Agent Module Overview
The Agent Module is the core orchestrator of ARKOS, coordinating the state machine, memory, LLM, and tool systems to provide intelligent conversational interactions.Core Concepts
The Agent class manages the complete conversation lifecycle, including context retrieval, state transitions, tool execution, and response generation.
Architecture
Agent Class
Initialization
Key Attributes
Core Methods
step() - Main Processing Loop
Process messages through the state machine:step_stream() - Streaming Response
Stream responses character by character:call_llm() - LLM Interface
Call the language model:Context Management
Transition Selection
When multiple state transitions are possible:Tool Integration
Tool Argument Classes
Usage with FastAPI
The agent is used in the API server:Performance Timing
The agent includes built-in timing logs:Configuration
Agents are configured viaconfig_module/config.yaml:
Error Handling
Debug Logging
The agent logs state transitions:Best Practices
- Always set user_id: For per-user tool authentication
- Monitor MAX_ITER: Prevent infinite loops
- Use streaming: For better UX with long responses
- Reset state: Agent resets to initial state after each conversation
- Handle errors: Graceful degradation on state failures
Troubleshooting
Agent not responding
Agent not responding
Check state machine for deadlocks:
Tool calls failing
Tool calls failing
Verify tool manager is initialized:
Context too short
Context too short
Increase the turns parameter (config.yaml):
Next Steps
State Module
Learn about state management
Memory Module
Explore memory systems
Tool Module
Understand tool integration
Base Module
See the API server