Skip to content

Build a model-free endpoint

Download this guide as Markdown

This guide builds an endpoint whose fully resolved operation runs without looking up a model. This is a deliberately narrow shipped path—not a general deterministic workflow compiler. Requirements and registration-time rejections are specified in the operation reference.

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.

For a focused current-checkout lesson beyond this published-compatible walkthrough, see example 22. It keeps the callable’s immutable discount default application-owned, checks stricter annotated receiving constraints before the operation starts, and preserves the full annotated response contract. The normal path performs real integer arithmetic without resolving a model. Output inference in that lesson is included from version 0.15.0; it does not change the historical version boundary of the explicit declaration below.

Use Python 3.11–3.14 and install the HTTP extra: python -m pip install 'summonpot[serve]'. This example performs arithmetic only; no provider credentials or network model calls are involved. The summonpot CLI requires the optional cli extra, but this example starts the server through its public Python API.

Save the complete program below as direct_quote.py:

from decimal import Decimal, ROUND_HALF_UP
from pydantic import BaseModel, Field
from summonpot import Exactly, FromRequest, Operation, Required, Summon
class QuoteRequest(BaseModel):
unit_price_cents: int = Field(gt=0)
quantity: int = Field(ge=1, le=100)
tax_rate_percent: Decimal = Field(ge=0, le=30)
class QuoteResponse(BaseModel):
subtotal_cents: int
tax_cents: int
total_cents: int
def calculate_quote(
unit_price_cents: int,
quantity: int,
tax_rate_percent: Decimal,
) -> QuoteResponse:
"""Calculate the approved quote using decimal half-up tax rounding."""
subtotal = unit_price_cents * quantity
tax = (Decimal(subtotal) * tax_rate_percent / Decimal(100)).quantize(
Decimal("1"), rounding=ROUND_HALF_UP
)
return QuoteResponse(
subtotal_cents=subtotal,
tax_cents=int(tax),
total_cents=subtotal + int(tax),
)
quote_operation = Operation(
calculate_quote,
bind={
"unit_price_cents": FromRequest("unit_price_cents"),
"quantity": FromRequest("quantity"),
"tax_rate_percent": FromRequest("tax_rate_percent"),
},
output=QuoteResponse,
)
summon = Summon("direct-quote-service")
@summon("/quotes/direct")
def create_quote(
request: QuoteRequest,
quote=Required(quote_operation, calls=Exactly(1)),
) -> QuoteResponse:
"""Return the exact approved quote through its one complete operation path."""
...
if __name__ == "__main__":
summon.serve(host="127.0.0.1", port=8000)

The endpoint declaration is intentionally an ellipsis. It is not a handler body: the registered function is a contract, direct Python invocation is rejected, and the generated HTTP route invokes the runtime. request defines and validates the JSON body; the docstring is the fixed goal; Required(..., calls=Exactly(1)) declares the sole mandatory operation and bound; and the response annotation is the endpoint output schema.

Operation wraps the exact application callable. Each parameter is explicitly bound from the validated request, and output=QuoteResponse asks the runtime to validate the callable’s result. The callable remains application authority; the framework does not replace its implementation or infer authorization. Put authorization and any write policy inside the application operation.

Start the server in one terminal:

Terminal window
python direct_quote.py

In another terminal, submit a harmless request:

Terminal window
curl -i -X POST http://127.0.0.1:8000/quotes/direct \
-H 'Content-Type: application/json' \
-d '{"unit_price_cents":1299,"quantity":3,"tax_rate_percent":"8.25"}'

The response body is {"subtotal_cents":3897,"tax_cents":322,"total_cents":4219}. The operation computes it; no model is resolved or called. This path requires a Pydantic request model, exactly one required Exactly(1) operation, at least one FromRequest binding (this example binds all three inputs), only FromRequest or supported immutable callable defaults for remaining parameters, and an operation output that is the identical response-model class declared by the endpoint. A declaration outside that full predicate is not eligible for direct execution.

Check rejection before application code with invalid quantity:

Terminal window
curl -i -X POST http://127.0.0.1:8000/quotes/direct \
-H 'Content-Type: application/json' \
-d '{"unit_price_cents":1299,"quantity":0,"tax_rate_percent":"8.25"}'

Pydantic rejects the request with HTTP 422. The operation is not invoked for invalid input. The route also publishes its request and response contract in OpenAPI at /openapi.json; the interactive schema is at /docs.

The runtime reserves the permitted operation start before invoking application code. An operation that returns an invalid declared output does not satisfy Required, and it is not automatically retried. This is a per-request start bound, not exactly-once completion, rollback, distributed deduplication, or cancellation: application code may have side effects before it raises or before output validation fails. Use idempotency and transaction policy in the application where required.

FromRequest supplies the canonical value from the validated request and checks it against the receiving parameter contract without coercion. Validation does not establish user identity or authorization. Keep sensitive access checks in the operation and do not bind an untrusted identifier as proof of permission.

  • Operation(fn) without complete bindings is explicit but not an eligible direct operation; registration rejects unsupported explicit shapes.
  • A scalar endpoint request, no request-bound argument, multiple operations, optional Depends, or a direct AgentChoice is not this no-model shape.
  • The output must match by class identity, not merely equivalent fields.
  • Mutable/custom callable defaults do not qualify. Supported immutable exact built-ins are None, bool, int, float, complex, str, bytes, and recursively composed tuples/frozensets of those exact values.
  • Bare legacy Depends(fn) / Required(fn) callables keep their agent-backed behavior; their presence does not prove deterministic direct execution.

From 0.12.0, model-free execution also supports uniquely ordered chains of two or more required Exactly(1) operations with a Pydantic request, at least one FromRequest binding, only FromRequest/FromResult sources or supported immutable defaults, and a terminal operation declaring the endpoint’s exact full response annotation. FromResult transfers locally validated results; after enforces independent success ordering. The canonical terminal result is returned. An AgentChoice normally remains agent-mediated; the result-dependent source exception included from version 0.14.0 is documented in the operation reference. Published 0.13.0 behavior remains unchanged. See the three-step SQLite example.

For a semantic choice, see Build an agent-backed bound operation. For runtime mechanics and error handling, see Execution internals. Authenticated FromContext is included from version 0.13.0 in a narrow source slice; broader graphs and bounds remain planned.