Skip to content

Execution internals

Download this internals guide as Markdown

This is an implementation map, not a promise of a general graph compiler. The runtime currently has a narrow direct executor and an agent-backed executor; registration chooses only a validated supported plan. Follow the source links at the exact ownership boundary when debugging.

Version 0.15.0 supports a narrow, fully resolved required Exactly(1) acyclic graph with a Pydantic request/response, at least one FromRequest, supported request/result/authenticated-context/default inputs, a unique sink reached by every operation, and exactly one producer of the endpoint’s exact full response annotation. AgentChoice is excluded. Ready operations execute sequentially with declaration-order tie-breaking; after adds business ordering. This is not a public graph API, parallel scheduler, feedback, or general graph support. Existing chain, choice, repetition, and checkpoint behavior is unchanged. Published v0.14.0 is unchanged; milestone 4 is partial and milestone 3 remains partial. See example 20 and the contract.

One required typed operation may run a finite positive number of times (1 <= minimum <= maximum, maximum > 1) with a Pydantic request, at least one FromRequest, direct closed Literal[str] AgentChoice inputs, supported request/context bindings or immutable defaults, and exact full operation-output/endpoint-response annotation identity. Summonpot owns sequential decisions; business functions are not selector tools. It locally validates selections, shares one usage budget and deadline, resolves the model lazily, auto-finishes at maximum, and returns only the final successful canonical result; any failure aborts. Previous-result evidence is limited to 65,536 characters per decision, not an aggregate prompt budget. Explicit tool_calls_limit fails before provider/effects. No producer choices, FromResult, after, zero-minimum/unbounded bounds, implicit batch, or general graph. Existing Exactly(1) and producer-choice routes remain unchanged. Published v0.14.0 is untouched; milestone 3 remains partial and a narrow repeated-stage consumer is now documented below. Broader repeated-result addressing remains planned.

Version 0.15.0 repeated-stage final-result consumer

Section titled “Version 0.15.0 repeated-stage final-result consumer”

The original two-operation form lets one bounded repeated producer feed one required, choice-free terminal operation after the producer stage closes. The terminal uses FromResult(producer, field, invocation="final") to bind the final successful canonical result from one immutable closure record; meeting the minimum alone does not make it ready, and a failed or uncertain invocation aborts without earlier-result fallback. This two-operation shape is version 0.15.0, not published v0.14.0 behavior. It does not add aggregation, repeated consumers, inspect/correct/verify workflows, or general graphs. See the repeated-stage contract.

Version 0.15.0 single-stage sequential chains

Section titled “Version 0.15.0 single-stage sequential chains”

Version 0.15.0 supports a uniquely ordered chain with one nonterminal bounded repeated operation, an optional resolved prefix and a nonempty resolved suffix. Every other operation is required Exactly(1) with no agent choices. A Pydantic request needs at least one FromRequest across the whole chain, not necessarily on the repeated operation; supported request/result/authenticated-context bindings and immutable defaults remain required. The repeated operation has positive finite bounds (minimum >= 1, maximum > 1), direct closed plain-string Literal choices and a Pydantic intermediate distinct from the response. Ordinary FromResult reads single-invocation results; repeated results require invocation="final", with at least one suffix consumer. Exactly one terminal operation owns the endpoint’s exact full response annotation. Prefix operations run before one lazy model resolution; suffix operations run after immutable stage closure without further model decisions or acknowledgment. One principal, ledger, absolute deadline and usage budget span the request. Prefix results/context/ledger are not implicitly projected into model prompts; receiving constraints are checked before each start. Explicit function-tool quotas reject before all work. No feedback cycles, external choices, multiple repeated stages, aggregation, parallelism or durable recovery are added. Published behavior before v0.15.0 remains unchanged. See the single-stage chain contract.

Version 0.15.0 prefix selection before repetition

Section titled “Version 0.15.0 prefix selection before repetition”

Version 0.15.0 also composes exactly one producer-backed choice argument on one required Exactly(1) prefix consumer with one nonterminal bounded repeated stage and a resolved suffix. The candidate producer is an earlier single-start operation returning list[ConcreteModel]; repeated choices remain direct closed string Literal values, and all other operations remain resolved required Exactly(1). Pydantic request/response, chain-wide FromRequest, unique ordering, final-invocation addressing and exact terminal response ownership remain required. Empty/unavailable/oversized candidate domains stop before selection or repeated work; a singleton binds locally, while ambiguity uses canonical request-local tokens. Singleton selection still leads to model-backed repeated decisions. One lazy model-configuration lookup, run, principal, ledger, deadline and usage budget span both phases. No business-function tools, reselection after same-run failure, effect replay or final model acknowledgment are added. A fresh request starts a fresh run. Published behavior before v0.15.0 remains unchanged. See the composed selection/stage contract. See the canonical contract.

Version 0.15.0 framework-owned progression

Section titled “Version 0.15.0 framework-owned progression”

Version 0.15.0 supports one or more producer-backed choices with framework-owned progression. In an otherwise eligible uniquely ordered required Exactly(1) chain, a Pydantic request, at least one FromRequest, supported request/result/authenticated-context bindings or immutable defaults, and exact full terminal response annotation identity remain required. All current consumer domains are checked before selection or start. Singleton bindings resolve locally; a decision-only selector returns ambiguous tokens with no business-operation tools. The shared kernel validates and invokes the operation, then continues locally until another genuine decision is needed. The canonical terminal result returns without a final model acknowledgment. Request/principal, reservations, token domains, usage budgets and one deadline remain request-local across frontiers and corrections. Explicit tool_calls_limit retains the previous one-way agent suffix; allow_direct=False and other noneligible declarations retain their existing route. Limits remain 128 candidates and 65,536 evidence characters per binding, not an aggregate prompt/context budget. Prefix effects may precede provider-configuration failure; no rollback, effect replay or durable resume is added. Historical v0.14.0 remains exactly-one-choice. See the operation reference for details.

Version 0.15.0 bounded checkpoint progression

Section titled “Version 0.15.0 bounded checkpoint progression”

Version 0.15.0 admits one explicit Required(check, calls=Between(1, M), until="accepted") with finite M >= 2. Its marker must name a stored, non-null strict Boolean field in the validated Pydantic output; until=None retains ordinary semantics. The uniquely ordered required region uses bounds 1..M; a nonempty uniquely ordered optional negative continuation uses 0..M-1. Exactly one Required(..., calls=Exactly(1)) terminal returns the exact full endpoint response and reads only final checkpoint fields. Unsupported marked shapes reject at registration. True closes; false continues, while the Mth false closes unresolved without another continuation. Empty choice domains abort with the existing redacted 409, not an unresolved result. Only one frame operation is in flight; continuation admission atomically retires that round’s authority, so closure cannot race it. Invocations use the existing shared kernel. Request, principal, ledger, usage budget and deadline are shared across rounds. No rollback, replay, durable resume or recovery is provided; effects may remain after later failure. Published behavior before v0.15.0 remains unchanged. See the source contract and examples 18–19.

The overview diagram introduces the shared endpoint paths. This focused producer-choice view follows it rather than replacing the framework map.

One Summonpot application branches into the shipped single-operation direct slice or the agent-backed endpoint through the same typed HTTP and OpenAPI framework.
Framework overview; the direct path is limited to its documented eligibility predicate. Open full size.

The runnable producer-choice inventory example shows the narrower runtime/application boundary. The model sees bounded inert candidate evidence and opaque tokens, never canonical objects. Summonpot verifies request-local token membership and binds the exact validated candidate. The application operation checks live stock and revision, then owns the SQLite transaction, order persistence, and idempotency. Local validation returns the canonical terminal receipt. This producer-choice chain remains agent-mediated.

Four-step validated producer choice: the application returns bounded in-stock candidate records; Summonpot shows inert descriptions and opaque tokens to the model; the agent selects a token that Summonpot verifies and binds to the exact canonical candidate; the application operation checks stock and revision in SQLite, commits an order and returns its locally validated receipt. The model does not receive canonical objects. The chain remains agent-mediated; application code owns transactions and idempotency.
Summonpot validates candidate evidence and token binding; application code owns stock checks, the transaction, and idempotency. Open full size.

Accessible equivalent: the producer yields validated inventory snapshots; the model selects only from projected descriptions using opaque tokens. The runtime verifies token membership and binds the exact canonical candidate. The application operation checks stock and revision before its transaction and idempotency logic writes the order; local validation returns its canonical receipt.

  1. Summon.__call__ in summon.py captures path, HTTP method, goal/docstring, request parameters, and output annotation. It rejects direct decorated-function calls and validates explicit declarations during registration.
  2. Contract types in contracts.py describe Operation, input bindings, and CallBounds. Depends / Required in dependencies.py attach optional/mandatory semantics and combine markers with bounds.
  3. _execution.py compiles the endpoint to an internal plan. It resolves signatures and annotations, binding compatibility, output validators, operation identities, and the precise direct-eligibility predicate. Explicit unsupported graphs are rejected rather than silently widened.
  4. The compiled plan is registered with the endpoint. The runtime consults that plan; mutable public metadata is not a substitute for a validated contract.

server.py constructs FastAPI routes from registered endpoint definitions and creates a body model for request-model endpoints. Body-bearing POST/PUT/PATCH receive JSON; GET/DELETE/HEAD declarations use query parameters. FastAPI validates the transport input before _run_endpoint invokes Runtime.call.

Runtime.call in runtime.py prepares the request once and creates per-request operation state. For direct-eligible contracts, it invokes the compiled operation without model_for, agent construction, or provider access. It does not fall back to an agent if that call fails.

For agent-backed contracts, the runtime resolves endpoint model override or SUMMONPOT_MODEL (default openai:gpt-4o-mini), creates/caches the provider-neutral Pydantic AI agent for the compiled plan/model, and executes with per-run dependency state. A bound operation’s model-visible signature includes explicit choices while trusted request values and application-owned defaults are supplied by runtime.

For the enforced bound slice, FromRequest values are fetched from the validated request and checked against their receiving parameter contract without coercion. The runtime reserves the bounded start under per-request state before invoking application code. Sync callables run via asyncio.to_thread; async callables are awaited. The operation’s output validator checks the returned object; only a valid result increments success state. An invalid result does not satisfy Required and is not automatically retried.

Agent-backed final output is parsed/validated against the endpoint response schema and audited before returning. This checks model shape and configured validation invariants; it cannot prove natural-language claims are causally grounded in an operation result. The direct path returns its validated operation result according to the exact direct predicate.

Runtime(model=None, retries=1, usage_limits=None, timeout=None) accepts a model string or Pydantic AI Model; None defers to SUMMONPOT_MODEL at call time and then the default openai:gpt-4o-mini. Endpoint model overrides are resolved from the registered plan. Provider credentials and optional provider integrations follow Pydantic AI conventions and package extras; they are not needed for the direct slice. SUMMONPOT_MODEL=test selects the keyless test model for agent-backed testing. It is not a sandbox: operation code executes with placeholder model arguments.

retries bounds model retry behavior, usage_limits is passed into the agent run, and timeout wraps either executor path. These settings do not undo side effects that occurred before an exception or timeout. Consult Runtime for current argument validation and model resolution.

_run_endpoint keeps internal provider and capability details in logs, returning fixed public messages. Current mappings include invalid injected values → 422, usage limit exceeded → 429, timeout → 504, upstream provider throttling → 429, other provider HTTP error → 502, and operator/model configuration failures → fixed server error. Do not infer undocumented transport status for arbitrary application exceptions; inspect current server code and tests.

  • Request schema validation is not authentication; application operations must check authorization.
  • Closed declared callables constrain available authority, but each callable’s real implementation and side effects remain application-owned.
  • Required-use state is runtime enforced; a prompt is not enforcement.
  • Output validation proves contract conformance, not semantic correctness or provenance.
  • A permitted start is not successful completion, transaction rollback, distributed idempotency, or exactly-once execution.
  • Test-model execution can invoke real capability code.

From 0.12.0, model-free execution also traverses the compiled order of a uniquely ready chain of two or more required Exactly(1) operations. Eligibility requires a Pydantic request, at least one FromRequest binding, only FromRequest/FromResult bindings or supported immutable defaults, and the terminal operation’s exact full endpoint response annotation. The shared invocation kernel enforces readiness, after, receiving constraints, validated results, and reserved starts. The canonical terminal result is returned without model construction or fallback. An AgentChoice normally keeps the chain agent-mediated; a result-dependent source exception included from version 0.14.0 is documented in the operation reference. Historical published boundaries remain unchanged.

For source-level value-transfer/security details, read docs/declarative-capabilities.md. Authenticated FromContext is included from version 0.13.0 in a narrow source slice; broader graphs and bounds remain planned.