roboto.ai.agent_session.record#

Module Contents#

type roboto.ai.agent_session.record.AgentContent = AgentTextContent | AgentToolUseContent | AgentToolResultContent | AgentErrorContent#

Type alias for all possible content types within agent messages.

class roboto.ai.agent_session.record.AgentContentType#

Bases: roboto.compat.StrEnum

Enumeration of different types of content within agent messages.

Defines the various content types that can be included in agent messages.

ERROR = 'error'#

Error information when message generation fails.

TEXT = 'text'#

Plain text content from users or AI responses.

TOOL_RESULT = 'tool_result'#

Results returned from tool executions.

TOOL_USE = 'tool_use'#

Tool invocation requests from the AI assistant.

class roboto.ai.agent_session.record.AgentErrorContent(/, **data)#

Bases: pydantic.BaseModel

Error content within an agent message.

Used when message generation fails due to an error or is cancelled by the user.

Parameters:

data (Any)

content_type: Literal[AgentContentType]#
error_code: str | None = None#

Optional error code for programmatic handling.

error_message: str#

User-friendly error message describing what went wrong.

class roboto.ai.agent_session.record.AgentGoalStatus#

Bases: roboto.compat.StrEnum

Lifecycle of a per-turn declared goal.

Goals begin PENDING when registered. They transition to ACHIEVED when the corresponding achieve-tool reports success, or to FAILED when the runner’s corrective re-prompt budget for the turn is exhausted (or when the worker cannot construct an achieve-tool for the goal).

ACHIEVED = 'achieved'#

Goal’s corresponding achieve-tool was invoked successfully.

FAILED = 'failed'#

Goal could not be achieved within the turn’s retry budget.

PENDING = 'pending'#

Goal has been registered but not yet completed.

class roboto.ai.agent_session.record.AgentMessage(/, **data)#

Bases: pydantic.BaseModel

A single message within an agent session.

Represents one message in the conversation, containing the sender role, content blocks, and generation status. Messages can contain multiple content blocks of different types (text, tool use, tool results).

Parameters:

data (Any)

content: list[AgentContent]#

List of content blocks that make up this message.

created: datetime.datetime = None#

Timestamp when this message was created.

is_complete()#

Check if message generation is complete.

Returns:

True if the message status is COMPLETED, False otherwise.

Return type:

bool

is_unsuccessful()#

Check if message generation failed or was cancelled.

Returns:

True if the message status is FAILED or CANCELLED, False otherwise.

Return type:

bool

role: AgentRole#

The role of the message sender (user, assistant, or roboto).

status: AgentMessageStatus#

Current generation status of this message.

classmethod text(text, role=AgentRole.USER)#

Create a simple text message.

Convenience method for creating a message containing only text content.

Parameters:
  • text (str) – The text content for the message.

  • role (AgentRole) – The role of the message sender. Defaults to USER.

Returns:

AgentMessage instance containing the text content.

Return type:

AgentMessage

class roboto.ai.agent_session.record.AgentMessageStatus#

Bases: roboto.compat.StrEnum

Enumeration of possible message generation states.

Tracks the lifecycle of message generation from initiation to completion.

CANCELLED = 'cancelled'#

Message generation was cancelled by the user.

COMPLETED = 'completed'#

Message generation has finished and content is complete.

FAILED = 'failed'#

Message generation failed due to an error.

GENERATING = 'generating'#

Message content is currently being generated.

NOT_STARTED = 'not_started'#

Message has been queued but generation has not begun.

is_terminal()#

Check if the message generation is in a terminal state.

Returns:

True if the message is in a terminal state, False otherwise.

Return type:

bool

class roboto.ai.agent_session.record.AgentRole#

Bases: roboto.compat.StrEnum

Enumeration of possible roles in an agent session.

Defines the different participants that can send messages in a session.

ASSISTANT = 'assistant'#

AI agent responding to user queries and requests.

ROBOTO = 'roboto'#

Roboto system providing tool results and system information.

USER = 'user'#

Human user sending messages to the agent.

class roboto.ai.agent_session.record.AgentSessionDelta(/, **data)#

Bases: pydantic.BaseModel

Incremental update to an agent session.

Contains only the changes since the last synchronization, used for efficient real-time updates without transferring the entire session history.

Parameters:

data (Any)

continuation_token: str#

Updated token for the next incremental synchronization.

goals: list[AgentSessionGoalRecord] | None = None#

Latest snapshot of every goal declared in the session, ordered by allocation. None means there has been no change since the previous delta — clients should retain the snapshot they already hold. An empty list means the session has no declared goals. A non-empty list is the authoritative current snapshot and replaces any prior value.

messages_by_idx: dict[int, AgentMessage]#

New or updated messages indexed by their position in the conversation.

status: AgentSessionStatus | None = None#

Updated status of the agent session.

title: str | None = None#

Updated title of the agent session.

class roboto.ai.agent_session.record.AgentSessionGoalRecord(/, **data)#

Bases: pydantic.BaseModel

Customer-visible read shape of a goal declared on an agent session.

Parameters:

data (Any)

concluded_at: datetime.datetime | None = None#

Timestamp when the goal transitioned to a terminal state (ACHIEVED or FAILED). None while the goal is still PENDING.

created: datetime.datetime#

Timestamp when the goal was registered.

goal_data: dict[str, Any]#

The validated goal payload as JSON. Use to_agent_goal() to recover the typed model the caller declared.

goal_type: str#

Discriminator selecting which AgentGoal model the goal_data payload conforms to (e.g. "dataset_summary").

message_sequence_num: int#

Index in the session’s full messages list of the AgentRole.USER message that declared this goal. Use to render goals adjacent to the turn they were attached to.

status: AgentGoalStatus#

Current lifecycle state of the goal.

to_agent_goal()#

Re-hydrate goal_data into the typed AgentGoal the caller declared.

Returns:

The validated, discriminated AgentGoal instance — for "dataset_summary" rows, a DatasetSummaryAgentGoal; for "dataset_triage" rows, a DatasetTriageGoal; etc.

Return type:

roboto.ai.goals.AgentGoal

class roboto.ai.agent_session.record.AgentSessionRecord(/, **data)#

Bases: pydantic.BaseModel

Complete record of an agent session.

Contains all the persistent data for a session including metadata, message history, and synchronization state.

Parameters:

data (Any)

property chat_id: str#

Backwards-compatible alias — serialized as chat_id in API responses.

Return type:

str

continuation_token: str#

Token used for incremental updates and synchronization.

created: datetime.datetime#

Timestamp when this agent session was created.

created_by: str#

User ID of the person who created this agent session.

forked_from_message_sequence_num: int | None = None#

Message sequence number in the source session that this fork was taken from.

Populated in tandem with forked_from_session_id; both are None for sessions that were not created as a fork.

forked_from_session_id: str | None = None#

If this session was forked, the id of the source session. None otherwise.

goals: list[AgentSessionGoalRecord] | None = None#

Goals declared across this session’s turns, ordered by allocation (i.e. by goal_index). None means goals were not loaded for this record (full-session reads populate the field; lightweight or legacy reads may omit it). An empty list means goals were loaded but the session never declared any.

messages: list[AgentMessage] = None#

Complete list of messages in the conversation.

model_profile: str | None = None#

Model profile used for this agent session (e.g., ‘standard’, ‘advanced’).

org_id: str#

Organization ID that owns this agent session.

session_id: str = None#

Unique identifier for this agent session.

status: AgentSessionStatus#

Current status of this agent session.

title: str | None = None#

Title of this agent session.

class roboto.ai.agent_session.record.AgentSessionStatus#

Bases: roboto.compat.StrEnum

Enumeration of possible agent session states.

Tracks the overall status of an agent session from creation to termination.

CLIENT_TOOL_TURN = 'client_tool_turn'#

Client must execute pending tool uses and submit results.

GOALS_FAILED = 'goals_failed'#

The agent runner exhausted its corrective re-prompt budget without achieving every declared goal for the most-recent turn. Signals to clients that the session needs human intervention before it can continue.

NOT_STARTED = 'not_started'#

Session has been created but no messages have been sent.

ROBOTO_TURN = 'roboto_turn'#

Roboto is generating a message.

USER_TURN = 'user_turn'#

User has the turn to send a message.

class roboto.ai.agent_session.record.AgentTextContent(/, **data)#

Bases: pydantic.BaseModel

Text content within an agent message.

Parameters:

data (Any)

text: str#

The actual text content of the message.

class roboto.ai.agent_session.record.AgentToolDetailResponse(/, **data)#

Bases: pydantic.BaseModel

Unsanitized tool request and response details for an agent tool invocation.

Parameters:

data (Any)

tool_result: roboto.ai.core.record.AgentToolResultContent#
tool_use: roboto.ai.core.record.AgentToolUseContent#
class roboto.ai.agent_session.record.AgentToolResultContent(/, **data)#

Bases: pydantic.BaseModel

Tool execution result content within an agent message.

Parameters:

data (Any)

content_type: Literal[AgentContentType]#
raw_response: dict[str, Any] | None = None#

Raw, unparsed response payload from tool execution.

runtime_ms: int#

Wall-clock execution time of the tool in milliseconds.

status: str#

Outcome of the tool execution (e.g. ‘success’, ‘error’).

tool_name: str#

Name of the tool that was executed.

tool_use_id: str#

Identifier of the tool invocation this result corresponds to.

class roboto.ai.agent_session.record.AgentToolUseContent(/, **data)#

Bases: pydantic.BaseModel

Tool usage request content within an agent message.

Parameters:

data (Any)

content_type: Literal[AgentContentType]#
input: dict[str, Any] | None = None#

Parsed tool input parameters chosen by the LLM (provider-agnostic).

raw_request: dict[str, Any] | None = None#

Raw, unparsed request payload for this tool invocation.

tool_name: str#

Name of the tool the LLM is requesting to invoke.

tool_use_id: str#

Unique identifier for this tool invocation, used to correlate with its result.

class roboto.ai.agent_session.record.ClientToolResult(/, **data)#

Bases: pydantic.BaseModel

Result of executing a client-side tool.

Parameters:

data (Any)

output: dict[str, Any] | None = None#

Structured output returned by the tool.

runtime_ms: int#

Wall-clock execution time of the tool in milliseconds.

status: ClientToolResultStatus#

Outcome of the tool execution.

tool_name: str#

Name of the tool that was executed.

tool_use_id: str#

Identifier of the tool invocation this result corresponds to.

class roboto.ai.agent_session.record.ClientToolResultStatus#

Bases: roboto.compat.StrEnum

Outcome of executing a client-side tool.

DECLINED = 'declined'#
ERROR = 'error'#
SUCCESS = 'success'#
class roboto.ai.agent_session.record.ClientToolSpec(/, **data)#

Bases: pydantic.BaseModel

Declarative specification for a client-side tool.

Unlike AgentTool (which is an ABC with a __call__ method for server-side execution), ClientToolSpec is a plain data model. The backend includes it in the LLM’s tool list but never executes it — the client is responsible for execution and submitting the result.

Parameters:

data (Any)

description: str#
input_schema: dict[str, Any]#
name: str#
class roboto.ai.agent_session.record.ForkChatRequest(/, **data)#

Bases: pydantic.BaseModel

Request payload for forking a chat at a specific message.

Parameters:

data (Any)

message_sequence_num: int#

Highest message sequence number (inclusive) to copy into the new chat.

class roboto.ai.agent_session.record.SendMessageRequest(/, **data)#

Bases: pydantic.BaseModel

Request payload for sending a message to an agent session.

Contains the message content and optional context for the AI assistant.

Parameters:

data (Any)

analysis_scope: roboto.ai.core.AnalysisScope | None = None#

Optional replacement analysis scope. When provided, overwrites the session’s current analysis scope; the new scope takes effect for this turn’s tool invocations and every turn thereafter. When None, the session’s existing analysis scope is left untouched (there is currently no wire-format way to clear a scope via send).

client_context: roboto.ai.core.ClientViewingContext | None = None#

Optional ClientViewingContext describing what the client was viewing when this message was composed. Wire field is client_context; the legacy context alias is accepted during the migration window and will be dropped in a future release.

client_tools: list[roboto.ai.core.record.ClientToolSpec] | None = None#

Optional client-side tools available for this invocation.

goals: list[roboto.ai.goals.AgentGoal] | None = None#

it gates a per-turn achieve-tool against each goal and re-prompts until every goal is satisfied or a per-turn retry budget is exhausted. May be omitted; when present, message becomes optional. Capped at MAX_GOALS_PER_TURN entries (see the constant for rationale).

Type:

Goals declared for this turn. The agent runner enforces achievement

message: roboto.ai.core.record.AgentMessage | None = None#

Message content to send. May be omitted when at least one goal is declared in goals; in that case the server synthesizes a minimal user message so the LLM has a turn-initiating prompt.

class roboto.ai.agent_session.record.StartAgentSessionRequest(/, **data)#

Bases: pydantic.BaseModel

Request payload for starting a new agent session.

Contains the initial messages and configuration for creating a new conversation.

Parameters:

data (Any)

analysis_scope: roboto.ai.core.AnalysisScope | None = None#

Optional analysis scope for the session. Delivered to every tool invocation on the server side; individual tools opt in to honoring it. None means no scope.

client_context: roboto.ai.core.ClientViewingContext | None = None#

Optional ClientViewingContext describing what the client was viewing when this session was started. Wire field is client_context; the legacy context alias is accepted during the migration window and will be dropped in a future release.

client_tools: list[roboto.ai.core.record.ClientToolSpec] | None = None#

Optional client-side tools available for this invocation.

goals: list[roboto.ai.goals.AgentGoal] | None = None#

it gates a per-turn achieve-tool against each goal and re-prompts until every goal is satisfied or a per-turn retry budget is exhausted. May be omitted; when present, messages may be empty. Capped at MAX_GOALS_PER_TURN entries (see the constant for rationale).

Type:

Goals declared for the first turn. The agent runner enforces achievement

messages: list[roboto.ai.core.record.AgentMessage] = None#

Initial messages to start the conversation with. May be empty when at least one goal is declared in goals; in that case the server synthesizes a minimal user message so the LLM has a turn-initiating prompt.

model_profile: str | None = None#

Optional model profile ID for the session (e.g. ‘standard’, ‘advanced’).

system_prompt: str | None = None#

Optional system prompt to customize AI assistant behavior.

class roboto.ai.agent_session.record.SubmitToolResultsRequest(/, **data)#

Bases: pydantic.BaseModel

Request payload for submitting client-side tool execution results.

Parameters:

data (Any)

client_tools: list[roboto.ai.core.record.ClientToolSpec] | None = None#

Optional updated client-side tools for the next invocation.

tool_results: list[ClientToolResult]#

Tool results from client-side execution.