Project README
Generated from README.md, a repository documentation snapshot at commit a38c3096060243d55a258349196381c89b784545. Roadmap items are planned work, not claims of shipped features.
summonpot
Section titled “summonpot”
Part of ModePot. Project website Created by Tugrul Guner
Define the endpoint. Summonpot owns the orchestration.
Declare the request, fixed goal, exact application-owned operations, and response. Summonpot orchestrates those operations; the agent chooses only where the contract leaves a bounded choice.
Quick start · Playground · Deep docs · Documentation · README quick start · Why summonpot · Capabilities · How it works · Examples · Community · Contributing
Validated producer-choice chain
Section titled “Validated producer-choice chain”The overview above remains the framework map. This supporting diagram traces the runnable producer-choice inventory example: bounded candidate evidence reaches the model with opaque tokens, Summonpot verifies token membership and binds the exact canonical candidate, and the application-owned operation checks live stock and revision before committing its typed receipt. This producer-choice chain remains agent-mediated; the application owns transactions and idempotency.
Summonpot modernizes APIs for AI without replacing the endpoint with a separate agent layer. The endpoint remains the stable public abstraction while its contract combines exact application behavior with explicitly bounded agentic decisions.
The ellipsis is declaration syntax, not an unfinished implementation. The signature,
docstring, operations, argument bindings, and return type are the executable contract.
Depends(...) and Required(...) attach deterministic application code. AgentChoice()
marks the exact arguments where the agent may decide. Deterministic and agentic endpoints
use the same declaration style, request/response validation, routing, and OpenAPI instead of
separate API and agent frameworks. Summonpot owns the bounded agent loop, operation
enforcement, and structured output. Calling a registered declaration directly raises a
clear error; serve the application or invoke its generated HTTP route instead.
[!IMPORTANT] The supported single-operation
Exactly(1)path executes without resolving or constructing a model. From version 0.12.0, uniquely ordered requiredExactly(1)chains of at least two operations run model-free with a Pydantic request, at least oneFromRequestbinding, supported immutable defaults or request/result/authenticated-context bindings, and a terminal operation declaring the endpoint’s exact full response annotation. Bare legacy capabilities remain agent-mediated; unsupported explicit contract shapes fail at registration. Broader graphs remain on the roadmap, not shipped behavior.The narrow result-dependent route is included from version 0.14.0 for exactly one producer-backed choice in an otherwise eligible chain. A singleton completes locally; multiple candidates trigger lazy model resolution after the prefix and retain the agent-mediated suffix. Historical v0.13.0 behavior remains agent-mediated for all producer-backed choices.
Version 0.15.0 supports one or more producer-backed choice bindings with framework-owned progression under the same Pydantic-request, request-binding, unique-order, required
Exactly(1), immutable-source and exact-full-terminal predicates. Check every current consumer domain before selection or start. Singleton inputs bind locally; a private selector returns only ambiguous tokens and exposes no business-operation tools. The guarded kernel invokes the consumer and advances locally to the next decision. The canonical terminal result returns without a final model acknowledgment. Shared request/principal, reservations, usage budgets and one deadline persist; no effect replay or durable resume is added. Limits remain 128 candidates and 65,536 evidence characters per binding, not an aggregate context budget. Prefix effects may precede provider-configuration failure; no rollback is implied. Explicittool_calls_limitretains the previous one-way agent suffix;allow_direct=Falseand noneligible declarations retain their existing route. Historical v0.14.0 remains exactly-one-choice. Milestone 3 remains partial.
Version 0.15.0 supports bounded repeated calls for one required typed operation with finite bounds (
minimum >= 1,maximum > 1), a Pydantic request with at least oneFromRequest, closed directLiteral[str]choices, supported request/context bindings or immutable defaults, and exact full operation-output/endpoint-response annotation identity. Summonpot owns sequential decisions and returns the final successful canonical invocation result; failures abort. Explicittool_calls_limitfails before provider/effects. Published behavior before v0.15.0 remains unchanged. See the bounded repeated-call contract.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 oneFromRequestacross 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-stringLiteralchoices and a Pydantic intermediate distinct from the response. OrdinaryFromResultreads single-invocation results; repeated results requireinvocation="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 and original final-result binding.
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 returninglist[ConcreteModel]; repeated choices remain direct closed stringLiteralvalues, and all other operations remain resolved requiredExactly(1). Pydantic request/response, chain-wideFromRequest, 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.
Version 0.15.0 branch/join execution
Section titled “Version 0.15.0 branch/join execution”Version 0.15.0 adds one narrow model-free branch/join form. A supported Pydantic request/response declaration must contain at least one FromRequest and a fully resolved required Exactly(1) acyclic operation graph: request, result, authenticated-context, or supported immutable-default inputs; a unique sink reached by every operation; and one exact full-response producer. Ready operations run sequentially, with declaration order breaking ties. after adds business ordering but does not widen the graph contract. This is not a public graph API, parallel scheduler, feedback, or choice support; existing chain, choice, repetition, and checkpoint paths are unchanged. Published v0.14.0 is unchanged; milestone 4 is partial, and milestone 3 remains partial. See the branch/join contract and example 20.
Unreleased source: one producer-backed choice in required DAGs
Section titled “Unreleased source: one producer-backed choice in required DAGs”The current source adds one narrow exception to version 0.15.0’s fully resolved branch/join form; this is unreleased and is not part of published summonpot 0.15.0. Historical version 0.15.0 branch/join execution remains choice-free. A supported Pydantic request/response must have at least one FromRequest; all operations are required Exactly(1) in an acyclic graph with one sink reached by every operation and exactly one producer of the endpoint’s exact full response annotation. Exactly one argument globally may use producer-backed AgentChoice(from_result=...), from its exact declared producer Operation returning list[ConcreteModel]; every other input uses existing supported bindings or immutable defaults. The agent chooses only that argument value; it does not choose which branch runs.
Operations execute sequentially in stable declaration-priority order among ready nodes in this acyclic graph with a unique sink. The choice producer is a readiness dependency, but there is no global choice barrier: an independent earlier branch may already have effects if an empty/unavailable/oversized domain fails with the existing redacted 409 before consumer/model work. after still expresses business ordering. A singleton binds the canonical member with no model lookup or call; ambiguous choices expose only bounded inert candidate evidence and opaque tokens to a private selector with no business tools. The shared kernel validates the selection and invokes the consumer; no extra context/results are disclosed and no final model acknowledgment is requested. The sink returns its audited canonical result.
Explicit function-tool quota (UsageLimits.tool_calls_limit) and private allow_direct=False reject this new graph shape before effects; existing linear-chain compatibility, including its multiple-choice behavior, is unchanged. Historical version 0.15.0 branch/join execution remains choice-free, and its zero-choice behavior is preserved. This is not a public graph API, parallel scheduler, repeat/feedback workflow, durable recovery, or general graph compiler. Milestones 3 and 4 remain partial. See example 23, to be added with this source feature.
Version 0.15.0 bounded checkpoint progression
Section titled “Version 0.15.0 bounded checkpoint progression”Version 0.15.0 supports one explicit Required(check, calls=Between(1, M), until="accepted") marker, with finite M >= 2. The marker must name a stored, non-null strict Boolean field in the checkpoint’s validated Pydantic output; aliases, computed properties, expressions and coercive Boolean fields do not qualify. until=None keeps ordinary Required behavior. A uniquely ordered required region ends at the checkpoint, with effective bounds 1..M; a nonempty uniquely ordered optional negative continuation has bounds 0..M-1. Exactly one Required(..., calls=Exactly(1)) terminal returns the endpoint’s exact full response annotation and reads only fields from the final checkpoint invocation. Invalid marked shapes fail registration, never fall back to the legacy route.
True closes to terminal. False runs the declared continuation, then rechecks; the Mth false closes unresolved to terminal without another continuation. The application owns the truth of the check, candidate permissions and truthful report. An empty choice domain fails closed with the existing redacted 409; it is not an unresolved report. Only one frame operation is in flight. Continuation admission retires that round’s authority atomically, so closure cannot race it; only a fresh checkpoint after continuation can close. Every invocation uses the existing shared kernel. The shared request, authenticated principal, invocation ledger, usage budget and absolute deadline span all rounds. There is no rollback, effect replay, durable resume or recovery: a prior write/report may remain after later failure, and a fresh request is not safe recovery. Checkpoint progression is included from version 0.15.0; it was not part of version 0.14.0. See examples 18 and 19 and the complete contract.
Why summonpot?
Section titled “Why summonpot?”A conventional API puts deterministic work in a handler. An agent-first stack starts from an agent workflow and then wraps it in HTTP. Summonpot declares both through the same contract-first framework, so applications keep one public API as the balance changes between exact operations and semantic decisions:
The following conceptual declaration omits the application-specific models and service implementation; the quick start is the standalone example.
from typing import Literal
from summonpot import AgentChoice, Exactly, FromRequest, Operation, Required, Summon
summon = Summon("research-api")
def build_deterministic_report(topic: str) -> ResearchResponse: """Run the application's fully resolved research operation.""" return research_service.build_response(topic=topic, format="detailed")
deterministic_report_operation = Operation( build_deterministic_report, bind={"topic": FromRequest("topic")}, output=ResearchResponse,)
def build_agentic_report( topic: str, format: Literal["summary", "detailed"],) -> ResearchReport: """Run the exact operation with one declared semantic choice.""" return research_service.build(topic=topic, format=format)
agentic_report_operation = Operation( build_agentic_report, bind={ "topic": FromRequest("topic"), "format": AgentChoice(), }, output=ResearchReport,)
@summon("/reports/deterministic")def deterministic_report( request: ResearchRequest, report=Required(deterministic_report_operation, calls=Exactly(1)),) -> ResearchResponse: """Return the detailed report through a fully resolved operation path.""" ...
@summon("/reports/agentic")def agentic_report( request: ResearchRequest, report=Required(agentic_report_operation, calls=Exactly(1)),) -> ResearchResponse: """Choose the report format and return the sourced report.""" ...Those declarations answer the questions an API framework needs to answer:
| Question | Declared by |
|---|---|
| What may the caller send? | ResearchRequest |
| What must the endpoint achieve? | The docstring |
| What application authority may execution use? | Depends(...) and Required(...) |
| Which inputs must come from trusted application data? | FromRequest(...) and other bindings |
| Where may the agent make a semantic choice? | Explicit AgentChoice(...) bindings |
| What may the endpoint return? | ResearchResponse |
| Where is orchestration code? | Owned by summonpot |
The request carries business data only. The endpoint goal is fixed in code. Exact
operations remain application-owned, while the agent can choose only within the authority
declared for that endpoint. A response is not accepted until every Required(...)
operation has completed successfully.
| Conventional APIs | Agent-first stacks | summonpot | |
|---|---|---|---|
| Mental model | Write a handler | Configure an agent | Declare one endpoint |
| Deterministic work | Handler code | Usually exposed as tools | Exact application-owned operations |
| Agentic decisions | Separate agent workflow | Primary abstraction | Explicit choices in the same declaration |
| HTTP | Built around the handler | Added around the agent | Generated from the declaration |
| Application authority | Held by handler code | Often assembled separately | Closed by the endpoint contract |
| Final output | Handler convention | Provider or framework convention | Locally validated response model |
One declaration style, both endpoint flows
Section titled “One declaration style, both endpoint flows”/reports/deterministic binds every operation argument to validated application data; its
operation output is exactly the endpoint response model, so the fully resolved endpoint
executes once without constructing a model. /reports/agentic uses the same declaration
style but adds one explicit AgentChoice(). The endpoint with AgentChoice() still uses
the agent runtime. Both keep typed request/response contracts, operation enforcement,
routing, and OpenAPI under Summonpot.
What ships today
Section titled “What ships today”- One declaration style for deterministic operations and agentic decisions, sharing the same request, response, route, validation, and OpenAPI contract.
- Contract-first endpoints with a required goal and typed request/response contracts.
- Closed capability sets made from exact application-owned callables.
- Optional and mandatory operations through
Depends(...)andRequired(...). - Runtime-enforced required use, tracked per request rather than trusted to a prompt.
- Per-request operation-start enforcement for the first complete runtime slice: trusted
FromRequestvalues and callable defaults are removed from the operation tool schema, directAgentChoicearguments remain visible, one permitted start per request is reserved before application code, andoutput=is locally validated before success. This is not a distributed exactly-once completion guarantee. - Single-operation deterministic execution when one required
Exactly(1)operation uses a Pydantic request model and has at least oneFromRequestbinding; every remaining argument comes fromFromRequestor an immutable identity-stable callable default, and its output is exactly the endpoint response model. This path does not resolve, construct, or call a model. - Sequential required-operation chains with
Exactly(1)bounds and unique readiness, bound by validatedFromRequest/FromResultvalues and supported immutable defaults. Included from version 0.12.0, eligible fully resolved chains execute without model resolution. Included from version 0.14.0, the exactly-one-choice optimization handles a singleton locally and hands off for multiple candidates. Version 0.15.0 supports one or more producer-backed choices with framework-owned progression. In an otherwise eligible uniquely ordered requiredExactly(1)chain, a Pydantic request, at least oneFromRequest, 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. Explicittool_calls_limitretains the previous one-way agent suffix;allow_direct=Falseand 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. - Registration-time contract validation that rejects missing sources, invalid result references, unsupported choices, and provably incompatible types before serving.
- Provider-neutral model selection for OpenAI, Anthropic, Google, Groq, Mistral, OpenRouter, and xAI.
- Generated HTTP and OpenAPI contracts for body and query endpoints.
- Stable OpenAPI
operationIdvalues derived from each endpoint’s declared name and HTTP method, with registration-time rejection when two routes would produce the same ID. - GET, POST, PUT, PATCH, DELETE, and HEAD routes, keyed by
(path, method). - Local response validation, bounded retries, usage limits, timeouts, and redacted public failures.
- A keyless test model for exercising routes and schemas before adding provider credentials.
- Coding-agent skills for Claude Code, Cursor, Windsurf, GitHub Copilot, Cline, and OpenAI Codex, including typed operation bindings and their current runtime boundary.
Quick start
Section titled “Quick start”1. Install
Section titled “1. Install”pip install "summonpot[serve,cli]"Python 3.11 through 3.14 is supported. Summonpot requires Pydantic
>=2.13.5,<2.14 and pydantic-core >=2.46.5,<2.47. Earlier Pydantic versions
are no longer supported. Output
revalidation uses a version-sensitive core option to avoid reusing validators that
trust existing model instances; the dependency bounds keep that integration on the
tested minor versions.
Start without a provider account by selecting the built-in test model:
export SUMMONPOT_MODEL=testThe test model is keyless, not side-effect-free. An endpoint with capabilities may call them using generated placeholder arguments. Use harmless capabilities when testing wiring; do not attach destructive operations or treat the model as a dry-run sandbox.
2. Declare an endpoint
Section titled “2. Declare an endpoint”Create app.py:
from typing import Literal
from pydantic import BaseModel, Fieldfrom summonpot import Summon
class ReviewRequest(BaseModel): text: str = Field(min_length=1, max_length=2_000)
class ReviewResponse(BaseModel): sentiment: Literal["positive", "negative", "neutral"] summary: str
summon = Summon("review-api")
@summon("/review")def review(request: ReviewRequest) -> ReviewResponse: """Classify the text's sentiment and summarize it in one short sentence.""" ...The ellipsis marks a complete endpoint declaration. Summonpot never calls that body, and direct Python calls are rejected at the decorator boundary.
3. Serve it
Section titled “3. Serve it”summonpot serve app.py --host 127.0.0.1 --port 8000Open the generated API documentation at
http://127.0.0.1:8000/docs, or call the endpoint directly:
curl -X POST http://127.0.0.1:8000/review \ -H 'Content-Type: application/json' \ -d '{"text":"The endpoint contract is surprisingly small."}'The test model returns schema-valid placeholder data. To receive a real agent-generated answer, install a provider extra and select a provider-qualified model:
pip install "summonpot[serve,cli,anthropic]"export SUMMONPOT_MODEL=anthropic:claude-sonnet-4-5export ANTHROPIC_API_KEY='<your key>'The endpoint code and HTTP contract do not change when the provider changes.
Exact capabilities, not ambient authority
Section titled “Exact capabilities, not ambient authority”A capability is ordinary application code. It runs for real; summonpot never replaces its implementation.
def calculate_quote( unit_price_cents: int, quantity: int, tax_rate_percent: str,) -> dict[str, int]: """Calculate an exact quote using the service's approved pricing rules.""" return pricing_service.calculate( unit_price_cents=unit_price_cents, quantity=quantity, tax_rate_percent=tax_rate_percent, )Attach it to one endpoint, continuing from the application and models defined above:
from summonpot import Required
@summon("/quotes")def create_quote( request: QuoteRequest, calculation=Required(calculate_quote),) -> QuoteResponse: """Calculate and return the exact approved quote.""" ...| Declaration | Runtime contract |
|---|---|
Depends(operation) |
The operation is available to the endpoint and may be called. |
Required(operation) |
Final output is rejected until the operation succeeds. |
For bare callables, Required(...) proves only that the operation returned successfully at
least once during that request. The narrow bound form
shown below additionally enforces trusted request injection, local operation-output
validation, and Exactly(1). Ordering, idempotency, and provenance-backed final claims
remain separate concerns.
Capabilities do not become request-body fields or OpenAPI parameters. Their docstrings and annotations define the tool schema visible to the agent, while their implementations define the real application behavior.
The capability set is closed. For one required typed operation with explicit Exactly(1), the
runtime injects FromRequest values, removes them and callable defaults from any
model-visible tool schema, validates the declared operation output, and rejects a second
start. If the endpoint uses a Pydantic request model, has at least one FromRequest
binding, resolves remaining inputs from FromRequest, authenticated FromContext (from
0.13.0), or supported immutable callable defaults, and that output
is exactly the endpoint response model,
Summonpot executes the operation directly. Otherwise direct AgentChoice arguments remain
visible to the agent. Request values on agentic paths still appear in the agent’s user
message; tool-schema hiding is not prompt secrecy. Unsupported explicit operation shapes are
rejected before serving until their execution semantics ship. Bare Depends(fn) and
Required(fn) declarations with implicit marker bounds keep their legacy agent behavior.
Before either supported path invokes the capability, each injected FromRequest value is
checked strictly against its receiving operation parameter, including Annotated
constraints. A broader request contract therefore does not authorize a narrower operation
parameter. The check runs strictly before application code starts and rejects coercion: a
valid canonical validated request value is passed through unchanged, not replaced by a
coerced value. It does not rerun request-model validators.
The supported receiver vocabulary is exact primitive types with common non-transforming
numeric constraints and non-pattern string constraints, primitive Literal values with
exact-type semantics, unions when any branch safely matches, recursively checked built-in
containers, and structurally checked Pydantic model instances. The predicate uses unbound
built-in container operations, does not rebuild sets or dictionaries, and never calls a
serializer. Receiver models with typed extra="allow" fields have those extras checked
structurally too. Bare Decimal receivers require finite values before bounds or
multiple_of are checked. Decimal allow_inf_nan=True, float multiple_of, enum receiver
contracts, callable discriminators, and string pattern constraints are rejected at
registration because the hook-free predicate cannot reproduce their semantics exactly;
non-pattern string constraints remain supported. Integer and finite Decimal multiple_of
constraints remain supported. Receiver schemas containing custom functional validators
(BeforeValidator, AfterValidator, WrapValidator, or PlainValidator), transforming
string constraints, custom literal values, custom instance-checking metaclasses, or
unsupported core schemas are rejected at registration rather than silently stripped.
Every operation must still enforce authorization.
Pass exact operations, never raw database sessions, engines, connections, cursors,
arbitrary SQL, shell access, or ambient filesystem authority.
See the complete executable
Required(...) quote example.
Typed operation contracts fail before serving
Section titled “Typed operation contracts fail before serving”Included from version 0.15.0: Operation(fn, bind=...) may omit output= when the
callable has a resolved, non-empty return annotation. Registration captures that full
annotation (including Annotated metadata) without mutating the original Operation.
An explicit output= remains authoritative. Input bindings are never inferred;
missing bindings and unsupported shapes still fail before serving. Published v0.14.0
requires explicit output=. Examples 7 and 8 retain explicit outputs for release compatibility;
source users may omit those redundant output declarations.
Use Operation when a capability’s dataflow is part of the endpoint contract rather
than something the agent should invent:
from my_service.models import Customer, CustomerRequest, CustomerResponsefrom my_service.operations import load_customerfrom summonpot import AgentChoice, Exactly, FromRequest, Operation, Required, Summon
summon = Summon("customer-api")
customer_from_request = Operation( load_customer, bind={ "customer_id": FromRequest("customer_id"), "format": AgentChoice(), }, output=Customer,)
@summon("/customers")def get_customer( request: CustomerRequest, customer=Required(customer_from_request, calls=Exactly(1)),) -> CustomerResponse: """Load this customer and return the approved customer view.""" ...The contract is immutable after construction. At registration, summonpot verifies that:
- every required operation argument has an explicit source;
FromRequest(...)names a real request field;FromResult(...)names a declared producer and a readable, typed output field;AgentChoice(...)selects from a supported collection and fits its receiving argument;- known source, element, and destination types are compatible; and
- ordering references name operations declared by the same endpoint.
The rule is deliberately conservative: a declaration is rejected only when its
incompatibility is provable. Missing annotations, Any, framework context, and type
relationships the checker cannot establish remain unknown rather than becoming false
registration errors. An annotation that names a type Python cannot resolve is still an
invalid endpoint declaration and fails at import.
For example, binding an int request field to a str operation argument fails while the
module is imported. A Customer value may feed a Person argument when Customer is a
subclass, and Python’s numeric widening permits int or bool to feed float.
[!IMPORTANT] Registration validates and stores every binding source. Runtime enforcement covers one required
Exactly(1)operation usingFromRequest, directAgentChoice, and callable defaults. When every required value is application-owned and the operation output exactly matches the endpoint response model, that operation executes without a model. Version 0.11.0 also enforces a sequential chain of requiredExactly(1)operations connected byFromResultorafter, with producer-backed choices fromlist[ConcreteModel]outputs. Choices use bounded opaque tokens mapped to canonical validated members; empty or oversized sets fail with a fixed redacted 409 before model decision or downstream work. Chains with choices remain agent-mediated; eligible fully resolved chains run model-free from 0.12.0 under the exact predicate above. Both return the unique terminal operation’s canonical validated result. From version 0.13.0, application-authenticatedFromContextis admitted under the contract below. Broader call bounds and graphs and broader deterministic compilation remain planned. Binding sources must be exact built-in vocabulary types; user-defined subclasses are rejected too. Bare callable dependencies without an explicitOperationcontract remain compatible.Operation(fn)is still an explicit contract, so it is rejected unless the declaration supplies the complete enforced shape.
Validated result chains (0.11.0)
Section titled “Validated result chains (0.11.0)”A uniquely ready required operation can feed the next step without asking the model to reconstruct arguments. Declare two or more Required(..., calls=Exactly(1)) operations; use FromResult for validated result fields and after for independent success ordering. Every step must have exactly one ready operation, and readiness is checked again before invocation.
The chain accepts FromRequest, FromResult, supported immutable defaults, and
producer-backed AgentChoice(from_result=producer) for a producer output of
list[ConcreteModel] only. Version 0.12.0 did not support context bindings; authenticated FromContext is included from version 0.13.0 as described below. Direct unbounded
choices remain unsupported inside chains. Candidate
lists are limited to 128 items and 65,536 JSON characters per binding. Inert projections
and opaque request-local tokens are exposed, never the canonical results; projection
respects exclusions and aliases without application serializers. Local token membership
maps the selection to the exact validated member without Python-equality
authority. Empty, unavailable, or oversized sets return a fixed redacted 409 before
decision or downstream work, with no extra model request. Its unique terminal operation
must declare the exact endpoint response annotation. Summonpot returns that operation’s
validated result; the model cannot invent a receipt. Canonical intermediate results stay
outside model context.
Version 0.11.0 runs every supported chain through the agent runtime. From 0.12.0, fully
resolved chains meeting the Pydantic-request, request-binding, immutable-source, unique-order,
and exact terminal-response predicates above execute without a model. The result-dependent route is included from version 0.14.0; historical published v0.13.0 behavior remains unchanged: it
requires exactly one AgentChoice(from_result=...) argument across the whole otherwise fully
resolved eligible chain, a Pydantic request with at least one FromRequest, and the same
terminal response contract. Empty/unavailable/oversized domains fail before model resolution
or downstream work; one candidate is bound locally and the suffix runs locally; multiple
candidates resolve the model only after the prefix and retain the existing agent-mediated
suffix. All other AgentChoice chains remain agent-mediated. Starts remain reserved after failure or
uncertain timeout; model retries cannot replay effects. Applications own cross-request
idempotency and transactions. See the runnable three-step SQLite inventory reservation example
and the producer-constrained inventory choice example
for real persisted receipts and independent database checks. These application-owned
operations do not imply a framework database adapter. This feature is included from version 0.11.0; historical v0.10.0 does not include it.
Authenticated application context (included from version 0.13.0)
Section titled “Authenticated application context (included from version 0.13.0)”Use Summon(context=authenticate) to register a plain sync or async function taking one
HTTP request and returning its annotated Pydantic principal. The model must have
ConfigDict(frozen=True, extra="forbid"); fields are exact immutable str, bytes,
bool, int, finite float, None, or typed tuples/frozensets of those values.
Admission inspects the provider’s canonical values without copying or coercing them.
Principal validation hooks, custom initializers/post-init hooks, and transforming model
configurations are rejected at registration; normalize identity in the authenticator instead.
FromContext("tenant_id") names a canonical principal field, not a client header, JSON
field, model argument, or alias. The application verifies credentials and supplies identity;
Summonpot does not implement login or infer authorization from an identifier.
The provider protects every declared Summon endpoint, even one without a context binding.
Documentation/OpenAPI routes are not authenticated by this hook. It runs once per business
endpoint request inside Runtime.timeout, after transport validation
and before model resolution or operation starts. The runtime snapshots immutable values
and preflights all context receiving constraints, including downstream chain steps, before
any operation starts. Missing/denied authentication returns a fixed 401; invalid context or
unexpected provider failure returns a fixed redacted 500. Async cancellation is cooperative;
a timed-out sync authenticator may finish in its worker, but no operation is then started.
The supported single-operation and uniquely ordered required Exactly(1) chain shapes
may bind context alongside request/result values. Existing direct eligibility still requires
a Pydantic request, at least one FromRequest binding, supported immutable defaults, and
the exact full response annotation. Context-only or scalar-request declarations remain
agent-mediated. A declared AgentChoice remains agent-mediated too.
Raw Runtime.call(..., context=principal) is an explicit trusted Python entry point for an
already authenticated principal; it is never populated from request JSON or ambient state.
Authenticated HTTP requires the standard Runtime.call admission path; replacement call
methods are rejected rather than silently bypassing the provider. Custom runtimes remain
compatible when authenticated context is unused.
The framework does not insert context values into model prompts, schemas, or public errors. Application outputs can intentionally disclose values and remain application-owned, as do credential policy, operation authorization, and tenant-scoped database queries. See the runnable SQLite notes example for verified bearer tokens, two independent tenants, persisted receipts, and idempotency. This feature is not included in version 0.12.0.
How it works today
Section titled “How it works today”HTTP request | vPydantic request validation + OpenAPI contract | vRuntime.call(...) | +---- eligible fully resolved Exactly(1) operation or sequential chain | | | +---- execute directly; validate each output; return canonical result | +---- otherwise: configured provider-neutral model | +---- may call only declared capabilities | +---- Required-operation gate | vLocal Pydantic response validation | vHTTP responseThe endpoint docstring becomes the fixed execution goal. Request data becomes validated
execution input. Capabilities become the complete set of operations available to execution.
The response model is always the final local validator; on the agent-backed path, it also
becomes the structured-output schema and validated request data becomes the user message.
Every endpoint response model and every declared operation output= shape is checked before
serving, including operation shapes outside the currently enforced runtime slice. Enabled direct
validation aliases cannot claim the same input key under the model’s configured validation
policy, and declared fields plus serialization aliases cannot emit duplicate JSON keys.
Runtime-enforced model output also rejects allowed extras from instances or raw mappings that
shadow a canonical field or emitted alias, while retaining noncolliding validated extras. This namespace admission does not imply runtime
structural validation for broader operation graphs, whose execution remains unsupported.
Raw Runtime.call(endpoint, mapping) invocations validate that mapping once against the
same declared request contract as HTTP, including required fields, defaults, aliases, and
canonical typed values for both Pydantic request models and individual parameters. The HTTP
adapter still validates at its transport boundary and hands its plan-bound value graph to the
runtime once; runtime preparation does not rerun those validators. Raw preparation does not
render canonical values through Pydantic field serializers or application copy/string hooks.
Parameterless endpoints accept only an empty raw mapping, rejecting undeclared keys before
model execution or application value hooks; their HTTP routes expose no request fields.
Pydantic AI is an internal runtime dependency. Applications use Summon, @summon,
Pydantic models, and declarative capabilities; they do not construct provider clients or
Pydantic AI agents.
The contract stays stable across execution paths
Section titled “The contract stays stable across execution paths”Summonpot chooses its current execution path without adding a second endpoint API:
| Contract state | Current execution |
|---|---|
Pydantic request model, one required Exactly(1) operation, at least one FromRequest binding, other inputs from FromRequest, authenticated FromContext (from 0.13.0), or immutable identity-stable defaults, exact response-model output |
Execute directly without a model |
A direct AgentChoice remains in the admitted single-operation shape |
Use the agent runtime with the enforced operation contract |
| Eligible fully resolved sequential chain meeting every 0.12.0 predicate above | Model-free sequential execution; return the canonical terminal result |
Supported sequential chain with producer-backed AgentChoice |
Included from version 0.14.0: exactly one choice uses singleton-local execution or multi-candidate lazy agent handoff. Included from version 0.15.0: framework-owned progression across one or more choices; selectors return ambiguous tokens and local execution resumes. Explicit tool_calls_limit retains the one-way agent suffix. Historical v0.13.0 behavior remains agent-mediated for all such choices. |
| Bare callable capabilities with implicit marker bounds | Use the legacy agent runtime |
| Version 0.15.0 fully resolved branch/join meeting the narrow acyclic, unique-sink, exact-response predicates | Sequential model-free execution with declaration-order readiness tie-break; included from v0.15.0, not v0.14.0 |
| Unsupported explicit binding, ordering, bound, output, or multi-operation shape outside a supported chain or narrow branch/join | Reject during registration |
Broader graph execution beyond the narrow version 0.15.0 branch/join slice, SQLAlchemy/SQLite operation adapters, write receipts, streaming, and framework-managed authentication are planned, not shipped. The branch/join slice is included from version 0.15.0 and is not included in published v0.14.0. Authentication context is application-owned; it does not add login, token issuance, or tenant isolation. See ROADMAP.md for the design boundaries and implementation order.
Supported immutable callable defaults are exact built-in None, bool, int,
float, complex, str, and bytes values, plus tuples and frozensets containing
only those values recursively. Custom types (including subclasses of those built-ins)
and mutable defaults keep the endpoint agent-backed; copy hooks are not proof of
immutability. Scalar request declarations also remain agent-backed.
HTTP methods and OpenAPI
Section titled “HTTP methods and OpenAPI”POST is the default. Body endpoints take one Pydantic request model. Bodyless methods
such as GET, DELETE, and HEAD declare scalar or scalar-sequence query parameters:
This fragment continues from an existing module-level summon application:
from typing import Literal
from pydantic import BaseModel
class TicketPage(BaseModel): tickets: list[str]
@summon("/tickets", method="GET")def list_tickets( status: Literal["open", "closed"] = "open", ids: list[int] | None = None,) -> TicketPage: """List tickets matching the requested filters.""" ...GET /tickets and POST /tickets may coexist. Registering the same normalized
(path, method) twice fails at import time, as do missing docstrings, unresolved type
annotations, invalid capability callables, duplicate capability names, unsupported query
types, and stream=True.
Path parameters
Section titled “Path parameters”A {name} placeholder in a route binds from the URL on every method, body-carrying
ones included. Each placeholder must match exactly one required scalar parameter
(str, int, float, bool, UUID):
@summon("/customers/{customer_id}", method="POST")def update_customer(customer_id: int, name: str) -> str: """Update one customer.""" ...customer_id is documented as an OpenAPI path parameter and is excluded from the
generated request body model, so the value exists in exactly one place. The URL is
the only authority for it: a body that also carries customer_id does not override
the URL.
When the URL owns every declared parameter the route carries no request body at all, so it is callable with nothing but its path segments:
@summon("/items/{item_id}", method="POST")def touch_item(item_id: int) -> Item: """Touch one item.""" ...curl -X POST http://localhost:8000/items/7These fail at import time, next to the other registration errors above: a placeholder with no matching parameter, the same placeholder twice, a path parameter with a default, and a path parameter annotated with anything but a supported scalar. A structured value belongs in the body.
Provider and model configuration
Section titled “Provider and model configuration”| Provider | Install extra | Model example | API-key variable |
|---|---|---|---|
| OpenAI | summonpot[openai] |
openai:gpt-4o-mini |
OPENAI_API_KEY |
| Anthropic | summonpot[anthropic] |
anthropic:claude-sonnet-4-5 |
ANTHROPIC_API_KEY |
summonpot[google] |
google:gemini-2.5-flash |
GOOGLE_API_KEY |
|
| Groq | summonpot[groq] |
groq:llama-3.3-70b-versatile |
GROQ_API_KEY |
| Mistral | summonpot[mistral] |
mistral:mistral-large-latest |
MISTRAL_API_KEY |
| OpenRouter | summonpot[openrouter] |
openrouter:anthropic/claude-sonnet-4 |
OPENROUTER_API_KEY |
| xAI | summonpot[xai] |
xai:grok-4 |
XAI_API_KEY |
Set one default for the Summon application through SUMMONPOT_MODEL or in Python:
summon = Summon("research-api", model="openrouter:anthropic/claude-sonnet-4")Override it for one endpoint without changing that endpoint’s HTTP contract:
@summon("/research", model="anthropic:claude-sonnet-4-5")def research(request: ResearchRequest) -> ResearchResponse: """Research the topic and return a sourced report.""" ...OpenRouter keeps the upstream provider and model after the first colon. Legacy unprefixed model names resolve through OpenAI for backward compatibility.
Bounding a call
Section titled “Bounding a call”Binding and exposure: A reachable endpoint can spend the operator’s provider credit, so set explicit usage limits and a timeout:
from summonpot import Summon, UsageLimitsfrom summonpot.runtime import Runtime
summon = Summon( "my-service", runtime=Runtime( usage_limits=UsageLimits( request_limit=8, total_tokens_limit=40_000, ), timeout=30.0, ),)| HTTP status | Public meaning |
|---|---|
422 |
Request validation failed, or a validated request value failed a receiving operation contract. |
429 |
The configured usage limit or provider rate limit was exceeded. |
502 |
The provider failed, the agent did not satisfy the endpoint contract, or operation output failed validation. |
504 |
The endpoint exceeded its timeout. |
500 |
Provider configuration or application capability failed. |
Framework-owned failures return fixed messages. Normal logs contain allowlisted endpoint/failure categories only; they do not include exception text, chains, provider bodies, prompts, outputs, validation inputs, or capability arguments/results. HTTP request-validation 422 responses are also redacted to avoid echoing invalid input.
One monotonic request deadline covers runtime request preparation, model/capability execution, and final output validation. Synchronous preparation or validation cannot be preempted; after they return, the runtime checks the same deadline before starting effects or returning output. HTTP body parsing and FastAPI request validation happen before the route handler and are outside this runtime deadline. Async cancellation is cooperative. A timed-out synchronous capability running in a worker thread can continue and complete its side effect after the caller receives a timeout, so timeout is an uncertain outcome—not evidence that no effect occurred. Use application-level deadlines/idempotency for irreversible work; summonpot never retries a capability or falls back to a model after the direct effect starts.
Summonpot does not implement login or authentication policy. For HTTP routes, Summon(context=...) can resolve an application-authenticated principal per request; applications still own identity verification, authorization, tenant isolation, and deployment exposure. Bind local development to 127.0.0.1 and configure runtime limits.
Examples
Section titled “Examples”The examples/ directory grows from one endpoint to a multi-file service:
| Level | Example | What it demonstrates |
|---|---|---|
| 1 | basic_app.py |
Minimal typed request and response |
| 2 | 02_required_capability.py |
Required exact calculation |
| 3 | 03_agentic_order.py |
Bounded choice plus required write |
| 4 | 04_http_methods.py |
GET/POST and query parameters |
| 5 | 05_bounded_runtime.py |
Limits, timeout, model override |
| 6 | 06_support_service/ |
Multi-file legacy service |
| 7 | 07_bound_operation.py |
Enforced request binding and agent choice |
| 8 | 08_direct_execution.py |
Credential-free deterministic execution |
| 9 | 09_contract_boundaries/ |
Registration and receiving-constraint checks |
| 10 | 10_result_chain/ |
Sequential result chain |
| 11 | 11_linear_result_chain/ |
Fully resolved linear chain |
| 12 | 12_producer_choice/ |
Producer-constrained candidate choice |
| 13a | 13_authenticated_context/ |
Authenticated tenant context (released 0.13.0) |
| 13b | 13_multiple_producer_choices/ |
Multiple producer choices (included from version 0.15.0) |
| 14 | 14_bounded_audit/ |
Bounded repeated calls (included from version 0.15.0) |
| 15 | 15_repeated_stage/ |
Repeated-stage final result (included from version 0.15.0) |
| 16 | 16_stage_chain/ |
Repeated stage in a resolved chain (included from version 0.15.0) |
| 17 | 17_choice_stage/ |
Choice before repeated stage (included from version 0.15.0) |
| 18 | 18_checkpoint_cleanup/ |
Bounded checkpoint progression (included from version 0.15.0) |
| 19 | 19_checkpoint_status/ |
Checkpoint status (included from version 0.15.0) |
| 20 | 20_branch_join/ |
Narrow branch/join (included from version 0.15.0) |
| 21 | 21_path_methods/ |
Path parameters and HTTP methods (included from version 0.15.0) |
| 22 | 22_contract_defaults/ |
Callable defaults and contract metadata (included from version 0.15.0) |
| 23 | 23_choice_branch_join/ |
One bounded choice in independent branches (current source / unreleased) |
The examples guide explains capability progression and release boundaries.
Give your coding agent the contract
Section titled “Give your coding agent the contract”Summonpot uses an ellipsis as a declaration body, which is easy for a coding agent to mistake for an unfinished handler. Install the bundled skill so the agent knows the endpoint shape, typed operation sources, registration rules, capability boundary, HTTP behavior, and runtime caveats:
summonpot add skillsWith no arguments, summonpot detects agent configuration already present in the project. Choose one explicitly when needed:
summonpot add skills --agent claudesummonpot add skills --agent cursorsummonpot add skills --agent windsurfsummonpot add skills --agent copilotsummonpot add skills --agent clinesummonpot add skills --agent codexUse --path ./myproject to target another project directory. Shared files such as
AGENTS.md and .github/copilot-instructions.md are updated inside a managed block so
surrounding project instructions remain intact.
Community
Section titled “Community”The ModePot Discord is the shared community for summonpot, intpot, dexpot, and the rest of the project family. Join to discuss use cases, ask implementation questions, and help shape declaration-first Python frameworks.
Use GitHub issues for reproducible bugs and scoped feature proposals. Use Discord for open-ended design discussion, early ideas, and help applying the frameworks to real projects.
Contributing
Section titled “Contributing”Summonpot is early enough that a focused contribution can still shape the framework, not just polish its edges.
Useful places to contribute include:
- executable examples for real application workflows;
- provider and HTTP acceptance coverage;
- clearer errors, safer defaults, and API ergonomics;
- broader capability-graph execution,
FromContext, and ordering; - exact database-operation adapters;
- broader deterministic execution compilation described in the roadmap;
- documentation, diagrams, and reproducible bug reports.
For substantial behavior or architecture changes, open an issue first so the public contract and security boundary stay coherent.
Development uses uv:
git clone https://github.com/tugrulguner/summonpot.gitcd summonpotuv sync --all-extrasmake checkEvery user-facing change needs an issue-backed or generated orphan Towncrier fragment. Read CONTRIBUTING.md before opening a pull request.
Roadmap
Section titled “Roadmap”The long-term goal is one stable endpoint declaration with the least-powerful sufficient executor behind it:
one fully resolved operation path -> no-model deterministic executorbounded semantic choice remains -> agentic executorno legal path -> typed deterministic errorThe ordering, security constraints, non-goals, and shipped foundation live in ROADMAP.md.
Help summonpot grow
Section titled “Help summonpot grow”If the endpoint-first approach is useful to you:
- Star the repository so more Python developers can find it.
- Build one small endpoint and report the friction.
- Share a real use case, add an executable example, or contribute to a roadmap milestone.
Early feedback is especially valuable because the public contract is small and the next execution layers are being designed around it now.
