Parameters

ParameterTypeDefaultDescription
modelOptional[Model]NoneModel to use for this Agent
nameOptional[str]NoneAgent name
idOptional[str]NoneAgent ID (autogenerated UUID if not set)
user_idOptional[str]NoneDefault user_id to use for this agent
session_idOptional[str]NoneDefault session_id to use for this agent (autogenerated if not set)
session_stateOptional[Dict[str, Any]]NoneDefault session state (stored in the database to persist across runs)
add_session_state_to_contextboolFalseSet to True to add the session_state to the context
enable_agentic_stateboolFalseSet to True to give the agent tools to update the session_state dynamically
cache_sessionboolFalseIf True, cache the current Agent session in memory for faster access
search_session_historyOptional[bool]FalseSet this to True to allow searching through previous sessions.
num_history_sessionsOptional[int]NoneSpecify the number of past sessions to include in the search. It’s advisable to keep this number to 2 or 3 for now, as a larger number might fill up the context length of the model, potentially leading to performance issues.
dependenciesOptional[Dict[str, Any]]NoneDependencies available for tools and prompt functions
add_dependencies_to_contextboolFalseIf True, add the dependencies to the user prompt
dbOptional[BaseDb]NoneDatabase to use for this agent
memory_managerOptional[MemoryManager]NoneMemory manager to use for this agent
enable_agentic_memoryboolFalseEnable the agent to manage memories of the user
enable_user_memoriesboolFalseIf True, the agent creates/updates user memories at the end of runs
add_memories_to_contextOptional[bool]NoneIf True, the agent adds a reference to the user memories in the response
enable_session_summariesboolFalseIf True, the agent creates/updates session summaries at the end of runs
add_session_summary_to_contextOptional[bool]NoneIf True, the agent adds session summaries to the context
session_summary_managerOptional[SessionSummaryManager]NoneSession summary manager
add_history_to_contextboolFalseAdd the chat history of the current session to the messages sent to the Model
num_history_runsint3Number of historical runs to include in the messages.
knowledgeOptional[Knowledge]NoneAgent Knowledge
knowledge_filtersOptional[Dict[str, Any]]NoneKnowledge filters to apply to the knowledge base
enable_agentic_knowledge_filtersOptional[bool]NoneLet the agent choose the knowledge filters
add_knowledge_to_contextboolFalseEnable RAG by adding references from Knowledge to the user prompt
knowledge_retrieverOptional[Callable[..., Optional[List[Union[Dict, str]]]]]NoneFunction to get references to add to the user_message
references_formatLiteral["json", "yaml"]"json"Format of the references
metadataOptional[Dict[str, Any]]NoneMetadata stored with this agent
toolsOptional[List[Union[Toolkit, Callable, Function, Dict]]]NoneA list of tools provided to the Model
tool_call_limitOptional[int]NoneMaximum number of tool calls allowed for a single run
tool_choiceOptional[Union[str, Dict[str, Any]]]NoneControls which (if any) tool is called by the model
tool_hooksOptional[List[Callable]]NoneFunctions that will run between tool calls
reasoningboolFalseEnable reasoning by working through the problem step by step
reasoning_modelOptional[Model]NoneModel to use for reasoning
reasoning_agentOptional[Agent]NoneAgent to use for reasoning
reasoning_min_stepsint1Minimum number of reasoning steps
reasoning_max_stepsint10Maximum number of reasoning steps
read_chat_historyboolFalseAdd a tool that allows the Model to read the chat history
search_knowledgeboolTrueAdd a tool that allows the Model to search the knowledge base
update_knowledgeboolFalseAdd a tool that allows the Model to update the knowledge base
read_tool_call_historyboolFalseAdd a tool that allows the Model to get the tool call history
send_media_to_modelboolTrueIf False, media (images, videos, audio, files) is only available to tools and not sent to the LLM
store_mediaboolTrueIf True, store media in run output
system_messageOptional[Union[str, Callable, Message]]NoneProvide the system message as a string or function
system_message_rolestr"system"Role for the system message
build_contextboolTrueSet to False to skip context building
descriptionOptional[str]NoneA description of the Agent that is added to the start of the system message
instructionsOptional[Union[str, List[str], Callable]]NoneList of instructions for the agent
expected_outputOptional[str]NoneProvide the expected output from the Agent
additional_contextOptional[str]NoneAdditional context added to the end of the system message
markdownboolFalseIf markdown=true, add instructions to format the output using markdown
add_name_to_contextboolFalseIf True, add the agent name to the instructions
add_datetime_to_contextboolFalseIf True, add the current datetime to the instructions to give the agent a sense of time
add_location_to_contextboolFalseIf True, add the current location to the instructions to give the agent a sense of place
timezone_identifierOptional[str]NoneAllows for custom timezone for datetime instructions following the TZ Database format (e.g. “Etc/UTC”)
resolve_in_contextboolTrueIf True, resolve session_state, dependencies, and metadata in the user and system messages
additional_inputOptional[List[Union[str, Dict, BaseModel, Message]]]NoneA list of extra messages added after the system message and before the user message
user_message_rolestr"user"Role for the user message
build_user_contextboolTrueSet to False to skip building the user context
retriesint0Number of retries to attempt
delay_between_retriesint1Delay between retries (in seconds)
exponential_backoffboolFalseIf True, the delay between retries is doubled each time
input_schemaOptional[Type[BaseModel]]NoneProvide an input schema to validate the input
output_schemaOptional[Type[BaseModel]]NoneProvide a response model to get the response as a Pydantic model
parser_modelOptional[Model]NoneProvide a secondary model to parse the response from the primary model
parser_model_promptOptional[str]NoneProvide a prompt for the parser model
output_modelOptional[Model]NoneProvide an output model to structure the response from the main model
output_model_promptOptional[str]NoneProvide a prompt for the output model
parse_responseboolTrueIf True, the response from the Model is converted into the output_schema
structured_outputsOptional[bool]NoneUse model enforced structured_outputs if supported (e.g. OpenAIChat)
use_json_modeboolFalseIf output_schema is set, sets the response mode of the model, i.e. if the model should explicitly respond with a JSON object instead of a Pydantic model
save_response_to_fileOptional[str]NoneSave the response to a file
streamOptional[bool]NoneStream the response from the Agent
stream_intermediate_stepsboolFalseStream the intermediate steps from the Agent
store_eventsboolFalsePersist the events on the run response
events_to_skipOptional[List[RunEvent]]NoneSpecify which event types to skip when storing events on the RunOutput
roleOptional[str]NoneIf this Agent is part of a team, this is the role of the agent in the team
debug_modeboolFalseEnable debug logs
debug_levelLiteral[1, 2]1Debug level for logging
telemetryboolTrueLog minimal telemetry for analytics

Functions

run

Run the agent. Parameters:
  • input (Union[str, List, Dict, Message, BaseModel, List[Message]]): The input to send to the agent
  • stream (Optional[bool]): Whether to stream the response
  • stream_intermediate_steps (Optional[bool]): Whether to stream intermediate steps
  • user_id (Optional[str]): User ID to use
  • session_id (Optional[str]): Session ID to use
  • session_state (Optional[Dict[str, Any]]): Session state to use
  • audio (Optional[Sequence[Audio]]): Audio files to include
  • images (Optional[Sequence[Image]]): Image files to include
  • videos (Optional[Sequence[Video]]): Video files to include
  • files (Optional[Sequence[File]]): Files to include
  • retries (Optional[int]): Number of retries to attempt
  • knowledge_filters (Optional[Dict[str, Any]]): Knowledge filters to apply
  • add_history_to_context (Optional[bool]): Whether to add history to context
  • add_dependencies_to_context (Optional[bool]): Whether to add dependencies to context
  • add_session_state_to_context (Optional[bool]): Whether to add session state to context
  • dependencies (Optional[Dict[str, Any]]): Dependencies to use for this run
  • metadata (Optional[Dict[str, Any]]): Metadata to use for this run
  • debug_mode (Optional[bool]): Whether to enable debug mode

arun

Run the agent asynchronously. Parameters:
  • input (Union[str, List, Dict, Message, BaseModel, List[Message]]): The input to send to the agent
  • stream (Optional[bool]): Whether to stream the response
  • user_id (Optional[str]): User ID to use
  • session_id (Optional[str]): Session ID to use
  • session_state (Optional[Dict[str, Any]]): Session state to use
  • audio (Optional[Sequence[Audio]]): Audio files to include
  • images (Optional[Sequence[Image]]): Image files to include
  • videos (Optional[Sequence[Video]]): Video files to include
  • files (Optional[Sequence[File]]): Files to include
  • stream_intermediate_steps (Optional[bool]): Whether to stream intermediate steps
  • retries (Optional[int]): Number of retries to attempt
  • knowledge_filters (Optional[Dict[str, Any]]): Knowledge filters to apply
  • add_history_to_context (Optional[bool]): Whether to add history to context
  • add_dependencies_to_context (Optional[bool]): Whether to add dependencies to context
  • add_session_state_to_context (Optional[bool]): Whether to add session state to context
  • dependencies (Optional[Dict[str, Any]]): Dependencies to use for this run
  • metadata (Optional[Dict[str, Any]]): Metadata to use for this run
  • debug_mode (Optional[bool]): Whether to enable debug mode
Returns:
  • Union[RunOutput, AsyncIterator[RunOutputEvent]]: Either a RunOutput or an iterator of RunOutputEvents, depending on the stream parameter

continue_run

Continue a run. Parameters:
  • run_response (Optional[RunOutput]): The run response to continue
  • run_id (Optional[str]): The run ID to continue
  • updated_tools (Optional[List[ToolExecution]]): Updated tools to use, required if the run is resumed using run_id
  • stream (Optional[bool]): Whether to stream the response
  • stream_intermediate_steps (Optional[bool]): Whether to stream intermediate steps
  • user_id (Optional[str]): User ID to use
  • session_id (Optional[str]): Session ID to use
  • retries (Optional[int]): Number of retries to attempt
  • knowledge_filters (Optional[Dict[str, Any]]): Knowledge filters to apply
  • dependencies (Optional[Dict[str, Any]]): Dependencies to use for this run
  • debug_mode (Optional[bool]): Whether to enable debug mode
Returns:
  • Union[RunOutput, Iterator[RunOutputEvent]]: Either a RunOutput or an iterator of RunOutputEvents, depending on the stream parameter

acontinue_run

Continue a run asynchronously. Parameters:
  • run_response (Optional[RunOutput]): The run response to continue
  • run_id (Optional[str]): The run ID to continue
  • updated_tools (Optional[List[ToolExecution]]): Updated tools to use, required if the run is resumed using run_id
  • stream (Optional[bool]): Whether to stream the response
  • stream_intermediate_steps (Optional[bool]): Whether to stream intermediate steps
  • user_id (Optional[str]): User ID to use
  • session_id (Optional[str]): Session ID to use
  • retries (Optional[int]): Number of retries to attempt
  • knowledge_filters (Optional[Dict[str, Any]]): Knowledge filters to apply
  • dependencies (Optional[Dict[str, Any]]): Dependencies to use for this run
  • debug_mode (Optional[bool]): Whether to enable debug mode
Returns:
  • Union[RunOutput, AsyncIterator[Union[RunOutputEvent, RunOutput]]]: Either a RunOutput or an iterator of RunOutputEvents, depending on the stream parameter
Run the agent and print the response. Parameters:
  • input (Union[List, Dict, str, Message, BaseModel, List[Message]]): The input to send to the agent
  • session_id (Optional[str]): Session ID to use
  • session_state (Optional[Dict[str, Any]]): Session state to use
  • user_id (Optional[str]): User ID to use
  • audio (Optional[Sequence[Audio]]): Audio files to include
  • images (Optional[Sequence[Image]]): Image files to include
  • videos (Optional[Sequence[Video]]): Video files to include
  • files (Optional[Sequence[File]]): Files to include
  • stream (Optional[bool]): Whether to stream the response
  • stream_intermediate_steps (Optional[bool]): Whether to stream intermediate steps
  • markdown (Optional[bool]): Whether to format output as markdown
  • show_message (bool): Whether to show the message
  • show_reasoning (bool): Whether to show reasoning
  • show_full_reasoning (bool): Whether to show full reasoning
  • console (Optional[Any]): Console to use for output
  • tags_to_include_in_markdown (Optional[Set[str]]): Tags to include in markdown content
  • knowledge_filters (Optional[Dict[str, Any]]): Knowledge filters to apply
  • add_history_to_context (Optional[bool]): Whether to add history to context
  • dependencies (Optional[Dict[str, Any]]): Dependencies to use for this run
  • metadata (Optional[Dict[str, Any]]): Metadata to use for this run
  • debug_mode (Optional[bool]): Whether to enable debug mode

aprint_response

Run the agent and print the response asynchronously. Parameters:
  • input (Union[List, Dict, str, Message, BaseModel, List[Message]]): The input to send to the agent
  • session_id (Optional[str]): Session ID to use
  • session_state (Optional[Dict[str, Any]]): Session state to use
  • user_id (Optional[str]): User ID to use
  • audio (Optional[Sequence[Audio]]): Audio files to include
  • images (Optional[Sequence[Image]]): Image files to include
  • videos (Optional[Sequence[Video]]): Video files to include
  • files (Optional[Sequence[File]]): Files to include
  • stream (Optional[bool]): Whether to stream the response
  • stream_intermediate_steps (Optional[bool]): Whether to stream intermediate steps
  • markdown (Optional[bool]): Whether to format output as markdown
  • show_message (bool): Whether to show the message
  • show_reasoning (bool): Whether to show reasoning
  • show_full_reasoning (bool): Whether to show full reasoning
  • console (Optional[Any]): Console to use for output
  • tags_to_include_in_markdown (Optional[Set[str]]): Tags to include in markdown content
  • knowledge_filters (Optional[Dict[str, Any]]): Knowledge filters to apply
  • add_history_to_context (Optional[bool]): Whether to add history to context
  • dependencies (Optional[Dict[str, Any]]): Dependencies to use for this run
  • metadata (Optional[Dict[str, Any]]): Metadata to use for this run
  • debug_mode (Optional[bool]): Whether to enable debug mode

cli_app

Run an interactive command-line interface to interact with the agent. Parameters:
  • input (Optional[str]): The input to send to the agent
  • session_id (Optional[str]): Session ID to use
  • user_id (Optional[str]): User ID to use
  • user (str): Name for the user (default: “User”)
  • emoji (str): Emoji for the user (default: “:sunglasses:”)
  • stream (bool): Whether to stream the response (default: False)
  • markdown (bool): Whether to format output as markdown (default: False)
  • exit_on (Optional[List[str]]): List of commands to exit the CLI
  • **kwargs: Additional keyword arguments

acli_app

Run an interactive command-line interface to interact with the agent asynchronously. Parameters:
  • input (Optional[str]): The input to send to the agent
  • session_id (Optional[str]): Session ID to use
  • user_id (Optional[str]): User ID to use
  • user (str): Name for the user (default: “User”)
  • emoji (str): Emoji for the user (default: “:sunglasses:”)
  • stream (bool): Whether to stream the response (default: False)
  • markdown (bool): Whether to format output as markdown (default: False)
  • exit_on (Optional[List[str]]): List of commands to exit the CLI
  • **kwargs: Additional keyword arguments

cancel_run

Cancel a run by run ID. Parameters:
  • run_id (str): The run ID to cancel
Returns:
  • bool: True if the run was successfully cancelled

get_run_output

Get the run output for the given run ID. Parameters:
  • run_id (str): The run ID
  • session_id (str): Session ID to use
Returns:
  • Optional[RunOutput]: The run output

get_last_run_output

Get the last run output for the session. Parameters:
  • session_id (str): Session ID to use
Returns:
  • Optional[RunOutput]: The last run output

get_session

Get the session for the given session ID. Parameters:
  • session_id (str): Session ID to use
Returns:
  • Optional[AgentSession]: The agent session

get_session_summary

Get the session summary for the given session ID. Parameters:
  • session_id (str): Session ID to use
Returns:
  • Session summary for the given session

get_user_memories

Get the user memories for the given user ID. Parameters:
  • user_id (str): User ID to use
Returns:
  • List[UserMemory]: The user memories

get_session_state

Get the session state for the given session ID. Parameters:
  • session_id (str): Session ID to use
Returns:
  • Dict[str, Any]: The session state

get_session_metrics

Get the session metrics for the given session ID. Parameters:
  • session_id (str): Session ID to use
Returns:
  • Optional[Metrics]: The session metrics

delete_session

Delete a session. Parameters:
  • session_id (str): Session ID to delete

save_session

Save a session to the database. Parameters:
  • session (AgentSession): The session to save

rename

Rename the agent and update the session. Parameters:
  • name (str): The new name for the agent
  • session_id (str): Session ID to use

get_session_name

Get the session name for the given session ID. Parameters:
  • session_id (str): Session ID to use
Returns:
  • str: The session name

set_session_name

Set the session name. Parameters:
  • session_id (str): Session ID to use
  • autogenerate (bool): Whether to autogenerate the name
  • session_name (Optional[str]): The name to set
Returns:
  • AgentSession: The updated session

get_messages_for_session

Get the messages for the given session ID. Parameters:
  • session_id (str): Session ID to use
Returns:
  • List[Message]: The messages for the session

get_chat_history

Get the chat history for the given session ID. Parameters:
  • session_id (str): Session ID to use
Returns:
  • List[Message]: The chat history

add_tool

Add a tool to the agent. Parameters:
  • tool (Union[Toolkit, Callable, Function, Dict]): The tool to add

set_tools

Replace the tools of the agent. Parameters:
  • tools (List[Union[Toolkit, Callable, Function, Dict]]): The tools to set