Return Less, Reconcile More: Tool Results, Retry Classes, and Parallel Fan-Out That Survive Production

  created  by  Sherlock {{tag}}
创建于 2026年10月19日 09:48:53 最后修改于 2026年10月19日 09:48:53

Most agent postmortems do not start with “the model was dumb.” They start with “we trusted a timeout,” “we pasted the whole log into context,” or “two writes raced because the model asked for both at once.”

This essay is not a translation of a Chinese checklist and not another hymn to least privilege—though you still need least privilege.

It is a field guide for three controls that show up the moment agents leave the demo: bounded tool results, typed failure recovery, and deliberate parallel fan-out.


The thesis is simple: the model proposes calls; your runtime must keep a ledger of effects and a diet for context.

Scene: the double charge


图:可安全重试 vs 必须先对账

图:可安全重试 vs 必须先对账

An agent calls create_invoice. The HTTP client times out at thirty seconds. The model, trying to be helpful, calls again with the same arguments. Finance later finds two invoices. Everyone agrees idempotency keys would have helped.


The deeper failure is conceptual: a timeout is not a Boolean failure. It is an unknown.

Production runtimes should distinguish:

  • definitely not applied
  • definitely applied (receipt lost)
  • partially applied
  • still running


Only the first class is safe to retry as a new attempt. The others require reconcile-then-report: query by your application operation ID, then feed the recovered result back under the original tool-call correlation. If you cannot reconcile, escalate.


Do not let eloquence improvise a second write.

1) Normalize results: context is not a landfill


图:决策摘要 · 句柄 · 完整证据

图:决策摘要 · 句柄 · 完整证据

Raw APIs return pagination tokens, unused fields, binary blobs, and novels of logs. Models pay for every token you stuff back into the transcript—and then reason worse.


Adopt a three-layer return contract:

  1. Decision summary for the model: the minimum structured fields needed for the next choice.
  2. Handle for the model: a cursor, artifact ID, or fetch tool to pull more on demand.
  3. Full evidence for your store/trace: audit-grade payload that never becomes prompt by default.


Pathrule’s production pattern states this cleanly: keep outputs small; truncate with a pointer. AI Stack Current’s rule is sharper: never make model context the system of record.

Currai adds the product lesson: never announce success before the tool result confirms it.


Practical defaults that teams actually keep:

  • Enforce max_tool_result_chars in the harness, not in the prompt.
  • On overflow, return { ok: true, truncated: true, summary, next_cursor }.
  • Treat search pages, ticket comments, and file bodies as untrusted data—delimited, never allowed to raise privileges or budgets.
  • Add eval cases where the golden path is “summarize, then fetch slice,” not “ingest everything.”


If your agent gets “smarter” after you delete logging noise from tool results, you did not find a new model. You found a diet.

2) Classify failures before you retry


Blind retries turn recoverable errors into expensive loops. Classify first:


Class Examples Runtime action
Retryable rate limit, transient network bounded backoff + jitter
Correctable schema mismatch, missing field return structured error; let model repair once or twice
Terminal auth denial, not found, business reject stop that path; replan or escalate
Unknown effect timeout after write reconcile; do not replay


Openlayer’s guidance matches what incident channels teach: per-call retry budgets (often two or three) plus a session-level token/money ceiling. Exhaustion should trigger task-level replan, not another identical tool hammer.

Retries and replans are different recovery strategies; conflating them produces agents that spin politely.

Idempotency sits beside classification, not instead of it. Generate a stable operation key for payments, messages, bookings, and deploys. Persist it with the external transaction when the vendor allows. On ambiguous writes, status query before replay.


Return already_completed explicitly so the model can proceed without inventing a second world.

3) Parallel fan-out is a dependency graph with a budget


图:只读扇出 · 写路径 · 观测

图:只读扇出 · 写路径 · 观测

Models will request multiple tools in one turn. Product surfaces increasingly show parallel sub-agents with progress panes. Engineers still need a graph:


  • Parallelize independent reads.
  • Serialize anything whose arguments depend on prior results.
  • Forbid concurrent writes to the same resource unless your domain truly has merge semantics.


When merging results, correlate by call ID. Partial failure is normal: return structured per-call outcomes, not one flattened exception that erases the successes. Give each child a wall-clock timeout and count it against the parent budget.

Stall detection—identical consecutive calls, no state change, repeated identical error codes—should stop the run with a reason the caller can branch on.

Delegation follows the same economics. A sub-agent that explores for twenty steps should return a summary, not its entire chain of thought. Otherwise parallel speedups are erased by context taxes.


Streaming adds one non-negotiable rule from current tool-calling engineering: never execute a partial streamed call. Assemble name, ID, and full arguments; wait for the provider completion boundary; then parse, authorize, and run.

Parallelism does not license half-JSON side effects.

4) Observe three timelines, not one chat


A usable trace answers three questions that chat history cannot:


  1. What did the model request?
  2. What did the runtime permit or pend?
  3. What effect did the external system actually show?


When those disagree, the external effect wins.

Log—subject to privacy—tool version, grant ID, idempotency key reference, validation results, pending state transitions, retry reasons, and terminal stop causes (step_limit, budget, stall, unknown_effect, success).

Evaluate trajectories, not just final sentences: wrong tool, skipped tool, bad args, bad ordering, and false success announcements should all fail the suite.


Closing stance


Capability will keep getting cheaper. Unknowns will not.

The teams that ship durable agents will look boring in demos and strict in code review: small tool returns, typed retries, reconcile-on-timeout, and parallel execution that respects both dependency and budget. Return less to the model.

Reconcile more with the world. That is the harness. Everything else is autocomplete with confidence.


Worked micro-example: search, then act


Bad loop:

  1. search_docs returns 40KB of markdown.
  2. Model “summarizes” poorly, misses the canonical runbook.
  3. restart_service fires on the wrong cluster.
  4. Timeout → second restart.


Better loop:

  1. search_docs returns { hits: [{id, title, score}], next_cursor } capped at N.
  2. fetch_doc(id) returns a bounded section with hash.
  3. Approval token bound to {action: restart, cluster: X, doc_hash}.
  4. restart_service creates operationId first; on timeout, get_operation(operationId) reconciles.
  5. Trace shows request ≠ pending ≠ effect until effect is verified.


The model still looks clever in the UI. The harness does the adult work.


Parallel fan-out patterns that hold up


Map-reduce reads. Fan out get_metrics(region) across regions; reduce with a deterministic aggregator in code; give the model the aggregate plus anomalies only. Do not ask the model to be your distributed join engine unless you enjoy nondeterministic invoices.

Speculative reads, conservative writes. Parallelize reconnaissance. Keep mutation single-threaded per resource key. If the product insists on parallel agents for speed, isolate them by resource partition and merge through an application-owned lock or queue.

Budget inheritance. Parent run has 120 seconds and $0.50. Three children do not each get 120 and $0.50. They inherit a slice.


When a child hits its wall clock, return a structured timeout to the parent; let the parent decide whether the goal is still reachable.

Stall as a first-class stop cause. Identical consecutive calls, zero state delta, or the same terminal business error thrice should end the run with reason=stall. Operators can page on that better than on “the agent seemed stuck.”

Retry vs replan: make the difference visible in code


on_tool_result(result): if result.code in RETRYABLE and attempts < call_budget: schedule_retry(backoff) elif result.code in CORRECTABLE and repairs < repair_budget: return result_to_model # model may fix args elif result.state == outcome_unknown: reconcile(operation_id) # never blind replay else: replan_or_escalate()


Keep these branches out of the prompt.

Prompts describe goals; code defines physics. When product asks “can the model just decide to retry?”, answer: it can propose; the ledger decides.

What to measure this quarter


  • Duplicate side-effect rate per 1,000 write calls
  • Median and p95 tool-result characters returned to the model
  • Share of runs stopped by stall / budget / unknown_effect
  • False success announcements (assistant claimed done; effect missing)
  • Cost per successful task, not tokens per vibe


If duplicate side effects trend down while task success holds, your harness is learning. If costs fall only because you silently shortened max steps into failure, you are gaming the dashboard.


Closing addition


Enterprise agent marketing will keep showing parallel progress bars and always-on coworkers. Your job is to remember what those bars hide: uncertain writes, overweight context, and fan-out that can spend like an incident. Return less. Reconcile more.

Classify before retry. Parallelize only what cannot hurt itself. That is how tool-calling loops become products instead of anecdotes.

References


评论区
评论
{{comment.creator}}
{{comment.createTime}} {{comment.index}}楼
评论

Return Less, Reconcile More: Tool Results, Retry Classes, and Parallel Fan-Out That Survive Production

Return Less, Reconcile More: Tool Results, Retry Classes, and Parallel Fan-Out That Survive Production

Most agent postmortems do not start with “the model was dumb.” They start with “we trusted a timeout,” “we pasted the whole log into context,” or “two writes raced because the model asked for both at once.”

This essay is not a translation of a Chinese checklist and not another hymn to least privilege—though you still need least privilege.

It is a field guide for three controls that show up the moment agents leave the demo: bounded tool results, typed failure recovery, and deliberate parallel fan-out.


The thesis is simple: the model proposes calls; your runtime must keep a ledger of effects and a diet for context.

Scene: the double charge


图:可安全重试 vs 必须先对账

图:可安全重试 vs 必须先对账

An agent calls create_invoice. The HTTP client times out at thirty seconds. The model, trying to be helpful, calls again with the same arguments. Finance later finds two invoices. Everyone agrees idempotency keys would have helped.


The deeper failure is conceptual: a timeout is not a Boolean failure. It is an unknown.

Production runtimes should distinguish:


Only the first class is safe to retry as a new attempt. The others require reconcile-then-report: query by your application operation ID, then feed the recovered result back under the original tool-call correlation. If you cannot reconcile, escalate.


Do not let eloquence improvise a second write.

1) Normalize results: context is not a landfill


图:决策摘要 · 句柄 · 完整证据

图:决策摘要 · 句柄 · 完整证据

Raw APIs return pagination tokens, unused fields, binary blobs, and novels of logs. Models pay for every token you stuff back into the transcript—and then reason worse.


Adopt a three-layer return contract:

  1. Decision summary for the model: the minimum structured fields needed for the next choice.
  2. Handle for the model: a cursor, artifact ID, or fetch tool to pull more on demand.
  3. Full evidence for your store/trace: audit-grade payload that never becomes prompt by default.


Pathrule’s production pattern states this cleanly: keep outputs small; truncate with a pointer. AI Stack Current’s rule is sharper: never make model context the system of record.

Currai adds the product lesson: never announce success before the tool result confirms it.


Practical defaults that teams actually keep:


If your agent gets “smarter” after you delete logging noise from tool results, you did not find a new model. You found a diet.

2) Classify failures before you retry


Blind retries turn recoverable errors into expensive loops. Classify first:


Class Examples Runtime action
Retryable rate limit, transient network bounded backoff + jitter
Correctable schema mismatch, missing field return structured error; let model repair once or twice
Terminal auth denial, not found, business reject stop that path; replan or escalate
Unknown effect timeout after write reconcile; do not replay


Openlayer’s guidance matches what incident channels teach: per-call retry budgets (often two or three) plus a session-level token/money ceiling. Exhaustion should trigger task-level replan, not another identical tool hammer.

Retries and replans are different recovery strategies; conflating them produces agents that spin politely.

Idempotency sits beside classification, not instead of it. Generate a stable operation key for payments, messages, bookings, and deploys. Persist it with the external transaction when the vendor allows. On ambiguous writes, status query before replay.


Return already_completed explicitly so the model can proceed without inventing a second world.

3) Parallel fan-out is a dependency graph with a budget


图:只读扇出 · 写路径 · 观测

图:只读扇出 · 写路径 · 观测

Models will request multiple tools in one turn. Product surfaces increasingly show parallel sub-agents with progress panes. Engineers still need a graph:



When merging results, correlate by call ID. Partial failure is normal: return structured per-call outcomes, not one flattened exception that erases the successes. Give each child a wall-clock timeout and count it against the parent budget.

Stall detection—identical consecutive calls, no state change, repeated identical error codes—should stop the run with a reason the caller can branch on.

Delegation follows the same economics. A sub-agent that explores for twenty steps should return a summary, not its entire chain of thought. Otherwise parallel speedups are erased by context taxes.


Streaming adds one non-negotiable rule from current tool-calling engineering: never execute a partial streamed call. Assemble name, ID, and full arguments; wait for the provider completion boundary; then parse, authorize, and run.

Parallelism does not license half-JSON side effects.

4) Observe three timelines, not one chat


A usable trace answers three questions that chat history cannot:


  1. What did the model request?
  2. What did the runtime permit or pend?
  3. What effect did the external system actually show?


When those disagree, the external effect wins.

Log—subject to privacy—tool version, grant ID, idempotency key reference, validation results, pending state transitions, retry reasons, and terminal stop causes (step_limit, budget, stall, unknown_effect, success).

Evaluate trajectories, not just final sentences: wrong tool, skipped tool, bad args, bad ordering, and false success announcements should all fail the suite.


Closing stance


Capability will keep getting cheaper. Unknowns will not.

The teams that ship durable agents will look boring in demos and strict in code review: small tool returns, typed retries, reconcile-on-timeout, and parallel execution that respects both dependency and budget. Return less to the model.

Reconcile more with the world. That is the harness. Everything else is autocomplete with confidence.


Worked micro-example: search, then act


Bad loop:

  1. search_docs returns 40KB of markdown.
  2. Model “summarizes” poorly, misses the canonical runbook.
  3. restart_service fires on the wrong cluster.
  4. Timeout → second restart.


Better loop:

  1. search_docs returns { hits: [{id, title, score}], next_cursor } capped at N.
  2. fetch_doc(id) returns a bounded section with hash.
  3. Approval token bound to {action: restart, cluster: X, doc_hash}.
  4. restart_service creates operationId first; on timeout, get_operation(operationId) reconciles.
  5. Trace shows request ≠ pending ≠ effect until effect is verified.


The model still looks clever in the UI. The harness does the adult work.


Parallel fan-out patterns that hold up


Map-reduce reads. Fan out get_metrics(region) across regions; reduce with a deterministic aggregator in code; give the model the aggregate plus anomalies only. Do not ask the model to be your distributed join engine unless you enjoy nondeterministic invoices.

Speculative reads, conservative writes. Parallelize reconnaissance. Keep mutation single-threaded per resource key. If the product insists on parallel agents for speed, isolate them by resource partition and merge through an application-owned lock or queue.

Budget inheritance. Parent run has 120 seconds and $0.50. Three children do not each get 120 and $0.50. They inherit a slice.


When a child hits its wall clock, return a structured timeout to the parent; let the parent decide whether the goal is still reachable.

Stall as a first-class stop cause. Identical consecutive calls, zero state delta, or the same terminal business error thrice should end the run with reason=stall. Operators can page on that better than on “the agent seemed stuck.”

Retry vs replan: make the difference visible in code


on_tool_result(result): if result.code in RETRYABLE and attempts < call_budget: schedule_retry(backoff) elif result.code in CORRECTABLE and repairs < repair_budget: return result_to_model # model may fix args elif result.state == outcome_unknown: reconcile(operation_id) # never blind replay else: replan_or_escalate()


Keep these branches out of the prompt.

Prompts describe goals; code defines physics. When product asks “can the model just decide to retry?”, answer: it can propose; the ledger decides.

What to measure this quarter



If duplicate side effects trend down while task success holds, your harness is learning. If costs fall only because you silently shortened max steps into failure, you are gaming the dashboard.


Closing addition


Enterprise agent marketing will keep showing parallel progress bars and always-on coworkers. Your job is to remember what those bars hide: uncertain writes, overweight context, and fan-out that can spend like an incident. Return less. Reconcile more.

Classify before retry. Parallelize only what cannot hurt itself. That is how tool-calling loops become products instead of anecdotes.

References



Return Less, Reconcile More: Tool Results, Retry Classes, and Parallel Fan-Out That Survive Production2026-10-19Sherlock

{{commentTitle}}

评论   ctrl+Enter 发送评论