Agent class is the foundation for building AI agents in Agno. It handles interactions with language models, manages tools, maintains conversation history, and provides features like memory, knowledge integration, and reasoning.
Constructor
Core Parameters
The language model to use for this agent. Can be a Model instance or model identifier string.
A descriptive name for the agent.
Unique identifier for the agent. Auto-generated if not provided.
A description of the agent added to the system message.
Instructions that guide the agent’s behavior. Can be a string, list of strings, or callable that returns instructions.
Default user ID for this agent.
Session & State
Default session ID (auto-generated if not provided).
Session state stored in the database to persist across runs.
If True, adds the session_state to the agent’s context.
If True, gives the agent tools to update session_state dynamically.
If True, overwrites stored session_state with the provided session_state.
If True, caches the agent session in memory for faster access.
Database
Database to use for storing agent sessions, memory, and history.
Memory
Memory manager for handling user memories.
Enables the agent to manage memories of the user.
If True, the agent creates/updates user memories at the end of runs.
If True, adds a reference to user memories in the context.
History
Adds messages from chat history to the context sent to the model.
Number of historical runs to include in the messages.
Number of historical messages to include in the context.
Maximum number of tool calls to include from history (None = no limit).
Knowledge & RAG
Knowledge base for the agent to retrieve information from.
Filters to apply when searching the knowledge base.
If True, adds knowledge references to the user prompt.
Adds a tool that allows the agent to search the knowledge base.
Custom retrieval function. If provided, used instead of default search.
Tools
Tools available to the agent. Can be a list or callable factory that returns tools.
Maximum number of tool calls allowed.
Controls which tool is called: “none”, “auto”, or specific tool specification.
Functions called around tool calls as middleware.
Hooks
Functions called after session load, before processing starts.
Functions called after output generation, before response return.
Reasoning
Enables step-by-step reasoning mode.
Separate model to use for reasoning steps.
Minimum number of reasoning steps.
Maximum number of reasoning steps.
Response Configuration
Pydantic model or JSON schema for structured output.
Use model-enforced structured outputs if supported.
If True, instructs the agent to format output using markdown.
Stream the response from the agent.
Stream intermediate steps from the agent.
Methods
run()
Run the agent with a message.input(str | List | Dict | Message | BaseModel | List[Message]): The input message(s)stream(bool): Whether to stream the responsesession_id(str): Optional session IDuser_id(str): Optional user IDsession_state(Dict[str, Any]): Optional session stateimages(Sequence[Image]): Optional images to includeaudio(Sequence[Audio]): Optional audio filesvideos(Sequence[Video]): Optional videosfiles(Sequence[File]): Optional files
RunOutput or Iterator of RunOutputEvent if streaming
arun()
Async version ofrun().