Hypothetical scenario. Northwind’s read-only assistant can explain a policy. Maya now asks it to prepare a supplier change request. Dev adds a write tool; Priya asks who approved its exact fields and how the service recovers if execution finishes after the reply disappears.
Dev: “The model produced arguments matching the tool schema.”
Maya: “Which application decision authorizes that particular action for this employee?”
Separate proposal, approval, execution and recovery. Keep the initial capability bounded to preparing the selected change request, rather than granting arbitrary editing or messaging. The linked GenAI background complements the core job and idempotency mechanisms instead of replacing them.
Background for this lesson
Your outcome is an agent runtime separating proposals, approval, execution and recovery. Prerequisites are the optional assistant, core durable-job and idempotency chapters, and GenAI tool calling plus durable agents. The initial capability prepares a bounded change request; it does not grant arbitrary editing, messaging or purchasing authority. Model-directed choices stay inside an application-owned execution contract.
Which application decision authorizes this proposal?
An agent uses model output to choose a next step rather than following only a fixed sequence of predefined branches. That extra flexibility changes the control problem. The application must validate the selected tool, arguments, source references, current user authority and remaining budget before dispatch. A plausible JSON object is not an authorization decision.
Represent proposals explicitly. A proposal names the intended action, target, expected version and bounded arguments. Preserve the evidence used to prepare it, with appropriate retention controls. The runtime can reject an unsupported action or request clarification without pretending that the model has already completed it.
Retrieved text is evidence for a task, not a source of new privileges. A supplier document that says to disable approval cannot change the runtime policy. Likewise, a remembered instruction from an earlier session cannot grant an employee authority they no longer hold. Check permission at the consequential action boundary using current application state.
Bind approval to the action that will actually run
If the product requires approval, show the exact consequential fields and target. Record approval against the proposal identity and version. Changing the recipient, amount, destination or source revision can invalidate that approval. A generic continue response detached from the final action is difficult to audit and easy to misuse.
Persist accepted task state outside the model conversation. The runtime tracks prepared, awaiting approval, dispatched, confirmed, rejected and unresolved states as appropriate to the action. Model text may summarize those states, but it cannot replace their durable evidence. A transcript saying done is not a provider receipt.
Approval can expire or be revoked before dispatch. Revalidate the required current policy and expected target version when the action is accepted. If the underlying supplier record changed, return a conflict or prepare a new reviewable proposal. Do not silently apply an older approval to a different business transition.
Resume a durable workflow without replaying its effect
Hypothetical scenario. A model proposes action P. Application policy records approval A for a bounded, fingerprinted action under operation K. A durable workflow schedules the tool activity and records its eventual evidence. Replaying workflow decisions must reconstruct recorded choices; it must not call the model or remote tool anew as though those non-deterministic activities were pure local computation.
| Workflow record | Fields | Protected meaning |
|---|---|---|
| Proposal P | action, arguments, evidence | Untrusted suggestion |
| Approval A | fingerprint, scope, expiry | Bounded permission |
| Operation K | target identity, state, result | Recoverable business effect |
| Activity attempt | K, attempt ID, evidence | Execution observation |
The remote effect can succeed before the workflow records its reply. On resume, recover K through the target's operation contract and current authorization rule. A new attempt identity is useful, but creating a new business operation would duplicate the effect. Approval binds the actual action, not arbitrary later arguments produced by a model.
Cancellation changes what work may still be dispatched and which recovery actions remain authorized. It cannot erase an effect already committed remotely. Fixed workflows and dynamic agents both need these boundaries; dynamic planning adds choices within them rather than replacing them. Keep step, token, money and authority budgets in durable state so restart does not reset them.
Bound the work of one task
Hypothetical worked example. Select a maximum of six model turns and two tool attempts per turn. The tool-attempt ceiling is 6 × 2 = 12 attempts per task. It is not twelve successful business effects: the permitted logical actions and target duplicate rules are separate.
Choose a planning allowance of 1,500 input tokens and 300 output tokens per turn. Per-turn allowance is 1,500 + 300 = 1,800 tokens. Across six turns, the planned subtotal is 6 × 1,800 = 10,800 tokens. This is a selected reservation, not a vendor bill or proof of fit; growing history, serialization and actual tool results must be counted before each call.
For a forty-second task deadline, suppose eight seconds have elapsed and five seconds are reserved for final status handling. Remaining execution allowance is 40 − 8 − 5 = 27 seconds. A proposed tool retry requiring a selected thirty-second bound cannot fit. Stop or return an unresolved outcome rather than resetting the deadline for another model turn.
If ten accepted tasks each reserve twelve possible tool attempts, the aggregate reservation is 10 × 12 = 120 attempt opportunities. Admission can use that bound alongside measured demand. It should not report one hundred twenty completed actions or assume all reservations consume the same resources.
Resume the state machine, not a generated story
An interrupted runtime reloads the accepted task and last known operation identity. If an external call timed out, reconcile that exact operation before creating another logical action. A new conversation can help explain the uncertainty but cannot establish what the external target committed.
Keep retry ownership at one layer where possible. A model deciding to try again, an SDK retry and a queue redelivery can otherwise multiply work. Count actual attempts against the shared budget and use stable effect identities. The target’s real idempotency retention and conflict behavior remain part of the contract.
For long tasks, persist checkpoints that contain application-owned state, references and decisions needed for recovery. Do not require access to private model reasoning. An audit record should explain the accepted proposal, policy, approval and outcome; diagnostic traces can be correlated without becoming the only durable authority.
In the wild: fixed workflows and agents are distinct choices
Anthropic’s Building effective agents distinguishes predefined workflows from model-directed control and discusses composable patterns. Use that distinction to decide where flexibility is needed. The article does not supply Northwind’s action permissions or prove that an autonomous loop is better than a fixed form.
A narrow deterministic workflow can be preferable when the required steps and valid arguments are known. Add model-directed choice only where the product benefits from it and the runtime can bound it. A more complicated orchestration diagram is not evidence of better task outcomes.
A successful timeout is followed by another action
Hypothetical failure scenario. The change-request service commits the request, but the reply is lost. The model interprets the timeout as failure and proposes the same change again with a new operation identity. Both requests are accepted because the provider sees different logical operations.
Preserve the original identity through retries and reconcile its outcome. A durable unresolved task is more truthful than a fabricated failure or success. If the provider cannot recover the outcome, route the case to a declared human process rather than granting the agent permission to guess and continue.
Autonomy is a budgeted product capability
Limit tool availability by task and authenticated scope, not merely by a global list visible to every model call. Bound network destinations, output size and retained artifacts. A tool that executes code requires an actual isolation design beyond the agent’s prompt and beyond a schema validator.
Measure accepted tasks, rejected proposals, approval changes, confirmed effects and unresolved operations. Inspect failure categories separately from a blended task-success score. A runtime can finish quickly by refusing everything; usefulness and boundary preservation need their own evidence. The next page builds that release evidence without treating model self-evaluation as the final judge.
Challenge the proposed mechanism
The tool succeeded but its reply was lost before storage. Which activity should replay perform?
Reveal the design reasoning
Lookup or retry under the original K using the target contract and current authority, then record conclusive evidence. It must not replan a different action merely to fill a missing reply. Keep uncertainty when the target cannot resolve it.
Decision and reconsideration: Persist approvals, operation identities and budgets across resume. Treat model and tool calls as recorded activities.
Check the design against changed conditions
The arguments satisfy the tool schema. May the action execute?
Reason through the consequence
Not on schema evidence alone. Validate current user authority, target version, required exact approval and remaining execution budget at the action boundary.
A timeout follows dispatch. Should the next turn create a new operation identity?
Reason through the consequence
No for the same intention. Preserve and reconcile the original operation; a new identity can create a second business effect even if the generated text looks like a retry.
A thirty-second retry is proposed with twenty-seven seconds left. What should the runtime do?
Reason through the consequence
Reject the attempt under the selected deadline, or return a declared pending or unresolved state. Resetting the budget would remove the bound the product promised.
Bounded execution gives the agent a contract to follow. Page 64 asks what evidence supports releasing a changed prompt or route when usefulness, supported claims, authority and operations can fail independently.
Northwind decision log
Treat model-selected actions as proposals until application authorization.
Bind approval and recovery to exact durable operation identity.
Next, evaluate usefulness, authority and operations as separate requirements.
Go deeper: Proposals, control and tools
- Book chapter: Designing AI Agents — early-access chapters: chapter 2: Turn a task into an agent architecture — Jia Huang; early-access material, subject to revision. Use this resource to examine selecting agent architecture from task constraints.
- Book chapter: Designing AI Agents — early-access chapters: chapter 5: Reasoning: How your agent decides what to do next — Jia Huang; early-access material, subject to revision. Use this resource to examine inspectable decisions separated from action authority.
- Video lecture: Building with MCP and the Claude API — Alex Albert, John Welsh and Michael Cohen / Anthropic. Use this resource to examine tool integration without treating protocol access as permission.
- Primary document: Building effective agents — Anthropic. Use this resource to examine fixed workflows versus model-directed control.