Skip to main content

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 via config_module/config.yaml:

Error Handling

Debug Logging

The agent logs state transitions:

Best Practices

  1. Always set user_id: For per-user tool authentication
  2. Monitor MAX_ITER: Prevent infinite loops
  3. Use streaming: For better UX with long responses
  4. Reset state: Agent resets to initial state after each conversation
  5. Handle errors: Graceful degradation on state failures

Troubleshooting

Check state machine for deadlocks:
Verify tool manager is initialized:
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