A multi-agent system for financial data analysis with supervisor coordination, query interpretation, and data preparation capabilities.
- Supervisor Agent: Coordinates all tasks and agents
- Interpreter Agent: Processes and interprets user queries
- Data Prep Agent: Handles data preparation tasks
- Data Manager: Manages Snowflake database operations
- Model: GPT-4.1-mini (OpenAI)
- Database: Snowflake (INVEST_NEXT_DEV/GENAI)
- Framework: LangChain + LangGraph
- Environment: Python with UV package manager
- Status: ✅ Completed
- Goal: Transform single-execution script into interactive CLI with while loop
- Features Added:
- Interactive while loop for continuous operation
- Cool banner with emojis and timestamp
- Configuration display at startup showing API key status, model, database
- Real-time query processing with visual feedback
- Graceful exit handling (exit/quit/Ctrl+C)
- Session management with unique session IDs
- Query counter and session summary
- Error handling and recovery
- Fresh global state for each query
- Status: ✅ Completed
- Goal: Add human-friendly output with verbose debug option
- Features Added:
- Command line argument parsing with
--verbose/-vflag - Smart AI response extraction from LangChain messages
- Clean, conversational output format (default mode)
- Verbose debug mode showing technical details
- Token usage tracking and display
- Enhanced error handling with optional stack traces
- Dual output modes: normal vs verbose
- Command line argument parsing with
- Status: ✅ Completed
- Goal: Beautiful CLI with agent handoff visualization using Rich library
- Features Added:
- Rich library integration for beautiful CLI formatting
- Color-coded success/failure panels with borders
- Agent coordination flow visualization (Normal mode)
- Detailed agent handoff tree structure (Verbose mode)
- Professional token usage tables
- Tool usage extraction and display
- Visual agent flow:
Supervisor → Data Prep → Supervisor - Enhanced error formatting with Rich styling
- Clear separation between user info and debug details
- Status: ✅ Completed
- Goal: Transform single-query system into conversational flow with persistent memory
- Features Added:
- Added
langgraph-checkpoint-sqlite>=2.0.0dependency - Updated
GlobalStateto include proper message history withList[BaseMessage] - Created
MessagesStatetype for LangGraph integration withadd_messagesannotation - Replaced
InMemorySaverwithSqliteSaverfor persistent storage (chat_history.db) - Implemented message trimming (max 20 messages) to manage token limits
- Added conversation context display in CLI (
💬 Context: X previous messages) - Updated supervisor agent to pass conversation history to workflow
- Session-persistent conversation history within same CLI session
- Automatic conversation history management with error handling
- Enhanced CLI status display showing chat history configuration
- Added
- Status: ✅ Completed
- Goal: Fix CLI output formatting issues and improve tool call display
- Features Fixed:
- Removed debugger breakpoints from supervisor and runner
- Fixed missing tool arguments in Arguments/Query column
- Enhanced tool argument formatting for SQL queries, Python code, and transfers
- Cleaned up Agent Flow section to show only clean agent transitions
- Created separate Rich panel for detailed tool calls information
- Improved tool result display with better truncation and formatting
- Enhanced transfer tool result messages
- Technical Implementation:
- Breakpoint Removal: Removed
breakpoint()calls fromsupervisor/agent.py:167andrunner.py:313 - Argument Extraction: Enhanced
_format_sql_query(),_format_args(), and_format_python_code()methods - Clean Agent Flow: Simplified
format_agent_collaboration_summary()to show only agent names - Separate Tool Panel: Added dedicated Rich panel for tool calls in verbose mode with cyan border
- Better Formatting: Improved argument display for SQL queries, table schemas, and transfers
- Breakpoint Removal: Removed
- Status: ✅ Completed
- Goal: Fix agent flow truncation and capture missing SQL tool calls from sub-agents
- Issues Addressed:
- Agent Flow responses truncated at 60 characters
- Missing SQL tool calls in Tool Calls Details panel (only transfer operations shown)
- Features Implemented:
- Enhanced Agent Flow content display with smart truncation (60→200 characters)
- Improved tool call extraction to capture nested workflow operations
- Added hierarchical tool call organization by agent workflow
- Enhanced LangGraph supervisor configuration for better tool tracking
- Added comprehensive debugging output for tool call analysis
- Implemented agent context tracking and tool call inference
- Technical Implementation:
- Agent Flow Enhancement:
formatters.py- Increased truncation limits and smart sentence-boundary breaking - Tool Extraction Overhaul:
runner.py:_extract_tool_calls()- Enhanced to capture ToolMessages and infer agents - LangGraph Configuration:
supervisor/agent.py- Enabledadd_handoff_messages=Truefor detailed handoff tracking - Hierarchical Display:
formatters.py- New_add_tool_row_to_table()method with agent-grouped organization - Context Tracking: Added agent context tracking through message sequences for better tool attribution
- Debug Infrastructure: Added comprehensive message type analysis for troubleshooting tool call extraction
- Agent Flow Enhancement:
- Status: ✅ Completed
- Goal: Extract nested SQL tool calls from sub-agent workflows and restructure UI panels
- Root Cause Identified: LangGraph ReAct agents encapsulate SQL tool calls within internal workflows - these don't propagate to supervisor message stream
- Features Implemented:
- Deep debugging infrastructure with comprehensive message analysis
- Enhanced checkpointer access to investigate sub-agent workflow states
- Recursive message traversal through nested LangGraph checkpoints
- Experimental nested tool call extraction from checkpointer metadata
- Separate "Tool Details" panel for detailed agent responses (magenta border)
- Simplified Agent Flow showing only handoffs:
User → Agent: [Processing...] → Transfer - Enhanced debug output showing tool call arguments and content previews
- Technical Implementation:
- Deep Debug Infrastructure:
runner.py- Enhanced message analysis with tool call arguments and content previews - Checkpointer Investigation:
supervisor/agent.py- Added checkpointer state analysis and storage inspection - Nested Tool Extraction:
runner.py:_extract_nested_tool_calls()- Experimental method to traverse checkpointer storage - UI Restructure:
cli/manager.py- New Tool Details panel (magenta) separate from Tool Calls Details (cyan) - Simplified Agent Flow:
formatters.py:format_agent_flow_tree()- Clean handoff display without detailed responses - Enhanced Tool Details:
formatters.py:create_tool_details_panel()- Structured display of agent thinking and results
- Deep Debug Infrastructure:
- Architecture Challenge: LangGraph's
create_react_agent()creates isolated workflows where SQL tool calls remain internal to sub-agents, requiring deeper inspection methods to extract complete tool call history
- Status: 🚧 In Progress
- Goal: Add streaming responses for real-time agent output and better user experience
- Implementation Plan:
- Create streaming infrastructure (
src/core/streaming.py) - Add streaming state fields to
GlobalStateandMessagesState - Update supervisor agent to use
astream()instead ofainvoke() - Enhance CLI with Rich live displays and progress visualization
- Implement multiple stream modes:
messages,updates,values,debug - Add real-time token counting and cost tracking during streaming
- Create buffered streaming output with agent handoff indicators
- Implement streaming error handling and graceful degradation
- Add CLI progress bars and spinners for agent operations
- Enable live conversation history updates during streaming
- Support stream interruption and cancellation (Ctrl+C)
- Create streaming infrastructure (
- Technical Details:
- Stream Modes: LangGraph supports
values,updates,custom,messages,debug - Rich Integration:
rich.live.Livefor real-time terminal updates - Buffer Management: Handle streaming chunks and format appropriately
- Fallback Strategy: Gracefully degrade to non-streaming if errors occur
- Stream Modes: LangGraph supports
- Default Query:
explore financial_data.db - Usage: Always use this as the standard test query for debugging and development
- Purpose: Tests database exploration capabilities and agent coordination
- Storage: SQLite database (
chat_history.db) for persistent conversation checkpoints - Memory Management: In-session conversation history with automatic trimming
- Message Format: LangChain
BaseMessagetypes (HumanMessage,AIMessage) - Context Window: Maximum 20 messages per conversation thread
- State Integration: Conversation history embedded in
GlobalStateand passed to agents
SqliteSaver.from_conn_string("chat_history.db"): Persistent checkpointerMessagesStatewithadd_messagesannotation for LangGraph compatibilitytrim_messages()andupdate_conversation_history()functions for memory management- Enhanced
process_query()to maintain conversation context across queries - Modified supervisor agent to include conversation history in workflow execution
- ✅ Conversational continuity within CLI sessions
- ✅ Token-efficient memory management with automatic trimming
- ✅ Persistent storage survives application restarts
- ✅ Context-aware agent responses
- ✅ Visual feedback showing conversation context size
OPENAI_API_KEY: Required for agent operations
# Normal mode with clean, human-friendly output
python main.py
uv run main.py
# Verbose mode with debug information and technical details
python main.py --verbose
uv run main.py --verbose
uv run main.py -v
# Help
python main.py --help- Normal Mode: Clean AI responses, easy to read
- Verbose Mode: Technical details, token usage, raw data, debug info
src/
├── agents/ # Agent implementations
├── core/ # Base classes and models
└── graph/ # Graph workflow definitions
- System handles missing API keys gracefully with warnings
- Uses financial dataset (finance_economics_dataset.csv)
- Async/await pattern for agent execution