Skip to main content

Parameters

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_events (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. By default, merged with the session state in the db.
  • 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
  • output_schema (Optional[Union[Type[BaseModel], Dict[str, Any]]]): Output schema to use for this run. Can be a Pydantic model or a JSON schema.
  • 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. By default, merged with the session state in the db.
  • 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_events (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
  • output_schema (Optional[Union[Type[BaseModel], Dict[str, Any]]]): Output schema to use for this run. Can be a Pydantic model or a JSON schema.
  • 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_events (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_events (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. By default, merged with the session state in the db.
  • 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
  • markdown (Optional[bool]): Whether to format output as markdown
  • show_message (bool): Whether to show the input message
  • show_reasoning (bool): Whether to show reasoning steps
  • show_full_reasoning (bool): Whether to show full reasoning information
  • 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
  • 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
  • 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. By default, merged with the session state in the db.
  • 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
  • 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
  • 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

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:
  • Optional[List[UserMemory]]: The user memories

aget_user_memories

Get the user memories for the given user ID asynchronously. Parameters:
  • user_id (str): User ID to use
Returns:
  • Optional[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

update_session_state

Update the session state for the given session ID. Parameters:
  • session_id (str): Session ID to use
  • session_state_updates (Dict[str, Any]): The session state keys and values to update. Overwrites the existing session state.
Returns:
  • Dict[str, Any]: The updated session state

get_session_metrics

Get the session metrics for the given session ID. Parameters:
  • session_id (Optional[str]): Session ID to use
Returns:
  • Optional[SessionMetrics]: 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

asave_session

Save a session to the database asynchronously. 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_session_messages

Get the messages for the given session ID. Parameters:
  • session_id (Optional[str]): The session ID to get the messages for. If not provided, the latest used session ID is used.
  • last_n_runs (Optional[int]): The number of runs to return messages from, counting from the latest. Defaults to all runs.
  • limit (Optional[int]): The number of messages to return, counting from the latest. Defaults to all messages.
  • skip_roles (Optional[List[str]]): Skip messages with these roles.
  • skip_statuses (Optional[List[RunStatus]]): Skip messages with these statuses.
  • skip_history_messages (bool): Skip messages that were tagged as history in previous runs. Defaults to True.
Returns:
  • List[Message]: The messages for the session

get_chat_history

Get the chat history for the given session ID. Parameters:
  • session_id (Optional[str]): The session ID to get the chat history for. If not provided, the latest used session ID is used.
  • last_n_runs (Optional[int]): The number of runs to return messages from, counting from the latest. Defaults to all runs.
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