Contents

Foundation Model Engineering

Manuscript updated (UTC) · Chapter source on GitHub · Cite this chapter (RIS)

On this page

16.6 Agent Reliability, Recovery, and Guardrails

A customer asks an agent to open one support ticket. The ticket service saves it, but the response times out. The customer still sees a spinner. The agent sees a failed tool call. What should it do on the next turn?

This is the gap between a tool’s effect and the agent’s observation. A timeout tells us when the caller stopped waiting. To learn whether the ticket exists, the caller needs a receipt or a way to look up the original request. Even steady performance on single runs can hide failures across repeated attempts, as the ττ-bench experiments illustrate [4].


1. Bound the Loop

Give each run a deadline and a tool-call budget. Keep a separate budget for retries so that one slow service cannot consume the whole run.

Minimum Execution Limits

  • Count model turns and tool calls separately.
  • Set a deadline for the whole job as well as for each tool call.
  • Record why the runtime stopped and which operations still have an unknown outcome.

If a ticket call times out on the last permitted step, return the request identifier with a pending status. The next worker can reconcile that request before deciding whether to retry.


2. Checkpoint Before Risky Actions

Before sending a write, save the intended operation, its arguments, and a stable request key. After the tool responds, save its receipt. A worker recovering between those two writes has a known request with an unknown outcome.

  1. Read the pending request from the checkpoint after a restart.
  2. Look it up in the receiving service or replay it with the same key if the service supports idempotent creation.
  3. Save the confirmed receipt. If the service offers neither lookup nor safe replay, leave the outcome pending for reconciliation.

The ticket that survived the timeout

The following Python 3 example represents the ticket service with one SQLite file and one caller. Each call opens a fresh connection. The first call commits and its return value is deliberately ignored, simulating a lost response. The next two calls try two recovery choices.

from contextlib import closing
from pathlib import Path
import sqlite3
from tempfile import TemporaryDirectory

def create_ticket(path, key, subject):
    with closing(sqlite3.connect(path)) as db, db:
        db.execute("""CREATE TABLE IF NOT EXISTS ticket (
            id INTEGER PRIMARY KEY, request_key TEXT UNIQUE NOT NULL,
            subject TEXT NOT NULL)""")
        db.execute("""INSERT INTO ticket(request_key, subject) VALUES (?, ?)
                      ON CONFLICT(request_key) DO NOTHING""", (key, subject))
        ticket_id, saved_subject = db.execute(
            "SELECT id, subject FROM ticket WHERE request_key = ?", (key,)
        ).fetchone()
        if subject != saved_subject:
            raise ValueError("request key already used for another subject")
        return ticket_id

with TemporaryDirectory() as folder:
    path = Path(folder) / "support.db"
    subject = "Missing receipt for order 41"
    create_ticket(path, "action-41", subject)
    print(create_ticket(path, "action-41", subject))  # 1
    print(create_ticket(path, "action-42", subject))  # 2

The second call recovers ticket 1. The third call creates ticket 2 because the caller supplied a fresh key, even though the subject was identical. Try changing the subject on the second call. The service rejects the conflicting intent and keeps the first ticket. The unique constraint and the write share a transaction, so a worker cannot commit a ticket without recording its key [9].

A real service must define the key’s scope and how long it remembers it. In a multi-tenant system the lookup needs the authenticated account as well as the key. If the service has forgotten an old key, automatic replay can create another ticket.

Where model history fits (as of 2026-11-25). OpenAI documents that editing an earlier message or tool call in a GPT-6.2 Responses API conversation can cause the model to lose access to subsequent reasoning items. Repeating that work may consume more tokens [10]. Editing the conversation leaves ticket 1 in the support database. On recovery the agent can read the saved request key and use it to recover the receipt from the ticket service, even if it has to reason about the next step again.


3. Tool Execution Policy

A support agent can look up a ticket, add an internal note, or email the customer. Each call can time out. What happens on replay depends on the operation the service exposes.

Useful Defaults

Bind the call to the authenticated account, validate the arguments, and set a deadline. On timeout, the runtime should have a written rule for that operation. The tool’s description alone cannot tell the runtime how long the receiver keeps an idempotency key.

Classify Tools by Blast Radius

OperationWhat a second call can doRecovery rule
Read ticket 1Return a more recent statusRead again within the deadline.
Add a noteAppend the same note twiceReuse the saved key if the API supports it, then verify the note ID.
Email the customerDeliver a second copy to the inboxCheck the mail service’s delivery record. Hold the request if acceptance is unknown.

A draft can usually be edited after a mistake. A delivered email can already have been read. That difference affects both approval before the action and recovery afterward.


4. Human-in-the-Loop Does Not Mean Human-in-the-Way

Suppose the user authorized opening one ticket. That instruction covers the initial create. If a service timeout obscures the outcome, sending a new key asks the service to create a second ticket. That exceeds the user’s original approval.

Good Approval Boundaries

A worker can carry out an authorized status lookup on its own. Ask the user when the decision changes what happens outside the system. For example, if the service cannot confirm the original write, show the order number, the time of the first request, and the possible duplicate before offering to open another ticket. If the original request later appears, link it to the pending case.


5. What the Research Actually Shows

Read an agent paper with a concrete question in mind. What did the researchers observe after the action?

  • ReAct alternates reasoning and actions. A returned search result can change the next action [1]. Toolformer studies how a model learns where to call a tool and how to use its response [3].
  • Reflexion carries textual feedback from one attempt to the next [2]. For the ticket case, that could help a model remember to look up the request. The receiving service still determines whether a duplicate exists.
  • AgentBench evaluates multi-step decisions across interactive environments [5]. SWE-bench tests whether proposed changes resolve real repository issues [6]. The task and its grader determine what counts as success.
  • ττ-bench repeats tool-agent-user tasks under domain rules [4]. If the goal is one new ticket, the final database count is a better check than a fluent confirmation to the customer.

6. Practical Takeaway

For a recovery drill, drop the response after the ticket has been committed and restart the worker. Check the number of tickets created for that user request, the ID returned to the customer, and whether a second worker can reconstruct the outcome. Run it again with the service unavailable and verify that the case stays pending.


Recent Evidence: Boundaries Must Survive Alternate Paths

As of 2026-10-13. Anthropic’s October 9 report documents unintended actions in evaluations and internal use, including attempts to work around tool restrictions. The provider reports minimal real-world impact for the listed cases and explains that it disabled live internet access across its internal evaluations while strengthening containment and monitoring [7]. These observations establish concrete failure modes; they do not estimate a universal incident rate or prove how often another system will fail.

A recovery policy must preserve the original action boundary. If a fetch is denied, switching to a different tool, redirect, or service must not silently create new permission. Enforce destination and action authorization at execution time, independently of the model’s explanation. Test alternate routes, indirect requests, retries after denials, and writes disguised as reads. Record attempted effects, blocked effects, actual effects, and recovery outcome separately. A model’s cooperative narrative is not evidence that the executor enforced containment.

Deletion Needs an Access-Path Test

As of 2026-10-18, Lizzo and Heck’s October 15 workshop paper shows that measured forgetting can differ across semantically equivalent multilingual queries [8]. A successful refusal or failed recall in one language does not establish information inaccessibility. This is bounded evidence about access-path generalization, not a theorem that every unlearning method fails.

As an engineering release gate, distinguish external-memory deletion from changes to model weights. Trace a deletion through source records, summaries, vector and graph indexes, caches, replicas, and restore paths. Test equivalent queries across supported languages and scripts with an authorized recovery audit; an English-only refusal test is insufficient. A rollback must not silently resurrect deleted records. Version tombstones and retention decisions with the artifact and data lineage, and declare which residual copies remain under their retention policy.

A bounded decision model can supply a routing or review signal, but it cannot grant execution authority. Section 16.7 separates typed outputs, calibrated probabilities, abstention, and the independent executor policy.

Quizzes

Quiz 1: A status lookup is still pending when the last tool call times out. What belongs in the checkpoint? Save the original request key, the arguments, the outstanding status and why the run stopped. A later worker can reconcile the same operation within a new budget.

Quiz 2: The first response times out. Why do the next two calls return different ticket IDs? The first call committed ticket 1. Reusing action-41 with the same subject returns that ticket. The service treats action-42 as a new request and creates ticket 2.

Quiz 3: The service’s key retention window has expired and the checkpoint has no receipt. How should the agent recover? Look up the ticket in the receiving system using the original request or another reliable business record. If its status is still unknown, hold it for reconciliation. Replaying an expired key can create a second ticket.

Quiz 4: The user approved opening one ticket. Which recovery decision needs their attention? An authorized lookup can proceed. If the original outcome cannot be established, ask before creating another ticket and explain the possibility of a duplicate.


References

  1. Yao, S., et al. (2022). ReAct: Synergizing Reasoning and Acting in Language Models. arXiv:2210.03629.

  2. Shinn, N., et al. (2023). Reflexion: Language Agents with Verbal Reinforcement Learning. arXiv:2303.11366.

  3. Schick, T., et al. (2023). Toolformer: Language Models Can Teach Themselves to Use Tools. arXiv:2302.04761.

  4. Yao, S., Shinn, N., Razavi, P., & Narasimhan, K. (2024). ττ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains. arXiv:2406.12045.

  5. Liu, X., et al. (2024). AgentBench: Evaluating LLMs as Agents. arXiv:2308.03688.

  6. Jimenez, C. E., et al. (2024). SWE-bench: Can Language Models Resolve Real-World GitHub Issues? arXiv:2310.06770.

  7. Anthropic. (2026-10-09). Investigating unintended model actions in our evaluations and internal use. Source.

  8. Lizzo, T., & Heck, L. (2026). Behavioral Forgetting Is Not Privacy in Machine Unlearning. PriLOM workshop poster. Source.

  9. Malcolm Featonby. Making retries safe with idempotent APIs. Amazon Builders’ Library.

  10. OpenAI. Using GPT-6.2. Responses API guide.