Version 2.0.0

1. Executive Summary

The Hagglz Agent is an AI-powered negotiation system built on LangGraph that automatically analyzes bills, generates negotiation strategies, and helps users reduce their monthly expenses. The system uses specialized agents for different bill types, advanced document processing with Chunkr.ai, and confidence-based execution modes.

Key Capabilities

2. System Architecture

2.1 Core Components

graph TB
    subgraph Input Layer
        A[Bill Upload/URL] --> B[Chunkr Processor]
        B --> C[Document Intelligence]
    end

    subgraph Orchestration Layer
        C --> D[Router Agent]
        D --> E{Bill Type?}
        E -->|Utility| F[Utility Agent]
        E -->|Medical| G[Medical Agent]
        E -->|Subscription| H[Subscription Agent]
        E -->|Telecom| I[Telecom Agent]
    end

    subgraph Execution Layer
        F --> J[Strategy Generation]
        G --> J
        H --> J
        I --> J
        J --> K{Confidence Score}
        K -->|High >0.8| L[Auto Execute]
        K -->|Medium 0.5-0.8| M[Supervised]
        K -->|Low <0.5| N[Human Handoff]
    end

    subgraph Output Layer
        L --> O[Results API]
        M --> O
        N --> O
        O --> P[Client Response]
    end

2.2 Orchestrator Types

Orchestrator Purpose Key Features
Master Production deployment Full error handling, checkpointing, all agents
Simple Basic operations Simplified routing, GPT-3.5 for cost efficiency
Standalone Self-contained No external dependencies, validation first
Async Streaming operations WebSocket support, real-time updates
Parallel High throughput Fan-out/fan-in, batch processing

2.3 State Management

class NegotiationState(TypedDict):
    messages: Annotated[List[BaseMessage], operator.add]
    bill_data: dict    agent_decision: str    negotiation_result: dict    confidence_score: float    execution_mode: str    errors: Annotated[List[str], operator.add]
    error_count: int    retry_needed: bool    chunkr_result: Optional[dict]  # Chunkr processing result    human_feedback: Optional[dict]  # Human-in-loop feedback

3. Agent Specifications

3.1 Router Agent