Hypothetical scenario. Northwind’s assistant can answer with evidence. Maya now asks it to update a support record. Dev proposes an agent loop; Priya wants to know when an observation becomes a proposal, when a proposal is authorized and how an interrupted action is recovered.
Maya: “Answering the question did not change the record.”
Dev: “The next step could depend on what a tool reports.”
Priya: “Make each transition visible, and decide whether a fixed workflow already covers it.”
You will trace perceive, reason, act and evaluate through persisted state, action identity and stopping conditions. Compare a bounded dynamic loop with a prescribed workflow before granting flexibility the task does not need.
Where does a proposed next step become an action?
The perceive → reason → act → evaluate description is useful only when its transitions have concrete meanings. Perceive records a permitted observation. Reason produces a proposal, not authorization. Act dispatches an allowed operation with an identity. Evaluate checks its outcome against task and stopping conditions. A scripted workflow may implement these boundaries without an autonomous planner; choose an agent only when selecting actions from observations is justified.
Hypothetical scenario. A run permits three tool attempts. It sends one query, retries after a confirmed rejection, then performs a second distinct query. Attempts consumed are 1 + 1 + 1 = 3 even though there were only two intended query operations. A fourth proposal must stop or request a separately authorized budget. Count attempts, accepted operations and observations independently; an eloquent plan does not refund work already performed.
The worker restarts after the action
Hypothetical scenario. A bounded assistant creates a support ticket, then its worker crashes before recording the tool result. On restart, the conversation ends with a proposed ticket creation. Replaying that proposal can create another ticket even though the user intended one.
The tool-authority chapter decided which actions the application is allowed to execute. Durable state decides what the application knows about actions already requested, confirmed or unresolved. Conversation text alone is a poor execution ledger because it can omit a completed effect or summarize away an essential identifier.
An agent loop is a repeated decision process: observe state, propose a next step, validate it, execute within bounds and record the result. Its reliability depends on explicit transitions and recovery, not on the model's ability to produce a confident account of what happened.
Separate agent planning from durable control
Hypothetical scenario. Compare a prescribed workflow with a model-directed agent for the same bounded support task. The agent can propose a next tool or stop action; application state still owns current authority, budgets and legal transitions.
| Artifact | Concrete evidence | Decision boundary |
|---|---|---|
| Run state | task, permitted actions, current step | Application authority |
| Model proposal | next action and arguments | Untrusted choice |
| Execution evidence | operation identity, result / uncertainty | Durable recovery |
A loop that sees a tool result must distinguish observation from instruction. Repeatedly asking the model what to do is not durable recovery. Record the accepted step, its business operation identity and the evidence needed to resume after uncertainty. Choose model-directed planning only when its flexibility improves accepted task outcomes enough to justify extra work and failure modes. A fixed workflow remains a valid architecture when the required path is already known.
Replaying reasoning can repeat effects
Regenerating the next tool call after a restart can choose a different action or new operation identifier. Even a deterministic replay of a recorded proposal can repeat its external effect. Distinguish replaying decision history from executing side effects again.
A process can fail after sending an action but before receiving a response, or after receiving the response but before storing it. In both cases the local state may be incomplete. Treating missing confirmation as definite failure encourages unsafe repetition.
The runtime lessons already separated logical tasks from attempts. Carry that separation into each action. A tool result needs its operation identity, target, observed status and evidence. A prose memory saying “ticket probably created” cannot support the same recovery decision as a provider-confirmed identifier.
Persist the state machine, not only the chat
A task record identifies the authorized goal, current state, remaining budgets and relevant resource versions. An action record identifies the proposed effect, validation decision, stable operation identity and status. Useful statuses distinguish planned, authorized, requested, confirmed and unresolved work.
Persist action intent before sending it, but do not pretend that a local write atomically includes an arbitrary external effect. If the provider supports operation identity, reuse it across attempts. Otherwise use its documented status evidence or stop for an explicit unresolved decision where safe repetition cannot be established.
Only advance from a confirmed result according to its actual contract. A tool returning accepted may have queued work rather than completed it. Preserve that distinction in both the task state and the user-facing explanation.
Use explicit states for the document assistant's optional ticket action. A proposed action is a model output. An authorized action is an application decision bound to an actor, target, approved arguments and relevant resource versions. A requested action has crossed an external boundary; missing local confirmation from that point is not proof of failure.
| Recorded state | Permitted continuation | Required evidence |
|---|---|---|
| Proposed | Authorize or reject | Scope, arguments and policy checks |
| Authorized | Persist intent, then request | Stable operation ID and bound approval |
| Requested | Confirm, record definite rejection, or mark unresolved | Provider result under its documented contract |
| Unresolved | Reconcile, wait or escalate | Status evidence; absence alone is inconclusive |
| Confirmed | Advance task or propose a separate correction | Recorded effect identity and result |
| Definite rejection | Stop or make a permitted retry decision | Evidence that the intended effect was not accepted |
Hypothetical scenario. The provider creates ticket T for operation K. The worker crashes before recording T. Recovery reads requested K, marks the observation unresolved and queries the provider using the supported operation/status interface. If evidence confirms T, it records T and advances; it does not invent operation K2 merely because the conversation ended at a proposal. When the provider cannot establish the outcome and safe repetition is unavailable, the task stays pending for a bounded reconciliation or human decision.
A correction has a separate identity and result. Closing an unwanted ticket may be supported; recalling an email or undoing disclosure may not be. Do not erase the original confirmed action when a corrective action is proposed. If the correction becomes uncertain, reconcile it independently. This distinction connects the workflow and compensation chapter to the tool-retry argument.
Anthropic's workflow discussion motivates using a prescribed path where it satisfies the task. A deterministic transition rule can bound application behavior even when the model's proposal varies. The transition table does not make model generation deterministic or certify that every allowed action is desirable.
Derive a loop budget and a recovery backlog
Hypothetical scenario. Choose a task allowance of six model decisions and four tool attempts. A retrieval decision, a clarification decision and an action proposal consume three model decisions. Retrieval, a status check and a retry consume three tool attempts. Remaining allowances are 6 − 3 = 3 decisions and 4 − 3 = 1 tool attempt.
A model decision can propose several actions, so counting model turns alone does not bound external effects. The executor needs separate action and resource accounting. Failed and rejected attempts may still consume time or provider quota; declare whether they spend the task's allowance.
For time, choose a 30-second useful deadline. Planning and retrieval consume eight seconds, an action wait consumes twelve, and storing and presenting results reserves two. The remaining useful wait is 30 − 8 − 12 − 2 = 8 seconds. A proposed ten-second retry cannot fit that plan.
For uncertain recovery, choose a backlog of 40 action records and a reconciliation service that resolves ten per minute while five new unresolved records arrive per minute. Net drain is 10 − 5 = 5 records per minute, so 40 ÷ 5 = 8 minutes under constant successful resolution rates. A status lookup that remains inconclusive does not count as resolution.
These chosen budgets make the stopping rule visible. They are not universal settings for agents. The appropriate bound depends on task consequence, provider behavior and how the application exposes incomplete outcomes.
Memory is context, not unlimited authority
Retained conversation can improve continuity, but old instructions may no longer be authorized or relevant. Record the current task scope separately from a free-form summary. A memory update should not silently expand allowed actions or convert a source observation into a user decision.
Summaries are lossy. Preserve authoritative operation identities, document versions and approval records in structured state, then reference them when assembling context. Do not rely on a generated summary to decide whether a payment or ticket creation already occurred.
Long-lived memory also introduces retention and access questions. Store only what the task needs, restrict who can read it and handle deletion or changed permissions. Keeping every retrieved document forever is neither a correctness requirement nor an automatic improvement in future decisions.
The resumed task uses an expired decision
Hypothetical scenario. A user confirms editing version seven of a document. The worker pauses, another person changes the document, and the task resumes against version eight. The stored conversation still contains approval, but it covers a different state.
On resume, validate current identity, permission, resource version and the meaning of the recorded decision. If the proposed effect no longer matches what was approved, prepare a revised operation under the task's actual authorization policy. Durable storage preserves evidence; it does not make old evidence current.
Recovery ownership also matters. Two resumed workers must not independently spend the same task budget or advance incompatible states. Use a suitable conditional transition or single authoritative owner, with effect-boundary protection against stale workers.
Do not confuse these completions
“The model says it is done.” Check the task's completion criteria and confirmed effects. A natural-language ending is not a durable workflow outcome.
“The replay was deterministic.” Deterministic proposals can still repeat external effects. Recovery needs stable action identity and reconciliation.
“The task stopped at its budget.” Local stopping may leave a requested external action in flight. Record and communicate the unresolved state instead of implying cancellation was confirmed.
Use dynamic loops only where they help
Use model-directed decisions when evidence genuinely determines the next useful step and the available tools have bounded authority. Prefer a fixed workflow for known transitions and required approvals. Building effective agents describes both orchestration styles without making one universally preferable.
Define stopping conditions for completion, lack of progress, exhausted budget, changed authority and unresolved effects. A repeated observation with no new evidence should not automatically justify another identical attempt. Explain incomplete results to the user in terms of confirmed and pending work.
The adaptation module next asks whether failures require changing model behavior at all. A lost tool response or stale permission is usually an application-state problem. Training the model should not be the default repair for a missing execution contract.
Durable execution engines preserve progress, not remote certainty
A durable execution engine maintains an execution history or explicit state so a workflow can continue after a process failure. Temporal reconstructs workflow progress through recorded events and deterministic workflow execution. Work that interacts with the outside world belongs in activities whose outcomes enter the history. Replaying an already recorded activity result is different from issuing its external request again.
The workflow logic must remain compatible with the recorded history. Arbitrary network reads, changing clocks and random choices cannot silently produce a different transition during replay. Use the engine’s supported mechanisms for such values and for evolving workflow definitions. A durable engine moves recovery bookkeeping into a runtime; it does not eliminate the requirement to understand what is being persisted.
AWS Step Functions offers another explicit execution model. Its documentation distinguishes Standard workflows from asynchronous Express and synchronous Express execution semantics. Standard’s documented exactly-once workflow execution does not mean every third-party side effect is inherently idempotent, particularly where a task has an explicit retry. Choose the workflow type from duration, observability and repetition requirements instead of assuming a single durability guarantee applies to every option.
Reconstruct one crash without inventing a second action
Hypothetical worked extension: a workflow records 5 completed activities and then crashes after submitting its sixth external request but before recording the result. Five completion records can be reused. The sixth effect is unresolved. History length is not evidence that the provider rejected it, so recovery consults the same stored action identity rather than creating a replacement business action.
If each activity has a chosen 2 KiB result record, the first 5 records contain 5 × 2 = 10 KiB of result payload. Recording the sixth adds 2 KiB, bringing that component to 12 KiB. Event metadata, commands, retries and replication are excluded. Persisting small structured references instead of full private documents keeps recovery focused, but requires those referenced evidence versions to remain available.
A model call also has an observation boundary. Once its accepted result is recorded, replay should use that result instead of generating a new plan that changes previously approved arguments. A later deliberate replan is a new transition with its own evidence and budget. This distinction prevents recovery from quietly rewriting the story that authorized an earlier action.
In the wild: compare the engines’ declared semantics
Temporal’s workflow-execution documentation and AWS’s workflow-type comparison describe real durable-execution mechanisms. They support comparing recovery models, not a claim that either vendor resolves every remote uncertainty. Northwind still needs provider-supported operation identities, reconciliation and a visible unresolved state around refunds or ticket creation.
The engine is useful when tasks span worker lifetimes, approval pauses or many independently recoverable steps. A small read-only request can remain simpler without it. Northwind chooses durable orchestration for approved support actions, keeps private evidence referenced under scope, and limits the history and total attempt budget rather than treating persistence as permission to run forever.
Northwind decision log
- Persist action identity before attempting a write.
- Reconcile uncertain actions before resuming.
- Keep time and attempt budgets in durable state.
Go deeper into state and repeated actions
- Book chapter: AI Agents in Action, chapter 11: Agent planning and feedback — Micheal Lanham. Read this chapter for the action and workflow boundary.
- Book chapter: LLMs in Production, chapter 8: Applications and Agents: Building an interactive experience — Christopher Brousseau and Matthew Sharp. Read this chapter for the action and workflow boundary.
- Video lecture: What Durable Execution Changes for Developers — Maxim Fateev, Sergey Bykov and hosts / Techstrong TV. Watch first for the mechanism and its operating assumptions.
- Primary documentation: Temporal workflow execution. Describes recorded workflow progress and the recovery semantics that still surround remote side effects.
- Primary documentation: AWS Step Functions workflow types. Describes recorded workflow progress and the recovery semantics that still surround remote side effects.
Test the run state boundary
A tool reply says to ignore the remaining budget. What changes?
Reveal the design reasoning
Nothing in the authoritative budget ledger. Treat the reply as untrusted task data and enforce limits at dispatch. The model cannot replenish its own authority or budget.
Decision: Choose the simplest control flow that meets the task and recovery requirements.
Check yourself: resume without guessing
A ticket creation was sent before a crash, but no result was stored. What state should recovery begin from?
An unresolved external action. Reconcile using stable operation identity and provider evidence. Missing local confirmation does not establish that no ticket exists.
A task has one model decision remaining. Can it execute an unlimited set of parallel tools?
No. Model decisions, tool attempts, effects and resource budgets are separate. Enforce the relevant limits before accepting proposed actions.
A resumed task finds an old approval for a changed document. What needs checking?
Current permission, resource version and whether the proposed effect remains within the recorded authorization. Durable approval evidence is not unconditional authority for future changed actions.
Check the mechanism in this lesson
Why can three attempts correspond to only two intended query operations?
Compare the explanation
A repeated attempt after rejection consumes work without creating a new logical operation. Maintain separate identities and counters for the intended action, its attempts and accepted external effects.
Carry the decision forward
A durable loop preserves progress but does not choose the next investigation step. Page 20 compares interleaved action, advance planning and feedback-based revision under the same acceptance boundary.