Skip to main content
An Agent is the primary building block. Each agent wraps an LLM, a set of tools, optional knowledge bases, and configurable capabilities like planning and reflection.

Creating an Agent

Use the @agent decorator to define an agent class:
from framework.agents import Agent
from framework.decorators import agent

@agent(
    name="MyAgent",
    description="A helpful assistant",
    system_prompt="You are a helpful assistant.",
    enable_planning=True,
    enable_reflection=False,
    enable_retrieval=False,
    llm_config={"model": "openai/gpt-4o", "temperature": 0.7},
    max_turns=10,
)
class MyAgent(Agent):
    pass

Agent Configuration

ParameterTypeDefaultDescription
namestrrequiredUnique agent identifier
descriptionstrNoneHuman-readable description
system_promptstrNoneBase system prompt
llm_configdictdefaultsModel, temperature, max_tokens
enable_planningboolTrueEnable multi-step planning
enable_reflectionboolTrueEnable self-reflection on outputs
enable_retrievalboolFalseEnable knowledge base retrieval
max_turnsint10Maximum LLM call iterations

Agent Capabilities

Planning

When enabled, the agent breaks complex tasks into steps before execution. Configure via PlanningConfig:
planning_config=PlanningConfig(
    llm_config={"model": "openai/gpt-4o-mini", "temperature": 0.5},
    max_tokens=2048,
)

Reflection

The agent reviews its own output and retries if quality is insufficient. Controlled by max_reflection_attempts.

Retrieval

Automatically searches attached knowledge bases for relevant context before responding.

The Execution Loop

User message → Memory pruning → Prompt build → LLM call

                          ┌───────────────────────┤
                          ▼                       ▼
                    Tool call?              Text response?
                          │                       │
                    Execute tool             Return to user

                    Feed result back → LLM call (next turn)
The loop continues until the LLM produces a final text response or max_turns is reached.

Built-In Agents

AgentFlow ships with several pre-configured agents:
AgentRole
MainAgentPrimary orchestrator — routes to sub-agents
EmailsAgentEmail read, write, and management
TasksAgentTask creation and tracking
MeetingsAgentCalendar and meeting management
RecordsAgentCRM record operations
ResearchAgentWeb search and company research
GeneralSubAgentAutonomous work delegation