Architecture
Junkie uses a multi-agent team architecture built on the Agno framework. The system consists of:- Team Leader: Orchestrates task delegation and manages the overall conversation flow
- Specialized Agents: Handle specific domains (code execution, research, context analysis)
- Shared Resources: Database, memory manager, and observability infrastructure
How Agents Work Together
The team operates with a delegation hierarchy:Delegation Flow
- User sends message to Discord
- Team Leader receives the message and analyzes the task
- Leader delegates to the most appropriate specialist:
- Deep research / real-time data → Perplexity Agent
- Quick code execution / math → Groq Compound Agent
- Complex code / sandbox operations → Code Agent
- Chat history analysis → Context Q&A Agent
- Specialist executes the task using its tools
- Leader integrates results and responds to user
Agent Lifecycle
Team Creation
Teams are created per-user with LRU caching:Resource Cleanup
When teams are evicted from cache:- MCP connections are closed
- Team-level resources are cleaned up
- Per-user locks are removed
Shared Infrastructure
Database (PostgreSQL)
Memory Manager
Observability (Phoenix)
Configuration
Key environment variables:MAX_AGENTS: Maximum number of cached teams (LRU eviction)AGENT_HISTORY_RUNS: Number of history runs to keepAGENT_RETRIES: Number of retries for failed operationsDEBUG_MODE,DEBUG_LEVEL: Debugging configurationCONTEXT_AGENT_MODEL: Model for context Q&A agentPOSTGRES_URL: Database connection URL