Harness¶
octomate.tentacles.inkling.agent ¶
Agent: a Pydantic AI Agent subclass that streams events AND the typed output.
run_stream_events gives raw events but not validated output; stream_output
gives validated partial output but not thinking/tool events. stream_events drives
iter() ourselves and emits BOTH from each node:
- thinking + tool-call events pass through unchanged,
- text replies stream as Pydantic AI's native text events; every validated output
type surfaces as Pydantic AI's own
FinalResult[OutputT]; outputs that validate tolist[MessageSegment]also stream oneResultSegmentEventper segment as partial validation reveals them. Other structured outputs surface only atFinalResult. - capability-injected events (e.g. todo events) flow through the capability wrapper that Pydantic AI applies to each node's stream,
- a terminal
AgentRunResultEventcloses the stream (run-complete / deferred).
The two output_type overloads carry the output type into the event stream, so the
final Agent[Deps, list[Row]].stream_events(...) value is a FinalResult[list[Row]].
Agent ¶
Bases: Agent[AgentDepsT, OutputDataT]
A Pydantic AI agent that can stream events and the typed output together.
Source code in octomate/tentacles/inkling/agent.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
stream_events
async
¶
stream_events(
user_prompt: str | Sequence[UserContent] | None = None,
*,
output_type: None = None,
conversation: Conversation | None = None,
message_history: Sequence[ModelMessage] | None = None,
deferred_tool_results: DeferredToolResults
| None = None,
conversation_id: str | None = None,
deps: AgentDepsT = None,
model: Model | KnownModelName | str | None = None,
instructions: AgentInstructions[AgentDepsT] = None,
model_settings: AgentModelSettings[AgentDepsT]
| None = None,
usage_limits: UsageLimits | None = None,
usage: RunUsage | None = None,
metadata: AgentMetadata[AgentDepsT] | None = None,
output_retries: int | None = None,
infer_name: bool = True,
toolsets: Sequence[AbstractToolset[AgentDepsT]]
| None = None,
builtin_tools: Sequence[AgentNativeTool[AgentDepsT]]
| None = None,
capabilities: Sequence[AgentCapability[AgentDepsT]]
| None = None,
spec: dict[str, Any] | AgentSpec | None = None,
cancellation_token: CancellationToken | None = None,
) -> AsyncGenerator[
StreamEvents[OutputDataT]
| AgentRunResultEvent[OutputDataT]
]
stream_events(
user_prompt: str | Sequence[UserContent] | None = None,
*,
output_type: OutputSpec[RunOutputDataT],
conversation: Conversation | None = None,
message_history: Sequence[ModelMessage] | None = None,
deferred_tool_results: DeferredToolResults
| None = None,
conversation_id: str | None = None,
deps: AgentDepsT = None,
model: Model | KnownModelName | str | None = None,
instructions: AgentInstructions[AgentDepsT] = None,
model_settings: AgentModelSettings[AgentDepsT]
| None = None,
usage_limits: UsageLimits | None = None,
usage: RunUsage | None = None,
metadata: AgentMetadata[AgentDepsT] | None = None,
output_retries: int | None = None,
infer_name: bool = True,
toolsets: Sequence[AbstractToolset[AgentDepsT]]
| None = None,
builtin_tools: Sequence[AgentNativeTool[AgentDepsT]]
| None = None,
capabilities: Sequence[AgentCapability[AgentDepsT]]
| None = None,
spec: dict[str, Any] | AgentSpec | None = None,
cancellation_token: CancellationToken | None = None,
) -> AsyncGenerator[
StreamEvents[RunOutputDataT]
| AgentRunResultEvent[RunOutputDataT]
]
stream_events(
user_prompt: str | Sequence[UserContent] | None = None,
*,
output_type: OutputSpec[Any] | None = None,
conversation: Conversation | None = None,
message_history: Sequence[ModelMessage] | None = None,
deferred_tool_results: DeferredToolResults
| None = None,
conversation_id: str | None = None,
deps: AgentDepsT = None,
model: Model | KnownModelName | str | None = None,
instructions: AgentInstructions[AgentDepsT] = None,
model_settings: AgentModelSettings[AgentDepsT]
| None = None,
usage_limits: UsageLimits | None = None,
usage: RunUsage | None = None,
metadata: AgentMetadata[AgentDepsT] | None = None,
output_retries: int | None = None,
infer_name: bool = True,
toolsets: Sequence[AbstractToolset[AgentDepsT]]
| None = None,
builtin_tools: Sequence[AgentNativeTool[AgentDepsT]]
| None = None,
capabilities: Sequence[AgentCapability[AgentDepsT]]
| None = None,
spec: dict[str, Any] | AgentSpec | None = None,
cancellation_token: CancellationToken | None = None,
) -> AsyncGenerator[
StreamEvents[Any] | AgentRunResultEvent[Any]
]
Source code in octomate/tentacles/inkling/agent.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
octomate.events ¶
Typed event stream the agent run produces and channels consume.
One stream, with these event families:
- Pydantic AI passthrough (
AgentStreamEvent) — thinking + tool-call events. - Output values — text replies stream as Pydantic AI's native
TextPartevents, every validated output type is emitted as Pydantic AI's ownFinalResult[OutputT], and outputs that validate tolist[MessageSegment]additionally stream oneResultSegmentEventper completed segment as partial validation reveals it — except a trailing text segment, whose growth streams asResultTextDeltaEvents instead. Rendering (typing text, sending segments, or handling any other structured value) is a consumer concern; the event just carries the typed value. - Display events (
DisplayEvent) — fire-and-forget, e.g. the granular todo events (TodoCreatedEvent/TodoUpdatedEvent/TodoStatusChangedEvent/TodoCompletedEvent/TodoDeletedEvent), each carrying the affectedTodo. - Action batch (
ActionBatchEvent) — a persisted batch of deferred actions (questions + approvals). Its response mode and blocking flag distinguish a live wait, a deferred continuation, and an asynchronous request. - Thread metadata (
ThreadEvent) — committed titles, project bindings, handoffs, ledger entries and command outcomes published by the thread manager. - Subagent lifecycle (
SubagentStartedEvent/SubagentSettledEvent) — an accomplice's run opening and finishing around itscommissionorwhispercall. - Agent messages (
AgentMessageEvent) — another agent session's words reaching a native run as its prompt, published by the tailer. - System messages (
SystemMessageEvent) — a line the harness wrote into a native run in the person's place, published by the tailer. - Habitat lifecycle (
HabitatEvent) — the phases a user's habitat passes through, published by the habitat manager.
Display, action and subagent events are emitted by capabilities (a capability
bundles a tool + instructions + wrap_run_event_stream) or the suspender; the
output events are emitted by Agent.stream_events (see
octomate/tentacles/inkling/agent.py).
The reflex graph also reports outside any run (GatewayEvent, RunErrorEvent),
handing each to a channel's Feelers.present, and brackets what a kick does on
the nerve: ReflexAwakeEvent and ReflexAsleepEvent around the kick,
RunStartedEvent and RunEndedEvent around each agent run in it. Channels
present every event and build none; the one consumer-made form is
RunResultEvent, the wire shape of a run result.
The run-stream union itself stays generic (FinalResult[OutputT]), so it has
no single serialized form — but the wire family is concrete, so WireEvent and
its wire_event_adapter live here too: the run stream as a wire consumer sees
it, with the generic/unserializable members replaced by their wire forms.
SubagentActivityKind
module-attribute
¶
SubagentActivityStatus
module-attribute
¶
RunActivity
module-attribute
¶
wire_event_adapter
module-attribute
¶
wire_event_adapter: TypeAdapter[WireEvent] = TypeAdapter(
WireEvent, config=ConfigDict(ser_json_bytes="base64")
)
ThreadEvent ¶
ThreadEvent = (
ThreadTitleChangedEvent
| ThreadProjectBoundEvent
| ThreadHandoffRecordedEvent
| ThreadMessageRecordedEvent
| ThreadCommandOutcomeRecordedEvent
)
HabitatEvent ¶
HabitatEvent = Annotated[
HabitatProgressEvent | HabitatFailedEvent,
Field(discriminator="event_kind"),
]
TodoEvent ¶
TodoEvent = (
TodoCreatedEvent
| TodoUpdatedEvent
| TodoStatusChangedEvent
| TodoCompletedEvent
| TodoDeletedEvent
)
StreamEvents ¶
StreamEvents = (
AgentStreamEvent
| ResultSegmentEvent
| ResultTextDeltaEvent
| FinalResult[OutputT]
| TodoEvent
| MessageSentEvent
| ArtifactAvailableEvent
| OAuthAuthorizationEvent
| ActionBatchEvent
| ActionBatchAnsweredEvent
| ActionBatchUpdatedEvent
| SubagentStartedEvent
| SubagentSettledEvent
| HabitatPreparationEvent
| RunActivityChangedEvent
)
WireEvent ¶
WireEvent = (
Annotated[
AgentStreamEvent,
Field(json_schema_extra=omit_native_discriminator),
]
| ResultSegmentEvent
| ResultTextDeltaEvent
| TodoEvent
| MessageSentEvent
| ArtifactAvailableEvent
| OAuthDeviceAuthorizationEvent
| OAuthAuthorizationEvent
| ActionBatchEvent
| ActionBatchAnsweredEvent
| ActionBatchUpdatedEvent
| SubagentStartedEvent
| SubagentSettledEvent
| AgentMessageEvent
| SystemMessageEvent
| RunResultEvent
| ReflexAwakeEvent
| ReflexAsleepEvent
| ReflexPhaseChangedEvent
| ThreadEvent
| CommandOutcomeEvent
| RunStartedEvent
| HabitatPreparationEvent
| RunActivityChangedEvent
| RunEndedEvent
| RunErrorEvent
| GatewayEvent
| HabitatEvent
)
SubagentStartedEvent
pydantic-model
¶
Bases: BaseModel
An accomplice's run opened, named by the call that started it; a channel draws it on a timeline of its own.
Fields:
-
event_kind(Literal['subagent_started']) -
invocation_id(str) -
kind(SubagentActivityKind) -
name(str)
Source code in octomate/events.py
SubagentSettledEvent
pydantic-model
¶
Bases: BaseModel
The child run finished; response is its accumulated reply text.
Fields:
-
event_kind(Literal['subagent_settled']) -
invocation_id(str) -
status(SubagentActivityStatus) -
detail(str | None) -
response(str)
Source code in octomate/events.py
AgentMessageEvent
pydantic-model
¶
Bases: BaseModel
Another agent session's words reached a native run as its prompt: a subagent handing its report back, or a peer writing in. No person said them.
Fields:
-
event_kind(Literal['agent_message']) -
message_id(UUID7) -
agent(MessageAgent) -
text(str)
Source code in octomate/events.py
SystemMessageEvent
pydantic-model
¶
Bases: BaseModel
A line the harness wrote into a native run in the person's place: the mark
Claude leaves where the person stopped a turn. Kept as a system row.
Fields:
-
event_kind(Literal['system_message']) -
message_id(UUID7) -
text(str)
Source code in octomate/events.py
ReflexAwakeEvent
pydantic-model
¶
Bases: BaseModel
A kick's first word: the reflex woken, before anything it does.
Fields:
-
request_id(UUID7 | None) -
event_kind(Literal['reflex_awake'])
Source code in octomate/events.py
ReflexAsleepEvent
pydantic-model
¶
Bases: BaseModel
A kick's last word, the counterpart of ReflexAwakeEvent: the reflex
asleep again, every run and move of the kick over, finished or failed. What
a console waits for before it reads the thread again.
Fields:
-
request_id(UUID7 | None) -
event_kind(Literal['reflex_asleep']) -
outcome(KickOutcome | None)
Source code in octomate/events.py
ReflexPhaseChangedEvent
pydantic-model
¶
Bases: BaseModel
The enclosing kick entered a phase, including work outside an agent run.
Fields:
-
event_kind(Literal['reflex_phase_changed']) -
phase(Literal['preparing', 'routing', 'moving', 'finalizing']) -
spell(GatewayAction | None)
Source code in octomate/events.py
ThreadTitleChangedEvent
pydantic-model
¶
Bases: BaseModel
A committed title change, including a title derived from an opening message.
Fields:
-
event_kind(Literal['thread_title_changed']) -
thread_id(UUID7) -
title(str | None) -
updated_at(AwareDatetime)
Source code in octomate/events.py
ThreadProjectBoundEvent
pydantic-model
¶
Bases: BaseModel
A thread committed its project binding.
Fields:
-
event_kind(Literal['thread_project_bound']) -
thread_id(UUID7) -
project_id(UUID7) -
updated_at(AwareDatetime)
Source code in octomate/events.py
ThreadHandoffRecordedEvent
pydantic-model
¶
Bases: BaseModel
A committed handoff identifies the thread's new agent and model.
Fields:
-
event_kind(Literal['thread_handoff_recorded']) -
thread_id(UUID7) -
handoff(Handoff)
Source code in octomate/events.py
ThreadMessageRecordedEvent
pydantic-model
¶
Bases: BaseModel
A ledger entry committed, advancing the thread's listing timestamp.
Includes command receipts and fork notices. The first recorded entry makes the thread visible to its registered participants; an unknown thread can be loaded by its id. No message content is copied into a listing notification.
Fields:
-
event_kind(Literal['thread_message_recorded']) -
thread_id(UUID7) -
message_id(UUID7) -
updated_at(AwareDatetime)
Source code in octomate/events.py
ThreadCommandOutcomeRecordedEvent
pydantic-model
¶
Bases: BaseModel
A command's terminal outcome committed to its receipt.
Fields:
-
event_kind(Literal['thread_command_outcome_recorded']) -
thread_id(UUID7) -
receipt_id(UUID7) -
outcome(CommandOutcome) -
updated_at(AwareDatetime)
Source code in octomate/events.py
event_kind
pydantic-field
¶
HabitatObservation
pydantic-model
¶
Bases: BaseModel
Config:
extra:forbidfrozen:True
Fields:
-
user_id(UUID7) -
habitat(str) -
name(str) -
sequence(int) -
updated_at(AwareDatetime) -
invocation_id(UUID7 | None) -
thread_id(UUID7 | None)
Source code in octomate/events.py
model_config
class-attribute
instance-attribute
¶
HabitatProgressEvent
pydantic-model
¶
Bases: HabitatObservation
Fields:
-
user_id(UUID7) -
habitat(str) -
name(str) -
sequence(int) -
updated_at(AwareDatetime) -
invocation_id(UUID7 | None) -
thread_id(UUID7 | None) -
event_kind(Literal['habitat_progress']) -
phase(Literal['unknown', 'preparing', 'starting', 'ready', 'stopping', 'stopped'])
Source code in octomate/events.py
HabitatFailedEvent
pydantic-model
¶
Bases: HabitatObservation
Fields:
-
user_id(UUID7) -
habitat(str) -
name(str) -
sequence(int) -
updated_at(AwareDatetime) -
invocation_id(UUID7 | None) -
thread_id(UUID7 | None) -
event_kind(Literal['habitat_failed']) -
phase(Literal['failed']) -
message(str)
Source code in octomate/events.py
RunStartedEvent
pydantic-model
¶
Bases: BaseModel
An agent run beginning, before anything it streams: the thread it reports into — another than the one asked about when a move carried the turn there. A kick holds one run or several, one after another.
Fields:
-
event_kind(Literal['run_started']) -
address(ChannelAddress) -
sender(UserProfile | None) -
agent_tentacle_id(str | None)
Source code in octomate/events.py
HabitatPreparationEvent
pydantic-model
¶
Bases: BaseModel
The run entered or completed preparation of its habitat.
Fields:
-
event_kind(Literal['habitat_preparation']) -
phase(Literal['preparing', 'ready'])
Source code in octomate/events.py
RunActivityChangedEvent
pydantic-model
¶
Bases: BaseModel
A harness reported activity within the enclosing run's existing brackets.
Fields:
-
event_kind(Literal['run_activity_changed']) -
activity(RunActivity) -
display_text(str | None)
Source code in octomate/events.py
event_kind
pydantic-field
¶
activity
pydantic-field
¶
Canonical run activity, supported by a real signal. Existing part and tool events still describe their own activity.
display_text
pydantic-field
¶
Optional harness label for this activity. None clears the previous label and selects standard wording.
RunEndedEvent
pydantic-model
¶
Bases: BaseModel
An agent run over, finished or failed, after everything it streamed: the
counterpart of RunStartedEvent.
Fields:
-
event_kind(Literal['run_ended']) -
thread_message_id(UUID7 | None) -
outcome(Literal['completed', 'failed', 'cancelled', 'deferred'] | None)
Source code in octomate/events.py
thread_message_id
pydantic-field
¶
The ledger row of the run's reply, for the channel to mark with the platform id it renders the reply as; None for a run that left no reply.
outcome
pydantic-field
¶
How this invocation ended. Deferred returns requests to the reflex; it does not decide whether the whole kick waits or moves. None means unreported, and a completed run does not finish its reflex.
RunResultEvent
pydantic-model
¶
Bases: BaseModel
The serializable projection of AgentRunResultEvent, whose payload
drags the run's private graph state and cannot go on a wire. Carries the
output value so a reply that never streamed (a plain non-streaming model,
a segment-less structured output) still reaches the consumer, and the
usage a session display renders.
Fields:
-
event_kind(Literal['run_result']) -
output(str | list[MessageSegment] | None) -
usage(RunUsage)
Source code in octomate/events.py
RunErrorEvent
pydantic-model
¶
Bases: BaseModel
A turn the graph could not finish, reported to the channel it came from, or to the one it was operated from.
Fields:
-
event_kind(Literal['run_error']) -
message(str) -
trace_id(str)
Source code in octomate/events.py
GatewayEvent
pydantic-model
¶
Bases: BaseModel
A spell carried the conversation: the console's own operation, or one the agent cast itself mid-turn.
Fields:
-
event_kind(Literal['gateway']) -
action(GatewayAction) -
destination(ChannelAddress) -
announcement(str | None) -
thread_message_id(UUID7 | None)
Source code in octomate/events.py
destination
pydantic-field
¶
Where the conversation is now; a summon's own thread.
announcement
pydantic-field
¶
The line the move leaves where the conversation was, or None when it leaves none there.
thread_message_id
pydantic-field
¶
The ledger row of that line, for the channel to mark with the platform id it posts the line as; None when the move recorded none.
ResultSegmentEvent
dataclass
¶
One completed message segment from a list[MessageSegment] output.
This is a convenience streaming event for channel renderers. The full typed
output, segment list or otherwise, still arrives as FinalResult[OutputT].
Source code in octomate/events.py
ResultTextDeltaEvent
dataclass
¶
The trailing text segment of a list[MessageSegment] output, as it grows.
A tool-backed segment reply carries its visible text inside the output
tool's streamed arguments, where no native text events exist; partial
validation reveals the trailing segment's text as it grows, and each event
carries the newly revealed piece so the channel renders the reply while the
model is still writing it. A segment that streamed this way is settled by
its last delta and never re-emitted as a ResultSegmentEvent.
Source code in octomate/events.py
DisplayEvent
pydantic-model
¶
ArtifactAvailableEvent
pydantic-model
¶
Bases: DisplayEvent
An artifact and its ledger reference have been committed.
The message ID deduplicates this appearance across live events and history; the artifact ID identifies the content for an independently authorized read. No invocation data or resource contents travel in this event.
Fields:
-
event_kind(Literal['artifact_available']) -
message_id(UUID7) -
artifact_id(UUID7)
Source code in octomate/events.py
TodoCreatedEvent
pydantic-model
¶
Bases: DisplayEvent
A todo was created.
Fields:
-
event_kind(Literal['todo_created']) -
todo(Todo)
Source code in octomate/events.py
TodoUpdatedEvent
pydantic-model
¶
Bases: DisplayEvent
A todo's content or placement changed.
Fields:
-
event_kind(Literal['todo_updated']) -
todo(Todo) -
previous(Todo | None)
Source code in octomate/events.py
TodoStatusChangedEvent
pydantic-model
¶
Bases: DisplayEvent
A todo moved to another status.
Fields:
-
event_kind(Literal['todo_status_changed']) -
todo(Todo) -
previous(Todo | None)
Source code in octomate/events.py
TodoCompletedEvent
pydantic-model
¶
Bases: DisplayEvent
A todo was completed.
Fields:
-
event_kind(Literal['todo_completed']) -
todo(Todo)
Source code in octomate/events.py
TodoDeletedEvent
pydantic-model
¶
Bases: DisplayEvent
A todo was deleted.
Fields:
-
event_kind(Literal['todo_deleted']) -
todo(Todo)
Source code in octomate/events.py
MessageSentEvent
pydantic-model
¶
Bases: DisplayEvent
The gate's send emitted segments to be delivered mid-run, without ending
the turn. Emit-only: the tool touches no channel. Where it goes is settled by
the time this is emitted — destination is None for the run's own conversation,
and otherwise a surface the gate resolved from the identity registry.
Fields:
-
event_kind(Literal['message_sent']) -
segments(list[MessageSegment]) -
destination(ChannelAddress | None) -
thread_message_id(UUID7 | None)
Source code in octomate/events.py
destination
pydantic-field
¶
None for this conversation. Otherwise the address the gate already resolved from the target the model named, so the consumer delivers without re-deciding anything and a refused destination never reaches one.
thread_message_id
pydantic-field
¶
The ledger row the send left, for the channel to mark with the platform id it delivers it as; None for a send recorded nowhere.
OAuthAuthorizationEvent
pydantic-model
¶
Bases: DisplayEvent
An integration is waiting for this user to authorize their own account.
Carries the authorization itself rather than a rendered message, so each channel
presents it as well as it can — a link in a plain timeline, a card whose button
opens the page where the platform has one. connector_id is the connection this
authorization belongs to.
Emitted as it stands by an authorization-code flow, where opening the link and approving is the whole errand: nothing to copy, and nothing to come back for because the provider's callback finishes the connection.
Fields:
-
event_kind(Literal['oauth_authorization', 'oauth_device_authorization']) -
connector_id(str) -
label(str) -
authorization_uri(str)
Source code in octomate/events.py
OAuthDeviceAuthorizationEvent
pydantic-model
¶
Bases: OAuthAuthorizationEvent
A device flow, which asks the user for one thing more.
Finishing is a second errand they have to come back for, which is why the code travels with the link and why a presenter asks them to return. A presenter that does not distinguish the two renders this as its base and simply leaves the code out — wrong, but not misleading.
Fields:
-
connector_id(str) -
label(str) -
authorization_uri(str) -
event_kind(Literal['oauth_authorization', 'oauth_device_authorization']) -
user_code(str)
Source code in octomate/events.py
LinkProfileAuthorizationEvent
pydantic-model
¶
Bases: DisplayEvent
A channel requests account authorization from the Octomate host.
Delivered directly through private feelers, not the agent's run stream. The host keeps the request; browser consent links its profile without returning an OAuth credential to the channel.
Fields:
-
event_kind(Literal['link_profile_authorization']) -
host(str) -
authorization(LinkProfileAuthorization)
Source code in octomate/events.py
ActionBatchEvent
pydantic-model
¶
Bases: BaseModel
A persisted batch of questions and approvals, which may block the run or leave it working while the user responds.
Carries the batch's questions and approvals (the persisted actions) so the
consumer renders + marks them together, and batch_id to correlate the reply
back to the right run.
Fields:
-
event_kind(Literal['action_batch']) -
batch_id(str) -
response_mode(DeferredResponseMode | None) -
blocks_run(bool | None) -
questions(list[DeferredQuestion]) -
approvals(list[DeferredApproval])
Source code in octomate/events.py
response_mode
pydantic-field
¶
The existing batch response mode: answer a live caller or open a later continuation. None means unreported; resume alone does not imply waiting.
blocks_run
pydantic-field
¶
Whether this batch blocks the run, as reported by the caller. False leaves the run active; None means unreported, not blocked.
from_batch
classmethod
¶
Source code in octomate/events.py
ActionBatchUpdatedEvent
pydantic-model
¶
Bases: BaseModel
Persisted draft feedback or closure changed; readers refresh existing cards.
Fields:
-
event_kind(Literal['action_batch_updated']) -
batch_id(str) -
closed(bool) -
questions(list[DeferredQuestion]) -
approvals(list[DeferredApproval])
Source code in octomate/events.py
ActionBatchAnsweredEvent
pydantic-model
¶
Bases: BaseModel
A batch's actions answered, from whichever surface answered them: every reader still showing the batch's cards marks them, so a card answered in one console, or on another channel, stops waiting everywhere.
Fields:
-
event_kind(Literal['action_batch_answered']) -
batch_id(str) -
approvals(dict[UUID7, bool]) -
answers(dict[UUID7, QuestionAnswer])
Source code in octomate/events.py
omit_native_discriminator ¶
Keep native event variants without OpenAPI-invalid registry mappings.
Native registries emit inline discriminator targets, while OpenAPI requires references. The generated oneOf still describes every event variant.
Source code in octomate/events.py
to_wire ¶
One run stream item as its wire event, or None for the shapes the wire replaces (see the wire module docstring).
Source code in octomate/events.py
octomate.tentacles.inkling.react ¶
ReactGraphInput ¶
ReactState
dataclass
¶
ReactDeps
dataclass
¶
Source code in octomate/tentacles/inkling/react.py
event_send_stream
class-attribute
instance-attribute
¶
choose_resolvers
class-attribute
instance-attribute
¶
output_type
class-attribute
instance-attribute
¶
permission_mode
class-attribute
instance-attribute
¶
instructions
class-attribute
instance-attribute
¶
model_settings
class-attribute
instance-attribute
¶
toolsets
class-attribute
instance-attribute
¶
builtin_tools
class-attribute
instance-attribute
¶
capabilities
class-attribute
instance-attribute
¶
cancellation_token
class-attribute
instance-attribute
¶
StartTurn
dataclass
¶
Bases: BaseNode[ReactState, ReactDeps[ReactOutputT, ReactDepsT], AgentRunResult[ReactOutputT]]
Source code in octomate/tentacles/inkling/react.py
run
async
¶
run(
ctx: GraphRunContext[
ReactState, ReactDeps[ReactOutputT, ReactDepsT]
],
) -> RunAgent[ReactOutputT, ReactDepsT]
Source code in octomate/tentacles/inkling/react.py
ResumeTurn
dataclass
¶
Bases: BaseNode[ReactState, ReactDeps[ReactOutputT, ReactDepsT], AgentRunResult[ReactOutputT]]
Source code in octomate/tentacles/inkling/react.py
run
async
¶
run(
ctx: GraphRunContext[
ReactState, ReactDeps[ReactOutputT, ReactDepsT]
],
) -> RunAgent[ReactOutputT, ReactDepsT]
Source code in octomate/tentacles/inkling/react.py
RunAgent
dataclass
¶
Bases: BaseNode[ReactState, ReactDeps[ReactOutputT, ReactDepsT], AgentRunResult[ReactOutputT]]
Source code in octomate/tentacles/inkling/react.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
user_prompt
class-attribute
instance-attribute
¶
deferred_results
class-attribute
instance-attribute
¶
run
async
¶
run(
ctx: GraphRunContext[
ReactState, ReactDeps[ReactOutputT, ReactDepsT]
],
) -> (
ResolveDeferred[ReactOutputT, ReactDepsT]
| End[AgentRunResult[ReactOutputT]]
)
Source code in octomate/tentacles/inkling/react.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | |
next_node
async
¶
next_node(
ctx: GraphRunContext[
ReactState, ReactDeps[ReactOutputT, ReactDepsT]
],
result: AgentRunResult[ReactOutputT],
span: LogfireSpan,
) -> (
ResolveDeferred[ReactOutputT, ReactDepsT]
| End[AgentRunResult[ReactOutputT]]
)
Source code in octomate/tentacles/inkling/react.py
ResolveDeferred
dataclass
¶
Bases: BaseNode[ReactState, ReactDeps[ReactOutputT, ReactDepsT], AgentRunResult[ReactOutputT]]
Source code in octomate/tentacles/inkling/react.py
run
async
¶
run(
ctx: GraphRunContext[
ReactState, ReactDeps[ReactOutputT, ReactDepsT]
],
) -> (
RunAgent[ReactOutputT, ReactDepsT]
| End[AgentRunResult[ReactOutputT]]
)
Source code in octomate/tentacles/inkling/react.py
build_react_graph ¶
build_react_graph(
start_node: ReactGraphInput[ReactOutputT, ReactDepsT],
) -> Graph[
ReactState,
ReactDeps[ReactOutputT, ReactDepsT],
ReactGraphInput[ReactOutputT, ReactDepsT],
AgentRunResult[ReactOutputT],
]
Wire the react nodes into a runnable graph for start_node to run through.
The node it will be run with is what binds the graph's type parameters — the output and deps types live only in annotations, so there is nothing else here to infer them from.
Source code in octomate/tentacles/inkling/react.py
iter_react_graph_events
async
¶
iter_react_graph_events(
start_node: StartTurn[ReactOutputT, ReactDepsT]
| ResumeTurn[ReactOutputT, ReactDepsT],
*,
state: ReactState,
deps: ReactDeps[ReactOutputT, ReactDepsT],
) -> AsyncGenerator[ReactStreamEvent[ReactOutputT], None]
Source code in octomate/tentacles/inkling/react.py
octomate.tentacles.inkling.deferred ¶
Deferred-tool resolution policies for Inkling's ReAct loop.
DeferredResolver ¶
Bases: Protocol
Resolve deferred tool calls in-process so the react loop can continue.
A resolver answers what it speaks for and leaves the rest alone — a posture has
an opinion about approvals and questions, and none at all about a teleport. It
is not the resolver's job to notice that it covered only part of the batch:
ResolveDeferred is where that is noticed, once, for whatever ran. The runner
refuses results covering only some of the calls it deferred, so a batch nobody
wholly answered goes to the suspender entire.
Source code in octomate/tentacles/inkling/deferred.py
ResolverChoice ¶
Bases: Protocol
Choose the resolvers for one deferral, from the conversation as it stands at that moment.
Asked at every deferral rather than once per run, because what may be resolved without a human is the conversation's approval posture — and that is switched while runs are going. Composed once, a switch would only reach the run after the one it was made during, which is the turn nobody was watching.
Several, in order, because one batch can hold deferrals of different kinds and no single policy speaks for all of them: each resolver answers its own and earlier ones win, so a catch-all goes last. An empty sequence means nothing answers this batch in-process — it goes to the suspender, and back to the caller when there is none.
Source code in octomate/tentacles/inkling/deferred.py
DeclineResolver
dataclass
¶
Resolves every deferred action by declining it immediately — the catch-all that closes a non-interactive run's chain (e.g. a commissioned accomplice). There is no human to ask, so approvals are denied and asks are answered with the decline, and the react loop continues to a final answer in-process instead of parking anything for review.
Last in the chain and answering everything, which is what guarantees a batch is covered: a run with no human has no suspender either, so anything left open would end the run holding requests nobody is coming to answer. Whatever ran before it has already had its say — earlier answers stand.
Source code in octomate/tentacles/inkling/deferred.py
message
class-attribute
instance-attribute
¶
message: str = "Declined: this run has no user to ask. Proceed on your best judgment and state the assumption in your report."
resolve
async
¶
Source code in octomate/tentacles/inkling/deferred.py
PostureResolver
dataclass
¶
Answers the two things an approval posture speaks about, and nothing else: the approvals it gates, and the questions it says not to put to a human.
What it walks past is the point. A teleport is deferred the same way a question
is, but it is neither an approval nor a question — no posture has an opinion on
it, and the suspender is what performs one. Left unanswered here, the batch is
not wholly covered and all of it goes to the human instead. A deferral arriving
with a kind this does not know goes the same way, so an unrecognized one reaches
a human rather than being answered on their behalf.
Source code in octomate/tentacles/inkling/deferred.py
resolve
async
¶
Source code in octomate/tentacles/inkling/deferred.py
octomate.tentacles.deferred ¶
Human deferral and stream interjections shared by agent providers.
DeferredSuspender ¶
Bases: Protocol
Persist actions for a human response. The caller controls the run's
lifecycle: request lets it continue, pause keeps it waiting for a live
reply, and suspend ends it for later continuation.
Returning an ActionBatchEvent asks the react loop to put the batch on the
stream, for whoever draws the run to present; returning None means there
is nothing to present, as for a deferral the graph performs itself.
Source code in octomate/tentacles/deferred.py
suspend
async
¶
Persist actions for a run that ends until its deferral is resolved.
The caller ends the current run; resolution starts a later run with the collected results. Return None for a deferral handled by the graph itself.
Source code in octomate/tentacles/deferred.py
pause
async
¶
Persist actions whose response unblocks the same live run.
The caller registers a waiter for batch_id before presenting the event, then awaits the response within the current run. This method does not wait.
Source code in octomate/tentacles/deferred.py
request
async
¶
Persist actions while the current run continues without waiting.
The caller presents the event and keeps running. The completed response starts a later turn after the current run finishes.
Source code in octomate/tentacles/deferred.py
Read
dataclass
¶
Ended
dataclass
¶
A runtime's own stream is over, or failed with error.
Source code in octomate/tentacles/deferred.py
Interjections ¶
What a live run's callbacks put on its stream while it waits on the runtime: the batch an approval pauses the run on, and the answer it resumes on, for whoever draws the run.
The runtime's own stream is read in a task of its own, so a batch gets through while the runtime is still waiting for its answer.
Source code in octomate/tentacles/deferred.py
interject ¶
around
async
¶
source's items in order, with each interjection as it is made.
Source code in octomate/tentacles/deferred.py
read
async
¶
octomate.tentacles.stream ¶
Run event streams shared by agent providers.
ReactStreamEvent ¶
ReactEventStream ¶
Deterministic-cleanup handle over a react event stream: entering the
context yields the underlying generator, exiting closes it. Mirrors
pydantic-ai's AgentEventStream, but typed over ReactStreamEvent — a
react run also streams octomate output/display/action-batch events.