cubeloop.session
ExecutionEventEnvelope
class
ExecutionEventEnvelope(run_id: str, attempt_id: str, seq: int, event: SessionEvent)
Attributes
run_id:strattempt_id:strseq:intevent:SessionEvent
ExecutionFinished
class
ExecutionFinished(
result: ExecutionResult,
type: Literal['execution_finished'] = 'execution_finished',
)
Attributes
result:ExecutionResulttype:Literal['execution_finished']
InputCommitted
class
InputCommitted(
input_id: str,
durability: InputDurability,
type: Literal['input_committed'] = 'input_committed',
)
Attributes
input_id:strdurability:InputDurabilitytype:Literal['input_committed']
SessionEvent
attribute
SessionEvent: TypeAlias = AgentEvent | InputCommitted | ExecutionFinished
InputEnvelope
class
InputEnvelope(input_id: str, message: Message, mode: InputMode)
Attributes
input_id:strmessage:Messagemode:InputMode
InputReceipt
class
InputReceipt(
input_id: str,
status: InputStatus,
durability: InputDurability | None = None,
)
Attributes
input_id:strstatus:InputStatusdurability:InputDurability | None
ExecutionSession
class
ExecutionSession(agent: Agent)
Public lifecycle for sequential execution attempts owned by one Agent.
Attributes
active_attempt_id:str | Noneturn_contexts:tuple[TurnExecutionContext, ...]state_context:JsonObject— The stable, live mapping persisted as checkpoint extra state.
Methods
load_checkpoint
load_checkpoint() -> CheckpointData | None
Atomically install checkpoint messages and extra while idle.
request_cancel
request_cancel() -> None
wait_for_idle
wait_for_idle() -> None
request_detach
request_detach() -> None
subscribe
subscribe(
listener: Callable[[ExecutionEventEnvelope], Any],
*,
required: bool = False,
name: str | None = None,
capacity: int = 256,
delivery_timeout: float = 1.0,
) -> Callable[[], None]
submit_input
submit_input(envelope: InputEnvelope) -> InputReceipt
cancel_input
cancel_input(input_id: str) -> InputReceipt
execute
execute(request: ExecutionRequest) -> ExecutionResult
Execute one attempt and return settled lifecycle facts.
ContinueExecutionRequest
class
ContinueExecutionRequest(
run_id: str,
attempt_id: str,
kind: Literal['continue'] = 'continue',
)
Attributes
run_id:strattempt_id:strkind:Literal['continue']
DeliveryError
class
DeliveryError(
consumer: str,
seq: int,
reason: Literal['timeout', 'closed', 'error'],
message: str = '',
)
Attributes
consumer:strseq:intreason:Literal['timeout', 'closed', 'error']message:str
ExecutionBusy
class
Raised when an Agent already has an executing or finalizing attempt.
ExecutionError
class
ExecutionError(
kind: Literal['cancelled', 'execution', 'finalization', 'inconsistent'],
message: str,
cause: BaseException | None = None,
)
Attributes
kind:Literal['cancelled', 'execution', 'finalization', 'inconsistent']message:strcause:BaseException | None
ExecutionOutcome
attribute
ExecutionOutcome: TypeAlias = Literal['completed', 'suspended', 'cancelled', 'failed', 'incomplete']
ExecutionRequest
attribute
ExecutionRequest: TypeAlias = PromptExecutionRequest | RespondExecutionRequest | ContinueExecutionRequest
ExecutionResult
class
ExecutionResult(
run_id: str,
attempt_id: str,
outcome: ExecutionOutcome,
pending_request: HitlRequest | None = None,
error: ExecutionError | None = None,
checkpoint_committed: bool = False,
history_consistent: bool = True,
delivery_errors: tuple[DeliveryError, ...] = (),
)
Attributes
run_id:strattempt_id:stroutcome:ExecutionOutcomepending_request:HitlRequest | Noneerror:ExecutionError | Nonecheckpoint_committed:boolhistory_consistent:booldelivery_errors:tuple[DeliveryError, ...]
PromptExecutionRequest
class
PromptExecutionRequest(
run_id: str,
attempt_id: str,
message: str | Message | list[Message],
kind: Literal['prompt'] = 'prompt',
)
Attributes
run_id:strattempt_id:strmessage:str | Message | list[Message]kind:Literal['prompt']
RespondExecutionRequest
class
RespondExecutionRequest(
run_id: str,
attempt_id: str,
answer: StructuredValue,
question_id: str | None = None,
kind: Literal['respond'] = 'respond',
)
Attributes
run_id:strattempt_id:stranswer:StructuredValuequestion_id:str | Nonekind:Literal['respond']
MessageView
class
MessageView(
role: str,
content: tuple[FrozenObject, ...],
metadata: Mapping[str, Any],
run_id: str | None,
_values: Mapping[str, Any],
)
Attributes
role:strcontent:tuple[FrozenObject, ...]metadata:Mapping[str, Any]run_id:str | None
Methods
capture
capture(cls, message: Message) -> MessageView
ToolExecutionBinding
class
ToolExecutionBinding(
name: str,
definition: FrozenObject,
parameters: type[BaseModel],
execute: Callable[..., Awaitable[AgentToolResult]],
hitl_builtin: bool,
execution_mode: Literal['sequential', 'parallel'] | None,
_source_id: int,
)
Attributes
name:strdefinition:FrozenObjectparameters:type[BaseModel]execute:Callable[..., Awaitable[AgentToolResult]]hitl_builtin:boolexecution_mode:Literal['sequential', 'parallel'] | None
Methods
capture
capture(cls, tool: AgentTool) -> ToolExecutionBinding
TurnExecutionContext
class
TurnExecutionContext(
turn_id: str,
run_id: str,
attempt_id: str,
model: FrozenObject,
reasoning: FrozenObject,
system_prompt: str,
messages: tuple[MessageView, ...],
tools: tuple[ToolExecutionBinding, ...],
policy_revision: str | None = None,
model_attempt_id: str | None = None,
)
Attributes
turn_id:strrun_id:strattempt_id:strmodel:FrozenObjectreasoning:FrozenObjectsystem_prompt:strmessages:tuple[MessageView, ...]tools:tuple[ToolExecutionBinding, ...]policy_revision:str | Nonemodel_attempt_id:str | None
Methods
capture
capture(
cls,
*,
turn_id: str,
run_id: str,
attempt_id: str,
model: Model,
reasoning: ReasoningControl,
system_prompt: str,
messages: list[Message],
tools: list[AgentTool] | None,
policy_revision: str | None = None,
model_attempt_id: str | None = None,
) -> TurnExecutionContext
matches_model
matches_model(model: Model, model_attempt_id: str | None) -> bool
binding_for
binding_for(name: str) -> ToolExecutionBinding | None
extend
extend(tool: AgentTool) -> TurnExecutionContext