WorkflowSession Attributes
| Parameter | Type | Default | Description |
|---|---|---|---|
session_id | str | Required | Session UUID - this is the workflow_session_id that gets set on agents/teams |
user_id | Optional[str] | None | ID of the user interacting with this workflow |
workflow_id | Optional[str] | None | ID of the workflow that this session is associated with |
workflow_name | Optional[str] | None | Workflow name |
runs | Optional[List[WorkflowRunOutput]] | None | List of all workflow runs in the session |
session_data | Optional[Dict[str, Any]] | None | Session Data: session_name, session_state, images, videos, audio |
workflow_data | Optional[Dict[str, Any]] | None | Workflow configuration and metadata |
metadata | Optional[Dict[str, Any]] | None | Metadata stored with this workflow session |
created_at | Optional[int] | None | The unix timestamp when this session was created |
updated_at | Optional[int] | None | The unix timestamp when this session was last updated |
WorkflowSession Methods
upsert_run(run: WorkflowRunOutput)
Adds a WorkflowRunOutput 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[WorkflowRunOutput]
Retrieves a specific workflow run by its run_id.
get_workflow_history(num_runs: Optional[int] = None) -> List[Tuple[str, str]]
Gets workflow history as structured data (input, response pairs).
num_runs: Number of recent runs to include. If None, returns all available history.
get_workflow_history_context(num_runs: Optional[int] = None) -> Optional[str]
Gets formatted workflow history context for steps.
num_runs: Number of recent runs to include. If None, returns all available history.
<workflow_history_context> tags, suitable for providing context to workflow steps.
get_messages(...) -> List[Message]
Returns the messages belonging to the session that fit the given criteria. Note: Either agent_id or team_id must be provided, but not both.
Parameters:
agent_id(Optional[str]): The ID of the agent to get the messages forteam_id(Optional[str]): The ID of the team to get the messages forlast_n_runs(Optional[int]): The number of runs to return messages from, counting from the latest. Defaults to all runslimit(Optional[int]): The number of messages to return, counting from the latest. Defaults to all messagesskip_roles(Optional[List[str]]): Skip messages with these rolesskip_statuses(Optional[List[RunStatus]]): Skip messages with these statusesskip_history_messages(bool): Skip messages that were tagged as history in previous runs. Defaults to Trueskip_member_messages(bool): Skip messages created by members of the team. Defaults to True
List[Message]: The messages for the session
get_chat_history(last_n_runs: Optional[int] = None) -> List[WorkflowChatInteraction]
Return a list of WorkflowChatInteraction objects containing the input and output for each run in the session.
Parameters:
last_n_runs(Optional[int]): Number of recent runs to include. If None, all runs will be considered
List[WorkflowChatInteraction]: The chat history for the session as a list of input/output interactions