The same error, a different position, and the model stops fixing it: error delivery in tool-calling agents

Leave this error in the conversation verbatim and the model retries with a different path. Delete it and add only "the previous attempt failed" to the earlier message, and the Llama family just stops working. Same FileNotFoundError: config/app.yaml, same model, same temperature, same user intent. Only the position changed, and the next action changed with it.

That is not folklore. arXiv:2611.11581, "Same Error, Different Recovery: How Delivery Changes LLM Agent Behavior" (Sunghyeun Woo, Javier Conde, Pedro Reviriego, posted 2026-11-08), turned it into a controlled experiment. Both studies fixed their plans before data collection, spanned 13 open models from 3B to 70B, and used exact deterministic reruns to compare the next action against subsequent task completion. The isolated variable is one most agent frameworks never model at all: how the error is delivered to the model.

What changed, and what did not

The error text did not change by a single character. What changed was placement, guidance, retained history and turn structure. In code that means three typical delivery forms: drop the failed exchange (erase the assistant's tool_calls together with the role=tool result, leaving the cleanest possible context), rewrite history (fold the failure into the previous user message), and append a new user turn (keep the whole failed exchange, then start a fresh turn telling the model something broke). The first one is especially common in tool-calling apps, because plenty of frameworks quietly strip failed turns while compacting context or resetting after an exception.

The result: dropping the failed exchange produced what the paper calls a severe stopping failure in Llama models. Appending a new user turn avoided it and was non-inferior to history rewriting in pooled synthetic comparisons -- but the authors stress it was not best for every model. They implemented this form as an opt-in recovery layer inside a deterministic inference engine. On ToolMaze, success on explicit errors rose 14.2 points with 7-8B models and 10.5 points with 32-70B models.

The negative result is the one I value most. Loud/Quiet has 24 multi-turn tasks mixing visible failures with silent corruption, scored by final-state agreement, and showed no measurable gain. Conversely, a client given the exact fault kind did better still. The paper's wording is deliberately restrained: delivery is a distinct factor in recovery, neither an engine-exclusive solution nor a universal retry policy. In plain terms, adding "please try again" only helps when the error is stated explicitly. If a tool returns wrong data without raising anything, this layer can do nothing.

Why position outweighs content

Message roles carry semantics. A failure the assistant wrote down is "my own record"; a failure appearing in a user turn is "a fact observed from outside". Delete the whole exchange and the next turn faces a breakpoint with no antecedent -- the model no longer knows which tool it called or with what arguments, and the cheapest action is to stop and report back to the user. Keeping the tool_calls and tool_call_id pairing is what lets it connect "which call blew up" to "which parameter to change next". That is also why retained history is isolated as its own variable in the paper: the few hundred tokens you saved bought away the causal chain.

There is a related trap worth flagging: a clean pairing check does not mean the information is still there. Strip the failed exchange entirely and both orphan tool results and unanswered tool calls come back empty. Validation looks perfectly healthy, yet the model has forgotten what it just tried. A clean history and a complete state are different things; the hands-on script below prints that contrast directly.

Three other items today are about the same thing

Jiqizhixin posted a NeurIPS 2026 paper walkthrough on 2026-11-12, "From posing the question first to exploring first: rethinking training data synthesis for tool-calling agents" -- the training side is starting to add failure trajectories instead of writing the question first and filling in a canonical answer afterwards. Qwopus3.8-27B-Coder-Flash on ModelScope (2026-11-08) writes its workflow as read, reason, call tools, edit, test, recover, deliver, with recovery as an explicit stage rather than something hidden in a retry decorator. CloudOpsBench, reported by The Decoder on 2026-11-04, is blunter still: across 45 real AWS operations tasks the best model solved only 60%, and about 80% of failures came from misjudging task scope, failing to check all relevant services, or stopping too early -- the same disease as the stopping failure, relocated to cloud operations.

The most interesting engineering counterpoint is microsoft/TokenEconomizer on today's GitHub Trending. Its loop guard waits for e=5 normally finished turns to learn the repository's usual turn, issues a short redirect only at judge confidence of at least 0.7, caps redirects at r=1 per turn, falls back to a rule when a churning turn exceeds b=2.5 times the usual length, and explicitly never stops a turn itself. One side studies how models stop on their own; the other designs a system that refuses to stop for you. Both are answering the same question: who gets to decide that a run is over.

Hands-on: make delivery a switchable layer

The script below is stdlib only; python delivery.py runs it as-is. It prints the messages built by all three strategies, the pairing checks and a token estimate in one pass. With a real endpoint, dropping the build() result straight into the request body gives you an A/B test without touching the agent's main loop.

# delivery.py - stdlib only. Run: python delivery.py
# Build and validate three ways of handing a failed tool call back to an agent.

CALL_ID = "call_01"


def failed_exchange():
    return [
        {"role": "user", "content": "Read config/app.yaml and print the port."},
        {"role": "assistant", "content": "",
         "tool_calls": [{"id": CALL_ID, "name": "read_file",
                         "arguments": {"path": "config/app.yaml"}}]},
        {"role": "tool", "tool_call_id": CALL_ID,
         "content": "Error: FileNotFoundError: config/app.yaml"},
    ]


def drop_exchange(msgs):
    return [m for m in msgs
            if m["role"] != "tool" and not m.get("tool_calls")]


def rewrite_history(msgs):
    out = drop_exchange(msgs)
    out[0] = {"role": "user",
              "content": out[0]["content"]
                         + " Previous attempt failed: FileNotFoundError."}
    return out


def new_user_turn(msgs, fault_kind="FileNotFoundError"):
    out = [dict(m) for m in msgs]
    out.append({"role": "user",
                "content": "The tool call above failed with " + fault_kind
                           + ". Keep the failed exchange in context, "
                           + "then retry with a corrected path or report "
                           + "the missing file."})
    return out


def validate(msgs):
    calls = set()
    for m in msgs:
        for c in m.get("tool_calls", []):
            calls.add(c["id"])
    results = {m["tool_call_id"] for m in msgs if m["role"] == "tool"}
    return {
        "orphan_tool_results": sorted(results - calls),
        "unanswered_tool_calls": sorted(calls - results),
        "failed_exchange_kept": bool(results) and bool(calls),
        "roles": " ".join(m["role"] for m in msgs),
    }


def approx_tokens(msgs):
    return sum(len(str(m.get("content", ""))) // 4 + 8 for m in msgs)


def demo():
    base = failed_exchange()
    builders = [
        ("drop_exchange", drop_exchange),
        ("rewrite_history", rewrite_history),
        ("new_user_turn", new_user_turn),
    ]
    for name, build in builders:
        msgs = build(base)
        v = validate(msgs)
        print("%-16s msgs=%d tokens=%d roles=[%s]"
              % (name, len(msgs), approx_tokens(msgs), v["roles"]))
        print("%-16s failed_exchange_kept=%s orphan=%s unanswered=%s"
              % ("", v["failed_exchange_kept"],
                 v["orphan_tool_results"], v["unanswered_tool_calls"]))


if __name__ == "__main__":
    demo()
drop_exchange    msgs=1 tokens=18 roles=[user]
                 failed_exchange_kept=False orphan=[] unanswered=[]
rewrite_history  msgs=1 tokens=29 roles=[user]
                 failed_exchange_kept=False orphan=[] unanswered=[]
new_user_turn    msgs=4 tokens=89 roles=[user assistant tool user]
                 failed_exchange_kept=True orphan=[] unanswered=[]

Look at the second line. Both drop_exchange and rewrite_history return empty orphan and unanswered lists -- validation "passes" -- while failed_exchange_kept=False. So do not treat a pairing check as proof of recovery capability. For production, add at least two more things: attach a structured fault_kind to the tool result (the paper found a client given the exact fault kind performed best, and it saves the model from guessing an error class out of free text), and validate state separately for silent corruption. Loud/Quiet settled that: the delivery layer cannot save you there, and final-state comparison plus external assertions are what will.

A change to message ordering alone that buys more than 10 points of success usually means a framework took something for granted. This time what it took for granted was that writing an error down is the same as delivering it.

Further reading

Comentarios

Este sitio es solo frontal: sin backend ni cuentas. Los comentarios van a GitHub Issues, Discussions o correo.

Pega esto en el issue o correo para ayudarme a localizar el problema; no incluye nada de lo que escribiste

También:Ver comentarios existentes · Comentarios por correo (sin cuenta de GitHub):278975598@qq.com