- System message: The system message is the main context that is sent to the agent, including all additional context
- User message: The user message is the message that is sent to the agent.
- Chat history: The chat history is the history of the conversation between the agent and the user.
- Additional input: Any few-shot examples or other additional input that is added to the context.
System message context
The following are some key parameters that are used to create the system message:- Description: A description that guides the overall behaviour of the agent.
- Instructions: A list of precise, task-specific instructions on how to achieve its goal.
- Expected Output: A description of the expected output from the Agent.
System message Parameters
The Agent creates a default system message that can be customized using the following agent parameters:
See the full Agent reference for more information.
How the system message is built
Lets take the following example agent:Additional Context
You can add additional context to the end of the system message using theadditional_context parameter.
Here, additional_context adds a note to the system message indicating that the agent can access specific database tables.
Tool Instructions
If you are using a Toolkit on your agent, you can add tool instructions to the system message using theinstructions parameter:
<additional_information> tags.
Agentic Memories
If you haveenable_agentic_memory set to True on your agent, the agent gets the ability to create/update user memories using tools.
This adds the following to the system message:
Agentic Knowledge Filters
If you have knowledge enabled on your agent, you can let the agent choose the knowledge filters using theenable_agentic_knowledge_filters parameter.
This will add the following to the system message:
Set the system message directly
You can manually set the system message using thesystem_message parameter. This will ignore all other settings and use the system message you provide.
User message context
Theinput sent to the Agent.run() or Agent.print_response() is used as the user message.
Additional user message context
You can add additional context to the user message using the following agent parameters: The following agent parameters configure how the user message is built:add_knowledge_to_contextadd_dependencies_to_context
Chat history
If you have database storage enabled on your agent, session history is automatically stored (see sessions). You can now add the history of the conversation to the context usingadd_history_to_context.
Managing Tool Calls
Themax_tool_calls_from_history parameter can be used to add only the n most recent tool calls from history to the context.
This helps manage context size and reduce token costs during agent runs.
Consider the following example:
- Run 1-3: Model sees tool calls [1], [1,2], [1,2,3]
- Run 4: Model sees tool calls [2,3,4] (tool call 1 filtered out)
- Run 5: Model sees tool calls [3,4,5] (tool calls 1-2 filtered out)
Important:
max_tool_calls_from_history filters tool calls from the runs loaded by num_history_runs. Your database always contains the complete history.Few-shot learning with additional input
You can add entire additional messages to your agent’s context using theadditional_input parameter.
These messages are added to the context as if they were part of the conversation history.
You can give your agent examples of how it should respond (also called “few-shot prompting”):
Context Caching
Most model providers support caching of system and user messages, though the implementation differs between providers. The general approach is to cache repetitive content and common instructions, and then reuse that cached content in subsequent requests as the prefix of your system message. In other words, if the model supports it, you can reduce the number of tokens sent to the model by putting static content at the start of your system message. Agno’s context construction is designed to place the most likely static content at the beginning of the system message.If you wish to fine-tune this, the recommended approach is to manually set the system message. Some examples of prompt caching:
- OpenAI’s prompt caching
- Anthropic prompt caching -> See an Agno example of this
- OpenRouter prompt caching
Developer Resources
- View the Agent schema
- View Cookbook