Graph, state and dependencies¶
octomate.reflex.graph ¶
Wiring for the reflex graph.
The nodes live one per module under nodes/; this is where they are assembled
into a runnable graph. Names the rest of the project imports from
octomate.reflex.graph are re-exported here so the split stays invisible to
callers.
ReflexEntryT
module-attribute
¶
ReflexEntryT = TypeVar(
"ReflexEntryT",
bound="BaseNode[ReflexState, ReflexDeps, ReflexGraphResult]",
)
Awake
dataclass
¶
Bases: BaseNode[ReflexState, ReflexDeps, ReflexGraphResult]
The entry node: explicit commands dispatch, batch replies resume, native
handoffs land, and user messages resolve their thread and go to Route.
Source code in octomate/reflex/nodes/awake.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 | |
run
async
¶
run(
ctx: GraphRunContext[ReflexState, ReflexDeps],
) -> (
Command
| Route
| ResumeDeferred
| Summon
| Teleport
| Scheme
| End[ReflexGraphResult]
)
Source code in octomate/reflex/nodes/awake.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 | |
thread_operation
async
¶
thread_operation(
ctx: GraphRunContext[ReflexState, ReflexDeps],
thread_ref: UUID | ThreadKey,
decision: SummonDecision | TeleportDecision,
*,
agent_id: str,
sender: UserProfile,
source: ChannelAddress,
requested_from: str,
) -> Summon | Teleport
Enter an existing thread its owner acts on: the console's operation on any thread, or a native session's teleport of its own.
Source code in octomate/reflex/nodes/awake.py
Command
dataclass
¶
Bases: BaseNode[ReflexState, ReflexDeps, ReflexGraphResult]
Own one command invocation through direct feedback or an ordinary agent stream.
Source code in octomate/reflex/nodes/command.py
run
async
¶
run(
ctx: GraphRunContext[ReflexState, ReflexDeps],
) -> Summon | Scheme | Teleport | End[ReflexGraphResult]
Source code in octomate/reflex/nodes/command.py
React
dataclass
¶
Bases: BaseNode[ReflexState, ReflexDeps, ReflexGraphResult]
Runs the summoned agent on the target channel and acts on how the run ends: a reply, a spell to perform, or a deferral to park.
Source code in octomate/reflex/nodes/react.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 | |
resume_results
class-attribute
instance-attribute
¶
run
async
¶
run(
ctx: GraphRunContext[ReflexState, ReflexDeps],
) -> (
React
| Summon
| Scheme
| Teleport
| End[ReflexGraphResult]
)
React, and leave the turn's workspace in the mirror however it ends.
In a finally because a turn that raised still did whatever it did on
disk. The files an agent wrote before its provider dropped the connection
are work, and until this runs the workspace is the only copy of them —
which also means the sweep can never reclaim that workspace, since it
refuses anything the mirror has not seen. A failed turn on a thread nobody
resumes would otherwise hold its disk for good.
A cancelled turn is the one case this does not cover: the save's first await raises straight back out, so its work stays in the workspace and the sweep keeps it, which is the safe direction.
Source code in octomate/reflex/nodes/react.py
react
async
¶
react(
ctx: GraphRunContext[ReflexState, ReflexDeps],
) -> (
React
| Summon
| Scheme
| Teleport
| End[ReflexGraphResult]
)
Source code in octomate/reflex/nodes/react.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 | |
ResumeDeferred
dataclass
¶
Bases: BaseNode[ReflexState, ReflexDeps, ReflexGraphResult]
Resolves a batch from the user's reply and, once it is whole, resumes the
suspended run through React.
Source code in octomate/reflex/nodes/resume_deferred.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 | |
run
async
¶
Source code in octomate/reflex/nodes/resume_deferred.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 | |
Route
dataclass
¶
Bases: BaseNode[ReflexState, ReflexDeps, ReflexGraphResult]
Picks the agent for an inbound message — the chat's pinned owner, the
flat-thread agent, or the channel's entry agent — and enters React.
Source code in octomate/reflex/nodes/route.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 | |
run
async
¶
Source code in octomate/reflex/nodes/route.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 | |
Scheme
dataclass
¶
Bases: BaseNode[ReflexState, ReflexDeps, ReflexGraphResult]
A scheme call: hand this turn's brief to the asking user's direct messages.
The receiver is whoever already owns that DM, or the channel's default agent when
nobody does — never an agent this run picked, so a group can't point someone's
private assistant somewhere. From there it is an ordinary handoff: the brief becomes
the receiving agent's prompt and the handoff is recorded on the DM's own thread, the
same way Route re-enters React with a decision it resolved itself.
Source code in octomate/reflex/nodes/scheme.py
run
async
¶
Source code in octomate/reflex/nodes/scheme.py
Summon
dataclass
¶
Bases: BaseNode[ReflexState, ReflexDeps, ReflexGraphResult]
Performs a summon: takes the surface over in place for the agent the decision
names, then re-enters React there.
Source code in octomate/reflex/nodes/summon.py
run
async
¶
Source code in octomate/reflex/nodes/summon.py
Teleport
dataclass
¶
Bases: BaseNode[ReflexState, ReflexDeps, ReflexGraphResult]
Create a thread at the prepared address, copy history and resume the agent.
An in-place move binds a project without creating a thread. A failed creation refuses the move before any history is copied.
Source code in octomate/reflex/nodes/teleport.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 | |
run
async
¶
Source code in octomate/reflex/nodes/teleport.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 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 | |
carry_on
async
¶
Run the agent where the move landed: on the user's prompt, recorded there as their message, or on its own call answered by where it now is.
Source code in octomate/reflex/nodes/teleport.py
land
async
¶
End the move where it landed, for the next message there to carry on: the handoff is recorded and the workspace saved, as a turn's end would.
Source code in octomate/reflex/nodes/teleport.py
bind
async
¶
Bind the thread landed in to the project the request names, and fork its workspace, so the resumed run starts in the project's code. The gate validated the project and the ref; a project missing here is a wiring bug. Answers the bound thread, re-read: the state's copy predates the binding, and the turn-end save reads the project off it.
Source code in octomate/reflex/nodes/teleport.py
DeferredResult
dataclass
¶
A turn that stopped on deferred requests, and the batch they were parked as.
Source code in octomate/reflex/state.py
ReflexDeps
dataclass
¶
The host's registries and managers a reflex run reaches through.
Source code in octomate/reflex/state.py
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 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | |
agents
class-attribute
instance-attribute
¶
runtime
cached
property
¶
Stateless orchestration shared by this graph's execution entries.
gateway_agents
cached
property
¶
The agents whose driven turns offer the gateway spells: each agent's own flag, settled at startup and read once. A turn of any other agent builds no session, so external callers find nothing live for it.
channel ¶
Source code in octomate/reflex/state.py
agent ¶
octomate_session
async
¶
octomate_session(
agent: AgentTentacle,
*,
user_profile: UserProfile | None,
thread_id: UUID7 | None,
conversation_address: ChannelAddress,
conversation_id: UUID | None = None,
) -> OctomateSession | None
One turn's gateway for agent, or None for an agent whose flag is off.
Built from the host's own registries, every channel's and not just this
one's: a spell that crosses lands where another channel's config decides who
runs, so the gateway offers — and checks against — that channel's routes,
and reads surfaces off it to know whether scheme can land. The agents
are what the accomplice spells run; without a thread there is nowhere for
a child conversation to live, and the gateway then does not offer them.
Source code in octomate/reflex/state.py
resolve_agent ¶
resolve_agent(
channel_id: str,
agent_id: str | None,
model: AgentRouteModelName | None,
) -> AgentModelConfig
Select an exposed agent and resolve a model from its catalog.
Source code in octomate/reflex/state.py
render_chat
async
¶
The ledger rows as one transcript: who spoke, under which identities, and
the #msg:<id> handle a brief would cite them by.
Each message is its segments, as they render themselves — the same body an
inbound event shows. message_text would be the shorter route and the wrong
one: it keeps only text and markdown, so a message that was a picture or a
quoted reply arrives as nothing at all.
ceiling cuts each message. It is 0 for the messages a turn must answer —
those are the work — and set for the chat behind them, where one pasted log
would otherwise be the whole slice.
Source code in octomate/reflex/state.py
report
async
¶
Publish that the turn failed, on the thread it came from. A turn that failed before it knew its source has nobody to tell.
Source code in octomate/reflex/state.py
carry
async
¶
Send a run's stream on the nerve at address as wire events, item by
item, until it ends.
Source code in octomate/reflex/state.py
record_move
async
¶
record_move(
address: ChannelAddress,
text: str,
*,
agent_tentacle_id: str,
platform_message_id: str | None = None,
) -> ThreadMessage
Write the line a move leaves behind to the ledger of the chat it left.
A person already sees it — the channel posted it, and a thread opened here hangs off it. The turn that comes next does not: a chat room's recap is built from the ledger, and a move nobody recorded leaves a chat in which the work simply stops. An agent reading that answers what was carried away ten minutes ago.
The row carries the opener's own platform id, so the ledger and the platform name the same message rather than two; a line still to be posted gets its id from the channel that posts it.
Source code in octomate/reflex/state.py
load_pending_prompt
async
¶
Source code in octomate/reflex/state.py
chat_recap
async
¶
What was said in this chat room before the messages the turn must answer.
Only a kick in a dm or a group chat needs it: that runs in a thread of its own, so its model context starts empty every time and the agent would answer a chat it cannot see. A thread carries its own history in the conversation and gets none of this — its context is already the whole of the work.
The chat is the parent's, so the rows come from there; how many, and how much of each, is the channel's to say.
Source code in octomate/reflex/state.py
ReflexResult
dataclass
¶
A finished turn: the decision it ran on, where it answered, and the agent's result.
Source code in octomate/reflex/state.py
ReflexState
dataclass
¶
All run-wide context for one reflex graph run.
Awake resolves the source context once and writes it here; downstream nodes read from state and carry only transition discriminators.
Source code in octomate/reflex/state.py
targets
class-attribute
instance-attribute
¶
summon_routes
class-attribute
instance-attribute
¶
trigger_thread_message_id
class-attribute
instance-attribute
¶
source_thread_address
class-attribute
instance-attribute
¶
source_thread_message_ids
class-attribute
instance-attribute
¶
user_prompt
class-attribute
instance-attribute
¶
ResponseTarget
dataclass
¶
Where a turn answers: the channel, the address on it, and how the reply is placed.
Source code in octomate/reflex/state.py
SummonDecision
pydantic-model
¶
Bases: BaseModel
A handoff decision: continue this turn with another agent, from a brief, in the conversation where it already is.
Fields:
-
action(Literal['summon']) -
reason(str) -
agent_id(str) -
model(AgentRouteModelName | None) -
effort(str | None) -
hint(str) -
brief(str)
Source code in octomate/schemas/triage.py
model
pydantic-field
¶
Selected model, or null to use the harness's native default.
brief
pydantic-field
¶
The receiver's whole opening prompt, refused over the cap rather than trimmed: what it leaves out, the receiver reads back through the handoff. Eight thousand characters is roughly two thousand tokens — the size a distilled handoff runs to, and well short of a pasted transcript.
build_reflex_graph ¶
build_reflex_graph(
entry: type[ReflexEntryT] = Awake,
) -> Graph[
ReflexState, ReflexDeps, ReflexEntryT, ReflexGraphResult
]
Wire the reflex nodes into a runnable graph, entered at entry.
Every edge comes from the nodes' own run return annotations, so the shape
stays declared where the transition is written rather than in a second list
here. A graph declares the one node it is entered at: a signal wakes the
whole reflex, so that is Awake, and only a test wires the same nodes with
a different door to exercise a stretch of them on its own.
Source code in octomate/reflex/graph.py
run_reflex
async
¶
Wake the reflex with signal, and say so on the nerve before anything
else. A failure is reported where the kick came from, and the reflex falls
asleep last whatever happened.
Source code in octomate/reflex/graph.py
octomate.reflex.state ¶
Graph state, dependencies and runtime orchestration.
The state and deps objects a node is handed, the runtime shared by execution entries, and the result variants a run ends in.
RECAP_HEADER
module-attribute
¶
RECAP_HEADER = "Recent messages in this chat. They are context and have been answered already — do not reply to them."
ReflexEntryT
module-attribute
¶
ReflexEntryT = TypeVar(
"ReflexEntryT",
bound="BaseNode[ReflexState, ReflexDeps, ReflexGraphResult]",
)
ResponseTarget
dataclass
¶
Where a turn answers: the channel, the address on it, and how the reply is placed.
Source code in octomate/reflex/state.py
PendingHandoff
dataclass
¶
A handoff one node decided, as far as it is known before it lands: the source side. The target is what landing resolves — the decision's route, as the agent is actually mounted — so it is read there when the row is recorded, and nothing here could name it without risking a second, drifting copy.
The source is who handed the conversation over, and where from as the row names it: the conversation the deciding turn ran in, the last model message in it and the run that left that message, read off the ledger rather than the run result because the row's foreign keys hold only for what was persisted. A native summon names its agent and nothing else, since the gateway cannot name the terminal session it came from; a route that pins a thread's owner names nobody.
Source code in octomate/reflex/state.py
source_agent_tentacle_id
class-attribute
instance-attribute
¶
source_conversation_id
class-attribute
instance-attribute
¶
source_model_message_id
class-attribute
instance-attribute
¶
land
async
¶
Record this handoff on the chat thread belongs to, naming the agent
and model decision resolved to, unless that chat already names them.
Source code in octomate/reflex/state.py
ReflexResult
dataclass
¶
A finished turn: the decision it ran on, where it answered, and the agent's result.
Source code in octomate/reflex/state.py
DeferredResult
dataclass
¶
A turn that stopped on deferred requests, and the batch they were parked as.
Source code in octomate/reflex/state.py
ReflexState
dataclass
¶
All run-wide context for one reflex graph run.
Awake resolves the source context once and writes it here; downstream nodes read from state and carry only transition discriminators.
Source code in octomate/reflex/state.py
targets
class-attribute
instance-attribute
¶
summon_routes
class-attribute
instance-attribute
¶
trigger_thread_message_id
class-attribute
instance-attribute
¶
source_thread_address
class-attribute
instance-attribute
¶
source_thread_message_ids
class-attribute
instance-attribute
¶
user_prompt
class-attribute
instance-attribute
¶
ReflexDeps
dataclass
¶
The host's registries and managers a reflex run reaches through.
Source code in octomate/reflex/state.py
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 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | |
agents
class-attribute
instance-attribute
¶
runtime
cached
property
¶
Stateless orchestration shared by this graph's execution entries.
gateway_agents
cached
property
¶
The agents whose driven turns offer the gateway spells: each agent's own flag, settled at startup and read once. A turn of any other agent builds no session, so external callers find nothing live for it.
channel ¶
Source code in octomate/reflex/state.py
agent ¶
octomate_session
async
¶
octomate_session(
agent: AgentTentacle,
*,
user_profile: UserProfile | None,
thread_id: UUID7 | None,
conversation_address: ChannelAddress,
conversation_id: UUID | None = None,
) -> OctomateSession | None
One turn's gateway for agent, or None for an agent whose flag is off.
Built from the host's own registries, every channel's and not just this
one's: a spell that crosses lands where another channel's config decides who
runs, so the gateway offers — and checks against — that channel's routes,
and reads surfaces off it to know whether scheme can land. The agents
are what the accomplice spells run; without a thread there is nowhere for
a child conversation to live, and the gateway then does not offer them.
Source code in octomate/reflex/state.py
resolve_agent ¶
resolve_agent(
channel_id: str,
agent_id: str | None,
model: AgentRouteModelName | None,
) -> AgentModelConfig
Select an exposed agent and resolve a model from its catalog.
Source code in octomate/reflex/state.py
render_chat
async
¶
The ledger rows as one transcript: who spoke, under which identities, and
the #msg:<id> handle a brief would cite them by.
Each message is its segments, as they render themselves — the same body an
inbound event shows. message_text would be the shorter route and the wrong
one: it keeps only text and markdown, so a message that was a picture or a
quoted reply arrives as nothing at all.
ceiling cuts each message. It is 0 for the messages a turn must answer —
those are the work — and set for the chat behind them, where one pasted log
would otherwise be the whole slice.
Source code in octomate/reflex/state.py
report
async
¶
Publish that the turn failed, on the thread it came from. A turn that failed before it knew its source has nobody to tell.
Source code in octomate/reflex/state.py
carry
async
¶
Send a run's stream on the nerve at address as wire events, item by
item, until it ends.
Source code in octomate/reflex/state.py
record_move
async
¶
record_move(
address: ChannelAddress,
text: str,
*,
agent_tentacle_id: str,
platform_message_id: str | None = None,
) -> ThreadMessage
Write the line a move leaves behind to the ledger of the chat it left.
A person already sees it — the channel posted it, and a thread opened here hangs off it. The turn that comes next does not: a chat room's recap is built from the ledger, and a move nobody recorded leaves a chat in which the work simply stops. An agent reading that answers what was carried away ten minutes ago.
The row carries the opener's own platform id, so the ledger and the platform name the same message rather than two; a line still to be posted gets its id from the channel that posts it.
Source code in octomate/reflex/state.py
load_pending_prompt
async
¶
Source code in octomate/reflex/state.py
chat_recap
async
¶
What was said in this chat room before the messages the turn must answer.
Only a kick in a dm or a group chat needs it: that runs in a thread of its own, so its model context starts empty every time and the agent would answer a chat it cannot see. A thread carries its own history in the conversation and gets none of this — its context is already the whole of the work.
The chat is the parent's, so the rows come from there; how many, and how much of each, is the channel's to say.
Source code in octomate/reflex/state.py
ReflexRuntime ¶
Stateless orchestration in graph deps; invocation resources stay with callers.
Source code in octomate/reflex/state.py
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 | |
resources
async
¶
resources(
ctx: GraphRunContext[ReflexState, ReflexDeps],
) -> tuple[
OctomateSession | None,
ReflexSuspender,
list[AgentCapability[None]],
]
Build fresh gateway, approval and tool context for the selected invocation.
Source code in octomate/reflex/state.py
prepare_user
async
¶
prepare_user(
ctx: GraphRunContext[ReflexState, ReflexDeps],
profile: UserProfile,
*,
session: OctomateSession | None,
suspender: ReflexSuspender,
capabilities: list[AgentCapability[None]],
) -> None
Mount capabilities belonging to the user authorized for this invocation.
Source code in octomate/reflex/state.py
send
async
¶
send(
ctx: GraphRunContext[ReflexState, ReflexDeps],
suspender: ReflexSuspender,
event: MessageSentEvent,
) -> bool
Deliver a gateway send to a person's direct messages, when possible: recorded there first, then published for that thread alone.
Source code in octomate/reflex/state.py
drive
async
¶
drive(
ctx: GraphRunContext[ReflexState, ReflexDeps],
suspender: ReflexSuspender,
source: AsyncGenerator[
ReactStreamEvent[ChannelOutput], None
],
) -> AgentRunResult[ChannelOutput]
Run the native invocation onto the nerve, closing it before recording its reply: the run's start before anything it streams, and its end after, carrying the reply's ledger row, whatever happened.
Source code in octomate/reflex/state.py
record_reply
async
¶
record_reply(
ctx: GraphRunContext[ReflexState, ReflexDeps],
suspender: ReflexSuspender,
result: AgentRunResult[ChannelOutput],
) -> ThreadMessage | None
Record and bind the run's reply, answering its row for the channel to mark with the platform id it renders the reply as.
Source code in octomate/reflex/state.py
present_command
async
¶
present_command(
ctx: GraphRunContext[ReflexState, ReflexDeps],
suspender: ReflexSuspender,
outcome: CommandOutcome,
) -> None
Publish direct feedback; its command receipt already owns the output.
Source code in octomate/reflex/state.py
finish
async
¶
finish(
ctx: GraphRunContext[ReflexState, ReflexDeps],
session: OctomateSession | None,
suspender: ReflexSuspender,
run_result: AgentRunResult[ChannelOutput],
) -> Summon | Teleport | Scheme | End[ReflexGraphResult]
Follow the gateway decision or deferral left by an actual agent run.
Source code in octomate/reflex/state.py
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 | |
octomate.reflex.suspender ¶
The reflex graph's deferred suspender: where a run's deferrals go — a teleport back to the graph, everything else to a human as a persisted batch.
TeleportRequest
dataclass
¶
A teleport for the graph to perform: carry the history and resume the agent
in the new place. One shape for every runtime — an Inkling run defers the
teleport call itself; a runtime a tool result cannot suspend is interrupted
on the recorded decision and ends its turn as the same deferral — read off
the deferred call by its metadata kind.
Source code in octomate/reflex/suspender.py
of
classmethod
¶
The teleport these requests carry.
Source code in octomate/reflex/suspender.py
ReflexSuspender
dataclass
¶
The reflex graph's DeferredSuspender: every deferral a run ends on comes
through here once, and each kind goes where it is resolved — a teleport to
the graph, which performs it and resumes the agent; anything else to a human,
persisted as a batch whose event rides the run's stream, for the channel to
present wherever it draws the run from. React builds it with the
run's context; Inkling reaches it through ResolveDeferred, a runtime a tool
result cannot suspend through the deferred_suspender its run was handed.
A runtime that asks a human mid-run pauses here instead, and stays live.
Source code in octomate/reflex/suspender.py
73 74 75 76 77 78 79 80 81 82 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 | |
suspended_batch_id
class-attribute
instance-attribute
¶
teleport
class-attribute
instance-attribute
¶
continuation_decision ¶
Preserve an actual agent run's selection for resume and teleport.
Source code in octomate/reflex/suspender.py
suspend
async
¶
Source code in octomate/reflex/suspender.py
pause
async
¶
Source code in octomate/reflex/suspender.py
persist
async
¶
persist(
requests: DeferredToolRequests,
*,
response_mode: DeferredResponseMode,
batch_id: UUID7 | None = None,
) -> DeferredActionBatch
Source code in octomate/reflex/suspender.py
octomate.reflex.crossing ¶
Create a channel-owned destination and announce the move at its origin.
open_crossing
async
¶
open_crossing(
ctx: GraphRunContext[ReflexState, ReflexDeps],
destination: ChannelAddress,
source_address: ChannelAddress,
hint_text: str,
agent_tentacle_id: str,
) -> ChannelAddress | None
Ask the destination channel to create an isolated thread.
The existing opener is recorded with its requesting user so the destination remains visible in their console. No fallback may reuse an existing chat.
Source code in octomate/reflex/crossing.py
announce_crossing
async
¶
announce_crossing(
ctx: GraphRunContext[ReflexState, ReflexDeps],
destination: ChannelAddress,
opened: ChannelAddress,
source_address: ChannelAddress,
hint_text: str,
agent_tentacle_id: str,
) -> None
Leave the move's line in the chat it left, and say where it landed.
Called once the history is carried: a fork shows the source's ledger as it stands, and the line is the source's own, not part of what moved.