symfonic.agent.backend.plan¶
plan ¶
Compiling one Agent call into an InvocationPlan.
This is the facade's side of the compile seam: it constructs the live port
objects (a chat model, a tool executor, a response adapter) and hands them to
the one compiler in symfonic.kernel. Constructing bindings here rather than
inside the compiler is what keeps IPL-8 true — the compiler stays a pure
function of values, and everything that has to build something happens on the
composition side of the line.
Every ConfigurationError the facade raises is raised here, before the first
inference call (FERR-3). Discovering that a provider cannot do structured
output after spending tokens is the failure mode RES-9 exists to prevent.
AgentPlanFactory
dataclass
¶
AgentPlanFactory(model_provider: Any, instructions: str | None, tools: NormalizedTools, max_model_rounds: int = MAX_TOOL_ITERATIONS, model: ModelConfig | None = None, role_models: Mapping[str, ModelConfig] = dict(), stages: tuple[Any, ...] = (), stage_handlers: Mapping[str, Any] = dict(), tool_preconditions: tuple[Any, ...] = (), authorized_effects: frozenset[str] = frozenset({'model_call'}), capability_names: tuple[str, ...] = ())
Turns the facade's four construction inputs into a compiled plan.
compile ¶
compile(output_type: type[BaseModel] | None, *, sink_factory: Callable[[ModelResolution], Any] | None = None) -> InvocationPlan
Validate eagerly, bind the ports, and compile exactly one plan.
sink_factory is the seam ServiceBindings.event_sink reserved.
It is called at most once, here, with the ModelResolution this plan
was compiled with, and whatever it returns is bound as the sink;
None — the simple facade's answer, which has no callback input —
leaves the binding unset, and InvocationRunner then constructs no
CallbackEventAdapter at all.
A factory rather than a sink because the two things a sink needs are produced on opposite sides of this call: the caller owns the run's identity (its id, its session, its tenant) and this method owns the model that identity has to name. Handing the resolution out rather than making the caller re-derive it keeps one answer to "which model ran?" — the caller's copy cannot drift from the plan's, because it is the plan's.
Binding it here rather than on the caller's side is also what makes the
sink's reference frozen at compile time along with every other port
(IPL-4). equality_key excludes bindings, so a bound sink changes
neither the config digest nor plan identity (IPL-7): two runs of the
same agent still compile the same plan shape with different sinks.
Source code in src/symfonic/agent/backend/plan.py
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 | |