symfonic.core.runtime¶
runtime ¶
AgentRuntime -- graph execution for a single agent invocation.
Per ADR-PFX-008 and TDD SS2.9: Eager compile in init, run() for execution, stream() for streaming. Callbacks dispatched via CallbackManager.
AgentRuntime ¶
AgentRuntime(graph: AgentGraph, deps: BaseAgentDeps, config: AgentConfig | None = None, timeout_seconds: float | None = None, checkpointer: Any | None = None)
Execute a compiled graph for a single agent invocation.
Eagerly compiles the graph in init -- raises immediately on misconfiguration (missing capabilities, invalid preset, etc.).
Source code in symfonic/core/runtime.py
run
async
¶
run(query: str, *, callbacks: Sequence[CallbackHandler] | None = None, **state_overrides: Any) -> dict[str, Any]
Execute the graph and return final state dict with final_response.
v7.18.0 (Option B emission-ordering): the caller may pass
_suppress_agent_end=True in state_overrides to disable
the success-path on_agent_end dispatch in this method. The
engine layer (SymfonicAgent.run) sets this flag so it can
emit on_response_render AFTER the full transformation chain
(synthesize-on-empty-final salvage -> fabrication -> metacog ->
extraction-stripping) and THEN emit on_agent_end with the
rewritten content. Composability rule (locked):
- salvage -> fabrication -> metacog -> extraction-stripping -> on_response_render -> on_agent_end.
- The rewriter runs at most ONCE per turn.
The error-path on_agent_end STILL fires from runtime --
engine cannot intercept the BaseException, and adopters relying
on a forced-failure terminator event must still receive it.
_suppress_agent_end is a runtime-internal flag and is NOT
part of the public state_overrides surface; adopter code
that passes arbitrary keys to runtime.run() ignores it
per the legacy default-False contract.
Source code in symfonic/core/runtime.py
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 | |
stream
async
¶
stream(query: str, *, callbacks: Sequence[CallbackHandler] | None = None, **state_overrides: Any) -> AsyncGenerator[Any, None]
Yields stream events. Emits AgentStartEvent/AgentEndEvent via callbacks.
Source code in symfonic/core/runtime.py
stream_events
async
¶
stream_events(query: str, *, callbacks: Sequence[CallbackHandler] | None = None, **state_overrides: Any) -> AsyncGenerator[StreamEvent, None]
Yield typed StreamEvent objects from astream_events(v2).
Calls _workflow.astream_events and pipes each raw LangGraph
event through EventTranspiler, yielding typed StreamEvent
objects (TextDeltaEvent, ToolCallStartEvent, ThinkingDeltaEvent,
etc.). AgentStartEvent / AgentEndEvent are dispatched via the
callback manager as in stream().
Source code in symfonic/core/runtime.py
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 | |