Skip to main content

AgentSession Attributes

ParameterTypeDefaultDescription
session_idstrRequiredSession UUID
agent_idOptional[str]NoneID of the agent that this session is associated with
team_idOptional[str]NoneID of the team that this session is associated with
user_idOptional[str]NoneID of the user interacting with this agent
workflow_idOptional[str]NoneID of the workflow that this session is associated with
session_dataOptional[Dict[str, Any]]NoneSession Data: session_name, session_state, images, videos, audio
metadataOptional[Dict[str, Any]]NoneMetadata stored with this agent
agent_dataOptional[Dict[str, Any]]NoneAgent Data: agent_id, name and model
runsOptional[List[RunOutput]]NoneList of all runs in the session
summaryOptional[SessionSummary]NoneSummary of the session
created_atOptional[int]NoneThe unix timestamp when this session was created
updated_atOptional[int]NoneThe unix timestamp when this session was last updated

AgentSession Methods

upsert_run(run: RunOutput)

Adds a RunOutput to the runs list. If a run with the same run_id already exists, it updates the existing run.

get_run(run_id: str) -> Optional[RunOutput]

Retrieves a specific run by its run_id.

get_messages(...) -> List[Message]

Returns the messages belonging to the session that fit the given criteria. Parameters:
  • agent_id (Optional[str]): The id of the agent to get the messages from
  • team_id (Optional[str]): The id of the team to get the messages from
  • 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_session_summary() -> Optional[SessionSummary]

Get the session summary for the session

get_chat_history(...) -> List[Message]

Get the chat history (user and assistant messages) for the session. Use get_messages() for more filtering options. Parameters:
  • last_n_runs (Optional[int]): Number of recent runs to include. If None, all runs will be considered
Returns:
  • List[Message]: The chat history for the session