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 src/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 src/symfonic/core/runtime.py
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 | |
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 src/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().