runtime Module

Runtime domain models for response sessions and stream events.

Classes

ResponseExecution

Lightweight pipeline state for one response execution.

This type intentionally does not own persisted stream history. Stream replay concerns are modeled separately in StreamReplayState.

ResponseModeFlags

Execution mode flags captured from the create request.

StreamEventRecord

A persisted record for one emitted stream event.

StreamReplayState

Persisted stream replay state for one response identifier.

Functions

build_cancelled_response

Build a Response object representing a cancelled terminal state.

build_cancelled_response(response_id: str, agent_reference: AgentReference | dict[str, Any], model: str | None, created_at: datetime | None = None) -> ResponseObject

Parameters

Name Description
response_id
Required
str

The response identifier.

agent_reference
Required

The agent reference model or metadata dict.

model
Required
str | None

Optional model identifier.

created_at

Optional creation timestamp; defaults to now if omitted.

Default value: None

Returns

Type Description

A Response object with status "cancelled" and empty output.

build_failed_response

Build a ResponseObject representing a failed terminal state.

build_failed_response(response_id: str, agent_reference: AgentReference | dict[str, Any], model: str | None, created_at: datetime | None = None, error_message: str = 'An internal server error occurred.', error_code: str = 'server_error') -> ResponseObject

Parameters

Name Description
response_id
Required
str

The response identifier.

agent_reference
Required

The agent reference model or metadata dict.

model
Required
str | None

Optional model identifier.

created_at

Optional creation timestamp; defaults to now if omitted.

Default value: None
error_message
str

Human-readable error message.

Default value: An internal server error occurred.
error_code
str

Error code string (e.g. "server_error" or "storage_error").

Default value: server_error

Returns

Type Description

A Response object with status "failed" and empty output.