Operations
An operation is an action a company performs only once the user approves its exact terms: a payment, an exchange, a cancellation. The Operations extension (version 3) makes the approval exact, and the action happen at most once. The paired examples get Ada's approval of Northwind Bank's payments.
The walkthrough:
- Negotiation.
operations_negotiated()is true only when the company listsoperationsversion 3 and the Session declares it inPoppy-Extensions(§3.4). Without it, a company handles approval itself or answers withextension_required. - The user decides.
ask_user()goes through the host's own approval surface, naming the company and showing its terms, and makes auserapproval. A chat message never approves anything. An agent may also approve on an instruction the user gave it (approve_as_agent(), anagentapproval): see the Operations guide. - New terms. An approval of a revision the company can't accept performs
nothing, and the company returns a new revision, never the one named.
ask_user(replaces=...)shows what changed before asking again. - At most once.
send()keeps the same approval after a failure or a timeout. The company performs the action once, and a repeat gets the original response; while it is being performed,503andRetry-After.
The wire depends on where the company asks. At an API, the first request answers
403 with approval_required and the operation, and the retry is the same request
with a Poppy-Approval header naming the operation_id and the revision. At an
MCP server, the tool returns an error result with the operation, and the retry
carries the approval in _meta. In a conversation, as here, a company message
carries the operation and the agent's message carries the approval. Operations have
no endpoint and no state of their own: the same request, with the approval, is all
there is.
The model sees revisions, changed term paths, error codes, and what the company says it came to, as written. Tokens stay host-only, and the decision to approve stays with the user in the host's own interface.
- Run the Pydantic AI example.
- Run the Agent Runtimes example.
- Read the Operations guide.