Skip to content

fix(agents): scheduled runs that recover from calling a missing tool are recorded failed - #201638

Merged
obviyus merged 1 commit into
mainfrom
fix/cron-recovered-tool-error
Nov 19, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/cron-recovered-tool-error

Conversation

@obviyus

@obviyus obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

A scheduled run gets marked failed even after it recovers and finishes, if its first tool call named a tool the run does not have.

Production case: a daily automation, two days in a row. The model's first call went to cream_exec, a name that does not exist (Tool cream_exec not found, executionStarted: false). It then called exec 4 to 6 times, all of which succeeded. It recorded no_change, replied NO_REPLY, and the session ended status: success. Cron history still recorded the run as error with ⚠️ Cream Exec blocked, and sent a "failed 2 times in a row" alert.

Why This Change Was Made

The terminal tool observer (src/agents/tool-terminal-outcome.ts) keeps one slot for the last failed tool call. Since #126542, that slot clears only when the same tool name later succeeds. For a real tool that is the right identity: a failed message send is not undone by a later read (#107735, #139037).

A call to a missing tool has no tool identity. The model's retry always uses a different name (exec, not cream_exec), so the slot could never clear. The rest of the chain then works as designed:

The fix is in the observer, where recovery is decided:

  • agent-core tags the "tool not found" outcome with a typed pre-execution errorKind: "unknown-tool", beside the existing "argument-validation".
  • The embedded runner and the Codex dynamic-tool bridge (Unknown OpenClaw tool / not available for this turn) carry it as unknownTool on the failure.
  • The observer treats an unknownTool failure as recovered by the next successful call that actually ran. Every other failure still recovers only through the same tool.

No warning, silence, no_change or cron payload rule changes. The bad state (a failure whose only recovery path is a name that cannot run) is no longer possible.

Accepted edge case: a model that calls a missing tool, then runs some unrelated tool successfully and ends silently without ever doing the intended work, now finishes ok. The failed call is still in the transcript and progress lane. A run that calls a missing tool and then stops still fails, as before.

User Impact

  • Scheduled runs that recover from calling a missing tool and finish their work are recorded ok, with no false failure alert.
  • A run that calls a missing tool and then gives up silently still records error with ⚠️ <tool> blocked.
  • Failures of real tools are unchanged.

Evidence

  • New regression in tool-terminal-outcome.test.ts. It drives a real Agent loop and the subscription, then builds payloads with isCronTrigger: true and runs resolveCronPayloadOutcome. Case: missing tool, then exec succeeds, then NO_REPLY.

    • Red on the production commit 5fb23152 and on the base 67aacbb6: expected [ '⚠️ Cream Exec blocked' ] to deeply equal [].
    • Green with the fix. The control (missing tool, then NO_REPLY) still warns and stays fatal on both sides.
  • Codex bridge regression in dynamic-tool-execution.test.ts: a real bridge, missing tool, then exec, through handleDynamicToolCallWithTimeout with the contract observer. The missing call carries unknownTool and executionStarted: false, and the next exec clears the failure.

  • Existing tables green: payloads.errors.test.ts (fix(agents): scheduled runs post a stale "Wait for Agents failed" warning after recovering #186652 / Respect deliberate silence after conversational read failures #151042 silence table), payloads.test.ts (fix: stop marking delivered scheduled reports as failed #152165 delivered-report cases), cron/isolated-agent/helpers.test.ts, subscribe ordering and session suites, Codex dynamic-tool-execution / event-projector.dynamic-tools, agents-wait-tool.

  • pnpm tsgo:core, pnpm check:test-types, pnpm check:baseline-ratchets, oxlint and oxfmt on the changed files: clean.

  • Real isolated Gateway (ocx src, random port, scratch state), real CronService, one-shot at job that came due on its own. Only model inference was scripted: a local Anthropic Messages server replays the production sequence (cream_exec → exec → NO_REPLY).

    Arm Model calls Session Cron history
    5fb23152 cream_exec (not found) → exec ok → NO_REPLY success error, ⚠️ Cream Exec blocked
    this PR same success ok
    this PR, no recovery cream_exec (not found) → NO_REPLY success error, ⚠️ Cream Exec blocked (unchanged)
  • A real-model attempt (Claude Opus 5.5) would not call a tool missing from its list, even when told to. It called exec directly and ended ok on base. That is why the incident sequence was scripted.

Production delta: about +40 lines on the existing observer path (one typed tag at each producer, one recovery branch). Over-cap files do not grow. Tests: +65.

A failed call is recovered only when the same tool later succeeds. A call to
a tool the run does not have never ran and has no name a retry could share,
so its failure could never clear. Scheduled runs that recovered and finished
were then recorded as failed with "⚠️ <tool> blocked".

agent-core now tags the not-found outcome as errorKind "unknown-tool"; the
embedded runner and the Codex dynamic-tool bridge carry it to the terminal
observer, which lets the next successful executed call recover it.

Co-authored-by: obviyus <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling extensions: codex size: S labels Nov 19, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR lets a successful executed tool call clear an earlier failure caused by a missing tool name.

Example: A scheduled run calls missing tool cream_exec, successfully calls exec, then returns NO_REPLY.

  • Before: Cron records error with ⚠️ Cream Exec blocked.
  • After: Cron records ok; a missing-tool call without subsequent recovery still records error.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with supplied Gateway behavior evidence and meaningful regression coverage; current CI failures remain unattributed.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The body supplies before/after results from an isolated Gateway with real CronService scheduling and scripted Anthropic inference: cream_exec → successful exec → NO_REPLY changes error to ok, while cream_exec → NO_REPLY stays error; Codex adapter propagation is separately covered by the production bridge regression.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Completed scheduled work is recorded as failed and can trigger misleading consecutive-failure alerts after the model corrects a nonexistent tool name.
Reason: The reported production sequence has a narrow, source-verified cause, and the maintainer-authored direction explicitly accepts the recovery tradeoff.

Merge readiness

✅ Ready for maintainer review

This maintainer-authored PR fixes a current false-failure path with a focused change to the shared terminal observer; no actionable correctness or security findings were identified.

Priority: P2
Reviewed head: 8f2428b806c6c1e48cb555fddf3ef12edf2794e4

Before merge

None.

Findings

None.

Agent review details

How this fits together

Agent-core and the Codex bridge report finalized tool outcomes to one attempt-scoped observer, whose retained failure feeds reply payloads and cron status.

flowchart TD
  A[Scheduled agent run] --> B[Agent core or Codex bridge]
  B --> C[Typed tool outcome]
  C --> D[Shared terminal observer]
  D --> E[Reply payload builder]
  E --> F[Cron outcome and alerts]
Loading

Technical review

Best possible solution:

Keep the typed missing-name classification at dispatch and its recovery exception in the existing shared observer.

Do we have a high-confidence way to reproduce the issue?

Pinned-main source establishes the missing-name retention-to-fatal-cron path, supported by the independent reporter's regression; this read-only review ran no target code.

Is this the best way to solve the issue?

The patch fixes the owning recovery decision with typed producer evidence rather than weakening cron silence handling or treating every pre-execution rejection as recoverable.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against a32fc09b4ce0.

Provenance checked

  • Shared failure recovery changes intended behavior with a stated reason (refactor(agents): replace tool-failure warning heuristics with a two-rule policy #126542: Replace heuristic warning recovery with one failure slot cleared by same-tool success; a later refactor inlined that policy into the observer.)
  • Codex terminal facts and response metadata keeps the original intent (aaf5d23: Prevent successful terminal tools from masking failed actions using a host-owned attempt observer; later work preserved exact side-effect evidence.)
  • Agent-core pre-execution classification keeps the original intent (d920bfc: Carry typed argument-validation rejection through existing finalized-outcome admission and accounting.)
  • Scheduled-run warning documentation keeps the original intent (98c5656: Meaningful recorded outcomes suppress stale warnings while no_change preserves failure reporting.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Josh Avant: Raw commit aaf5d23 adds src/agents/tool-terminal-outcome.ts:44 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: aaf5d23883a1; files: src/agents/tool-terminal-outcome.ts)

PR surface

Source +33, Tests +75, Docs +3. Total +111 across 12 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 9 49 16 +33
Tests 2 76 1 +75
Docs 1 4 1 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 129 18 +111

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test LOC Production +49/-16; tests +76/-1 Production growth carries one typed fact through existing owners; the regressions cover cron classification and the distinct Codex adapter boundary.

Labels

Label changes:

  • add P2: Recovered scheduled work can receive false error status and failure-streak alerts in a specific missing-tool sequence.
  • add merge-risk: 🚨 compatibility: The SDK-exposed tool-outcome contract gains an unknown-tool discriminator and optional failure metadata; the maintainer-authored repair documents the intended additive behavior and leaves existing validation and protocol fields intact.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Recovered scheduled work can receive false error status and failure-streak alerts in a specific missing-tool sequence.
  • merge-risk: 🚨 compatibility: The SDK-exposed tool-outcome contract gains an unknown-tool discriminator and optional failure metadata; the maintainer-authored repair documents the intended additive behavior and leaves existing validation and protocol fields intact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 19, 2026, 12:57 AM ET / 05:57 UTC.

@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer override: the red jobs on head 8f2428b8 are not caused by this PR.

  • checks-node-changed-compact-large-15: src/gateway/operator-run-cancellation.test.ts ("an accepted turn sent from agent:main:cron-sender / guest-and-staff keeps its authority after the occurrence retires", expected [Function] to throw at line 265). Fails identically on the merge base 67aacbb6 without this change (local ocx test, 2 failed / same assertion).
  • checks-node-changed-compact-large-31: src/gateway/server.chat-abort-initiator.product.test.ts ("binds cross-device Stop…", 90 s timeout). Times out identically on the merge base 67aacbb6.
  • checks-ui-e2e (1/2): ui/src/e2e/route-asset-requests.e2e.test.ts ("bounds plugins ready-window asset requests…", AssertionError: /assets/carapace-control-ui-…js). Fails identically on current main (cf9a9839) without this change; passes on this PR's head and on its merge base. The PR touches no ui/ files. One rerun failed the same way.
  • openclaw/ci-gate aggregates the jobs above.

Exact-head proof: real isolated Gateway cron run (ok with the fix, error on base), focused tests, and a ready local review on 8f2428b8.

@obviyus
obviyus merged commit f5958f4 into main Nov 19, 2026
205 of 214 checks passed
@obviyus
obviyus deleted the fix/cron-recovered-tool-error branch November 19, 2026 06:26
@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as f5958f4. Scheduled runs that call a missing tool and then recover through a tool that actually runs are no longer recorded as failed. Before the fix, a real isolated Gateway cron run recorded error / ⚠️ Cream Exec blocked; with it, the same run records ok. A run that calls a missing tool and then stops still fails.

RomneyDa added a commit that referenced this pull request Nov 19, 2026
…are recorded failed (#201638)

## What Problem This Solves

A scheduled run gets marked failed even after it recovers and finishes, if its first tool call named a tool the run does not have.

Production case: a daily automation, two days in a row. The model's first call went to `cream_exec`, a name that does not exist (`Tool cream_exec not found`, `executionStarted: false`). It then called `exec` 4 to 6 times, all of which succeeded. It recorded `no_change`, replied `NO_REPLY`, and the session ended `status: success`. Cron history still recorded the run as `error` with `⚠️ Cream Exec blocked`, and sent a "failed 2 times in a row" alert.

## Why This Change Was Made

The terminal tool observer (`src/agents/tool-terminal-outcome.ts`) keeps one slot for the last failed tool call. Since #126542, that slot clears only when **the same tool name** later succeeds. For a real tool that is the right identity: a failed `message` send is not undone by a later `read` (#107735, #139037).

A call to a missing tool has no tool identity. The model's retry always uses a different name (`exec`, not `cream_exec`), so the slot could never clear. The rest of the chain then works as designed:

- `payloads.ts` keeps the warning, because a scheduled run's `NO_REPLY` is not authoritative without message-tool delivery (#120056, #152165), and `no_change` is not a meaningful result (#186652).
- `resolveCronPayloadOutcome` finds an error payload with no later successful output, and `run-finalize.ts` records `error`.

The fix is in the observer, where recovery is decided:

- `agent-core` tags the "tool not found" outcome with a typed pre-execution `errorKind: "unknown-tool"`, beside the existing `"argument-validation"`.
- The embedded runner and the Codex dynamic-tool bridge (`Unknown OpenClaw tool` / `not available for this turn`) carry it as `unknownTool` on the failure.
- The observer treats an `unknownTool` failure as recovered by the next successful call that actually ran. Every other failure still recovers only through the same tool.

No warning, silence, `no_change` or cron payload rule changes. The bad state (a failure whose only recovery path is a name that cannot run) is no longer possible.

Accepted edge case: a model that calls a missing tool, then runs some unrelated tool successfully and ends silently without ever doing the intended work, now finishes `ok`. The failed call is still in the transcript and progress lane. A run that calls a missing tool and then stops still fails, as before.

## User Impact

- Scheduled runs that recover from calling a missing tool and finish their work are recorded `ok`, with no false failure alert.
- A run that calls a missing tool and then gives up silently still records `error` with `⚠️ <tool> blocked`.
- Failures of real tools are unchanged.

## Evidence

- New regression in `tool-terminal-outcome.test.ts`. It drives a real `Agent` loop and the subscription, then builds payloads with `isCronTrigger: true` and runs `resolveCronPayloadOutcome`. Case: missing tool, then `exec` succeeds, then `NO_REPLY`.
  - Red on the production commit `5fb23152` and on the base `67aacbb6`: `expected [ '⚠️ Cream Exec blocked' ] to deeply equal []`.
  - Green with the fix. The control (missing tool, then `NO_REPLY`) still warns and stays fatal on both sides.
- Codex bridge regression in `dynamic-tool-execution.test.ts`: a real bridge, missing tool, then `exec`, through `handleDynamicToolCallWithTimeout` with the contract observer. The missing call carries `unknownTool` and `executionStarted: false`, and the next `exec` clears the failure.
- Existing tables green: `payloads.errors.test.ts` (#186652 / #151042 silence table), `payloads.test.ts` (#152165 delivered-report cases), `cron/isolated-agent/helpers.test.ts`, subscribe ordering and session suites, Codex `dynamic-tool-execution` / `event-projector.dynamic-tools`, `agents-wait-tool`.
- `pnpm tsgo:core`, `pnpm check:test-types`, `pnpm check:baseline-ratchets`, oxlint and oxfmt on the changed files: clean.
- Real isolated Gateway (`ocx src`, random port, scratch state), real CronService, one-shot `at` job that came due on its own. Only model inference was scripted: a local Anthropic Messages server replays the production sequence (`cream_exec` → `exec` → `NO_REPLY`).

  | Arm | Model calls | Session | Cron history |
  | --- | --- | --- | --- |
  | `5fb23152` | `cream_exec` (not found) → `exec` ok → `NO_REPLY` | `success` | `error`, `⚠️ Cream Exec blocked` |
  | this PR | same | `success` | `ok` |
  | this PR, no recovery | `cream_exec` (not found) → `NO_REPLY` | `success` | `error`, `⚠️ Cream Exec blocked` (unchanged) |

- A real-model attempt (Claude Opus 5.5) would not call a tool missing from its list, even when told to. It called `exec` directly and ended `ok` on base. That is why the incident sequence was scripted.

Production delta: about +40 lines on the existing observer path (one typed tag at each producer, one recovery branch). Over-cap files do not grow. Tests: +65.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit f5958f4)

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
…are recorded failed (openclaw#201638)

## What Problem This Solves

A scheduled run gets marked failed even after it recovers and finishes, if its first tool call named a tool the run does not have.

Production case: a daily automation, two days in a row. The model's first call went to `cream_exec`, a name that does not exist (`Tool cream_exec not found`, `executionStarted: false`). It then called `exec` 4 to 6 times, all of which succeeded. It recorded `no_change`, replied `NO_REPLY`, and the session ended `status: success`. Cron history still recorded the run as `error` with `⚠️ Cream Exec blocked`, and sent a "failed 2 times in a row" alert.

## Why This Change Was Made

The terminal tool observer (`src/agents/tool-terminal-outcome.ts`) keeps one slot for the last failed tool call. Since openclaw#126542, that slot clears only when **the same tool name** later succeeds. For a real tool that is the right identity: a failed `message` send is not undone by a later `read` (openclaw#107735, openclaw#139037).

A call to a missing tool has no tool identity. The model's retry always uses a different name (`exec`, not `cream_exec`), so the slot could never clear. The rest of the chain then works as designed:

- `payloads.ts` keeps the warning, because a scheduled run's `NO_REPLY` is not authoritative without message-tool delivery (openclaw#120056, openclaw#152165), and `no_change` is not a meaningful result (openclaw#186652).
- `resolveCronPayloadOutcome` finds an error payload with no later successful output, and `run-finalize.ts` records `error`.

The fix is in the observer, where recovery is decided:

- `agent-core` tags the "tool not found" outcome with a typed pre-execution `errorKind: "unknown-tool"`, beside the existing `"argument-validation"`.
- The embedded runner and the Codex dynamic-tool bridge (`Unknown OpenClaw tool` / `not available for this turn`) carry it as `unknownTool` on the failure.
- The observer treats an `unknownTool` failure as recovered by the next successful call that actually ran. Every other failure still recovers only through the same tool.

No warning, silence, `no_change` or cron payload rule changes. The bad state (a failure whose only recovery path is a name that cannot run) is no longer possible.

Accepted edge case: a model that calls a missing tool, then runs some unrelated tool successfully and ends silently without ever doing the intended work, now finishes `ok`. The failed call is still in the transcript and progress lane. A run that calls a missing tool and then stops still fails, as before.

## User Impact

- Scheduled runs that recover from calling a missing tool and finish their work are recorded `ok`, with no false failure alert.
- A run that calls a missing tool and then gives up silently still records `error` with `⚠️ <tool> blocked`.
- Failures of real tools are unchanged.

## Evidence

- New regression in `tool-terminal-outcome.test.ts`. It drives a real `Agent` loop and the subscription, then builds payloads with `isCronTrigger: true` and runs `resolveCronPayloadOutcome`. Case: missing tool, then `exec` succeeds, then `NO_REPLY`.
  - Red on the production commit `30c2ded2` and on the base `78f5d6e6`: `expected [ '⚠️ Cream Exec blocked' ] to deeply equal []`.
  - Green with the fix. The control (missing tool, then `NO_REPLY`) still warns and stays fatal on both sides.
- Codex bridge regression in `dynamic-tool-execution.test.ts`: a real bridge, missing tool, then `exec`, through `handleDynamicToolCallWithTimeout` with the contract observer. The missing call carries `unknownTool` and `executionStarted: false`, and the next `exec` clears the failure.
- Existing tables green: `payloads.errors.test.ts` (openclaw#186652 / openclaw#151042 silence table), `payloads.test.ts` (openclaw#152165 delivered-report cases), `cron/isolated-agent/helpers.test.ts`, subscribe ordering and session suites, Codex `dynamic-tool-execution` / `event-projector.dynamic-tools`, `agents-wait-tool`.
- `pnpm tsgo:core`, `pnpm check:test-types`, `pnpm check:baseline-ratchets`, oxlint and oxfmt on the changed files: clean.
- Real isolated Gateway (`ocx src`, random port, scratch state), real CronService, one-shot `at` job that came due on its own. Only model inference was scripted: a local Anthropic Messages server replays the production sequence (`cream_exec` → `exec` → `NO_REPLY`).

  | Arm | Model calls | Session | Cron history |
  | --- | --- | --- | --- |
  | `30c2ded2` | `cream_exec` (not found) → `exec` ok → `NO_REPLY` | `success` | `error`, `⚠️ Cream Exec blocked` |
  | this PR | same | `success` | `ok` |
  | this PR, no recovery | `cream_exec` (not found) → `NO_REPLY` | `success` | `error`, `⚠️ Cream Exec blocked` (unchanged) |

- A real-model attempt (Claude Opus 5.5) would not call a tool missing from its list, even when told to. It called `exec` directly and ended `ok` on base. That is why the incident sequence was scripted.

Production delta: about +40 lines on the existing observer path (one typed tag at each producer, one recovery branch). Over-cap files do not grow. Tests: +65.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
…are recorded failed (openclaw#201638)

## What Problem This Solves

A scheduled run gets marked failed even after it recovers and finishes, if its first tool call named a tool the run does not have.

Production case: a daily automation, two days in a row. The model's first call went to `cream_exec`, a name that does not exist (`Tool cream_exec not found`, `executionStarted: false`). It then called `exec` 4 to 6 times, all of which succeeded. It recorded `no_change`, replied `NO_REPLY`, and the session ended `status: success`. Cron history still recorded the run as `error` with `⚠️ Cream Exec blocked`, and sent a "failed 2 times in a row" alert.

## Why This Change Was Made

The terminal tool observer (`src/agents/tool-terminal-outcome.ts`) keeps one slot for the last failed tool call. Since openclaw#126542, that slot clears only when **the same tool name** later succeeds. For a real tool that is the right identity: a failed `message` send is not undone by a later `read` (openclaw#107735, openclaw#139037).

A call to a missing tool has no tool identity. The model's retry always uses a different name (`exec`, not `cream_exec`), so the slot could never clear. The rest of the chain then works as designed:

- `payloads.ts` keeps the warning, because a scheduled run's `NO_REPLY` is not authoritative without message-tool delivery (openclaw#120056, openclaw#152165), and `no_change` is not a meaningful result (openclaw#186652).
- `resolveCronPayloadOutcome` finds an error payload with no later successful output, and `run-finalize.ts` records `error`.

The fix is in the observer, where recovery is decided:

- `agent-core` tags the "tool not found" outcome with a typed pre-execution `errorKind: "unknown-tool"`, beside the existing `"argument-validation"`.
- The embedded runner and the Codex dynamic-tool bridge (`Unknown OpenClaw tool` / `not available for this turn`) carry it as `unknownTool` on the failure.
- The observer treats an `unknownTool` failure as recovered by the next successful call that actually ran. Every other failure still recovers only through the same tool.

No warning, silence, `no_change` or cron payload rule changes. The bad state (a failure whose only recovery path is a name that cannot run) is no longer possible.

Accepted edge case: a model that calls a missing tool, then runs some unrelated tool successfully and ends silently without ever doing the intended work, now finishes `ok`. The failed call is still in the transcript and progress lane. A run that calls a missing tool and then stops still fails, as before.

## User Impact

- Scheduled runs that recover from calling a missing tool and finish their work are recorded `ok`, with no false failure alert.
- A run that calls a missing tool and then gives up silently still records `error` with `⚠️ <tool> blocked`.
- Failures of real tools are unchanged.

## Evidence

- New regression in `tool-terminal-outcome.test.ts`. It drives a real `Agent` loop and the subscription, then builds payloads with `isCronTrigger: true` and runs `resolveCronPayloadOutcome`. Case: missing tool, then `exec` succeeds, then `NO_REPLY`.
  - Red on the production commit `5fb23152` and on the base `67aacbb6`: `expected [ '⚠️ Cream Exec blocked' ] to deeply equal []`.
  - Green with the fix. The control (missing tool, then `NO_REPLY`) still warns and stays fatal on both sides.
- Codex bridge regression in `dynamic-tool-execution.test.ts`: a real bridge, missing tool, then `exec`, through `handleDynamicToolCallWithTimeout` with the contract observer. The missing call carries `unknownTool` and `executionStarted: false`, and the next `exec` clears the failure.
- Existing tables green: `payloads.errors.test.ts` (openclaw#186652 / openclaw#151042 silence table), `payloads.test.ts` (openclaw#152165 delivered-report cases), `cron/isolated-agent/helpers.test.ts`, subscribe ordering and session suites, Codex `dynamic-tool-execution` / `event-projector.dynamic-tools`, `agents-wait-tool`.
- `pnpm tsgo:core`, `pnpm check:test-types`, `pnpm check:baseline-ratchets`, oxlint and oxfmt on the changed files: clean.
- Real isolated Gateway (`ocx src`, random port, scratch state), real CronService, one-shot `at` job that came due on its own. Only model inference was scripted: a local Anthropic Messages server replays the production sequence (`cream_exec` → `exec` → `NO_REPLY`).

  | Arm | Model calls | Session | Cron history |
  | --- | --- | --- | --- |
  | `5fb23152` | `cream_exec` (not found) → `exec` ok → `NO_REPLY` | `success` | `error`, `⚠️ Cream Exec blocked` |
  | this PR | same | `success` | `ok` |
  | this PR, no recovery | `cream_exec` (not found) → `NO_REPLY` | `success` | `error`, `⚠️ Cream Exec blocked` (unchanged) |

- A real-model attempt (Claude Opus 5.5) would not call a tool missing from its list, even when told to. It called `exec` directly and ended `ok` on base. That is why the incident sequence was scripted.

Production delta: about +40 lines on the existing observer path (one typed tag at each producer, one recovery branch). Over-cap files do not grow. Tests: +65.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit f5958f4)
Release adaptation: approved 2026.11.7 models replay; see models-hook-safe-v2/REPORT.md.
Co-authored-by: RomneyDa <[email protected]>
obviyus added a commit that referenced this pull request Nov 29, 2026
…l recovered from (#180922)

Root cause: `src/agents/tool-terminal-outcome.ts:110` (main `ba0a7a5fac`). The terminal observer lets a failed tool call be recovered only by a later success of the same tool name. A run whose `read` or `web_fetch` fails, and that then does other work that succeeds, still ends holding that failure. In a cron run that ends on `NO_REPLY`, `payloads.ts:488` turns it into `⚠️ <Tool> failed` and the run is recorded as `error`.

Fixes #207683

## What Problem This Solves

A scheduled run reads or fetches something that fails, keeps working, and ends on `NO_REPLY` with `stopReason: stop`. It is still recorded as failed. That counts toward the error streak, fires failure alerts (each starts a repair turn) and auto-disables one-shot jobs.

Reports:
- @jaxonparrott, 2026.10.7: 9 of 9 failed runs of one hourly job had this shape (`Web Fetch`, `Wait`, plugin tools). The model kept working after the error, and the next run succeeded.
- @abacha, 2026.11.6 and main `cb59aaa3106`, plus #207683: a `web_fetch` inside a Code Mode `exec` cell returns 403 and the cell catches it. The outer `exec` completes and the turn ends on `NO_REPLY`, yet the run is recorded as `error` and the one-shot job is disabled. The nested failure fills the same last-tool-error slot, and the successful outer `exec` cannot clear it because it has a different name.

## Why This Change Was Made

The fix is in the observer, where recovery is already decided. Recovery by a later, different call applies only when the failed call actually ran, was not mutating, and its tool has the catalog's static replay-safe fact: `isReplaySafeToolCall(toolName, {})`, which is true for `read`, `ls`, `web_search`, `web_fetch`, `memory_get` and `sessions_*`. Such a call changed nothing, so the next successful executed call recovers it. Nothing else changes:
- A failed mutation (a send, write, edit or spawn) still recovers only through the same tool. A failed message send is not undone by a later read (#107735, #139037).
- Tools with no catalog read-only fact keep the same-tool rule. A failed browser `act` followed by a successful `read` still reports the browser failure. An `exec`, including one denied with `SYSTEM_RUN_DENIED` after it started, still keeps the cron execution-denied signal.
- A call blocked before it ran, the missing-tool rule (#201638) and the dispatch catalog-target rule are unchanged.
- The cron `NO_REPLY` guard at `payloads.ts:488` is unchanged. A tool failure followed by `NO_REPLY` with no later successful call still fails the run (#116731, #120056), and so does a missing tool followed by `NO_REPLY` (#201638).

No new field, state, config or wording.

Limits:
- The tool is classified with empty arguments. `subagents`, `session_status` and `presence` count as replay-safe when no action is given, but the stored `mutatingAction` still keeps their mutating actions. A failed `subagents wait` would be recovered, which is harmless.
- Tools that are replay-safe only for a specific instance (plugin tools, `replaySafeToolNames`) and read-only `exec` commands such as a failed `cat` keep today's same-tool rule. Recoveries from those still record `error`, as they do on main.

Non-cron chat runs: `buildFailureWarning` only adds `⚠️ <Tool> failed` when the turn has no user-facing reply. The one chat change: a turn where one of those catalog read-only calls failed, a different call then ran and succeeded, and the turn ended with no reply text at all no longer gets that warning. Turns with a visible reply or `NO_REPLY` already showed no warning and are unchanged. So are failed mutations, browser and exec failures, and blocked calls.

## User Impact

A scheduled job that recovers from a failed `read` or `web_fetch`, including one caught inside a Code Mode cell, and then ends silently now records `ok`. It no longer sends a false failure alert, starts a repair turn or disables itself. A job whose tool failed and that did nothing successful afterwards still fails and alerts.

## Evidence

Built Gateway in secretless Docker, real isolated `agentTurn` cron jobs, scripted model. Captures: [evidence comment](#180922 (comment)).

| Scenario | main `ba0a7a5fac` | this PR `de3a57c978` |
|---|---|---|
| (a) `read` fails, `write` succeeds, `NO_REPLY` | `error` `⚠️ Read failed`, consecutiveErrors 1 | `ok`, `succeeded`, 0 |
| (b) Code Mode cell catches a failed nested `read`, cell completes, `NO_REPLY` | `error` `⚠️ Read failed`, consecutiveErrors 1 | `ok`, `succeeded`, 0 |
| #116731 shape: `read` fails, `NO_REPLY`, nothing else | `error` `⚠️ Read failed` | `error` `⚠️ Read failed` |
| #201638 control: missing tool, `NO_REPLY`, nothing else | `error` `⚠️ Cream Exec blocked` | `error` `⚠️ Cream Exec blocked` |
| review regression: browser `act` fails, `read` succeeds, `NO_REPLY` | `error` `⚠️ Browser failed` | `error` `⚠️ Browser failed` |
| normal run | `ok`, `succeeded` | `ok`, `succeeded` |

New observer regressions in `tool-terminal-outcome.test.ts`:
- A failed `read` is cleared by a later successful `write` or `exec`. This fails on main.
- A failed `exec` (`SYSTEM_RUN_DENIED`, started, read-only command) and a failed browser `act` are both kept after a successful `read`. The previous head failed both.

The existing failed-send case still keeps its warning. The payload, cron, subscribe and Codex dynamic-tool suites pass. The draft's QA scenario, mock planners and extra cron test are dropped.

Production: +11/-4 in `src/agents/tool-terminal-outcome.ts` (4 code lines, the rest comment). Tests: +19/-1.

Merge danger: two-way door. No state, config or schema changes; a revert restores the old recovery rule. Blast radius: which earlier tool failure a run still reports after later successful work, in cron outcomes and the no-reply chat warning.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 29, 2026
…l recovered from (#180922)

Root cause: `src/agents/tool-terminal-outcome.ts:110` (main `ba0a7a5fac`). The terminal observer lets a failed tool call be recovered only by a later success of the same tool name. A run whose `read` or `web_fetch` fails, and that then does other work that succeeds, still ends holding that failure. In a cron run that ends on `NO_REPLY`, `payloads.ts:488` turns it into `⚠️ <Tool> failed` and the run is recorded as `error`.

Fixes #207683

## What Problem This Solves

A scheduled run reads or fetches something that fails, keeps working, and ends on `NO_REPLY` with `stopReason: stop`. It is still recorded as failed. That counts toward the error streak, fires failure alerts (each starts a repair turn) and auto-disables one-shot jobs.

Reports:
- @jaxonparrott, 2026.10.7: 9 of 9 failed runs of one hourly job had this shape (`Web Fetch`, `Wait`, plugin tools). The model kept working after the error, and the next run succeeded.
- @abacha, 2026.11.6 and main `cb59aaa3106`, plus #207683: a `web_fetch` inside a Code Mode `exec` cell returns 403 and the cell catches it. The outer `exec` completes and the turn ends on `NO_REPLY`, yet the run is recorded as `error` and the one-shot job is disabled. The nested failure fills the same last-tool-error slot, and the successful outer `exec` cannot clear it because it has a different name.

## Why This Change Was Made

The fix is in the observer, where recovery is already decided. Recovery by a later, different call applies only when the failed call actually ran, was not mutating, and its tool has the catalog's static replay-safe fact: `isReplaySafeToolCall(toolName, {})`, which is true for `read`, `ls`, `web_search`, `web_fetch`, `memory_get` and `sessions_*`. Such a call changed nothing, so the next successful executed call recovers it. Nothing else changes:
- A failed mutation (a send, write, edit or spawn) still recovers only through the same tool. A failed message send is not undone by a later read (#107735, #139037).
- Tools with no catalog read-only fact keep the same-tool rule. A failed browser `act` followed by a successful `read` still reports the browser failure. An `exec`, including one denied with `SYSTEM_RUN_DENIED` after it started, still keeps the cron execution-denied signal.
- A call blocked before it ran, the missing-tool rule (#201638) and the dispatch catalog-target rule are unchanged.
- The cron `NO_REPLY` guard at `payloads.ts:488` is unchanged. A tool failure followed by `NO_REPLY` with no later successful call still fails the run (#116731, #120056), and so does a missing tool followed by `NO_REPLY` (#201638).

No new field, state, config or wording.

Limits:
- The tool is classified with empty arguments. `subagents`, `session_status` and `presence` count as replay-safe when no action is given, but the stored `mutatingAction` still keeps their mutating actions. A failed `subagents wait` would be recovered, which is harmless.
- Tools that are replay-safe only for a specific instance (plugin tools, `replaySafeToolNames`) and read-only `exec` commands such as a failed `cat` keep today's same-tool rule. Recoveries from those still record `error`, as they do on main.

Non-cron chat runs: `buildFailureWarning` only adds `⚠️ <Tool> failed` when the turn has no user-facing reply. The one chat change: a turn where one of those catalog read-only calls failed, a different call then ran and succeeded, and the turn ended with no reply text at all no longer gets that warning. Turns with a visible reply or `NO_REPLY` already showed no warning and are unchanged. So are failed mutations, browser and exec failures, and blocked calls.

## User Impact

A scheduled job that recovers from a failed `read` or `web_fetch`, including one caught inside a Code Mode cell, and then ends silently now records `ok`. It no longer sends a false failure alert, starts a repair turn or disables itself. A job whose tool failed and that did nothing successful afterwards still fails and alerts.

## Evidence

Built Gateway in secretless Docker, real isolated `agentTurn` cron jobs, scripted model. Captures: [evidence comment](#180922 (comment)).

| Scenario | main `ba0a7a5fac` | this PR `de3a57c978` |
|---|---|---|
| (a) `read` fails, `write` succeeds, `NO_REPLY` | `error` `⚠️ Read failed`, consecutiveErrors 1 | `ok`, `succeeded`, 0 |
| (b) Code Mode cell catches a failed nested `read`, cell completes, `NO_REPLY` | `error` `⚠️ Read failed`, consecutiveErrors 1 | `ok`, `succeeded`, 0 |
| #116731 shape: `read` fails, `NO_REPLY`, nothing else | `error` `⚠️ Read failed` | `error` `⚠️ Read failed` |
| #201638 control: missing tool, `NO_REPLY`, nothing else | `error` `⚠️ Cream Exec blocked` | `error` `⚠️ Cream Exec blocked` |
| review regression: browser `act` fails, `read` succeeds, `NO_REPLY` | `error` `⚠️ Browser failed` | `error` `⚠️ Browser failed` |
| normal run | `ok`, `succeeded` | `ok`, `succeeded` |

New observer regressions in `tool-terminal-outcome.test.ts`:
- A failed `read` is cleared by a later successful `write` or `exec`. This fails on main.
- A failed `exec` (`SYSTEM_RUN_DENIED`, started, read-only command) and a failed browser `act` are both kept after a successful `read`. The previous head failed both.

The existing failed-send case still keeps its warning. The payload, cron, subscribe and Codex dynamic-tool suites pass. The draft's QA scenario, mock planners and extra cron test are dropped.

Production: +11/-4 in `src/agents/tool-terminal-outcome.ts` (4 code lines, the rest comment). Tests: +19/-1.

Merge danger: two-way door. No state, config or schema changes; a revert restores the old recovery rule. Blast radius: which earlier tool failure a run still reports after later successful work, in cron outcomes and the no-reply chat warning.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit ee377fc)

Release adaptation: Apply replay-safe later-tool recovery to the dispatch-by-target observer already backported earlier in this lane.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…l recovered from (#180922)

Root cause: `src/agents/tool-terminal-outcome.ts:110` (main `ba0a7a5fac`). The terminal observer lets a failed tool call be recovered only by a later success of the same tool name. A run whose `read` or `web_fetch` fails, and that then does other work that succeeds, still ends holding that failure. In a cron run that ends on `NO_REPLY`, `payloads.ts:488` turns it into `⚠️ <Tool> failed` and the run is recorded as `error`.

Fixes #207683

## What Problem This Solves

A scheduled run reads or fetches something that fails, keeps working, and ends on `NO_REPLY` with `stopReason: stop`. It is still recorded as failed. That counts toward the error streak, fires failure alerts (each starts a repair turn) and auto-disables one-shot jobs.

Reports:
- @jaxonparrott, 2026.10.7: 9 of 9 failed runs of one hourly job had this shape (`Web Fetch`, `Wait`, plugin tools). The model kept working after the error, and the next run succeeded.
- @abacha, 2026.11.6 and main `cb59aaa3106`, plus #207683: a `web_fetch` inside a Code Mode `exec` cell returns 403 and the cell catches it. The outer `exec` completes and the turn ends on `NO_REPLY`, yet the run is recorded as `error` and the one-shot job is disabled. The nested failure fills the same last-tool-error slot, and the successful outer `exec` cannot clear it because it has a different name.

## Why This Change Was Made

The fix is in the observer, where recovery is already decided. Recovery by a later, different call applies only when the failed call actually ran, was not mutating, and its tool has the catalog's static replay-safe fact: `isReplaySafeToolCall(toolName, {})`, which is true for `read`, `ls`, `web_search`, `web_fetch`, `memory_get` and `sessions_*`. Such a call changed nothing, so the next successful executed call recovers it. Nothing else changes:
- A failed mutation (a send, write, edit or spawn) still recovers only through the same tool. A failed message send is not undone by a later read (#107735, #139037).
- Tools with no catalog read-only fact keep the same-tool rule. A failed browser `act` followed by a successful `read` still reports the browser failure. An `exec`, including one denied with `SYSTEM_RUN_DENIED` after it started, still keeps the cron execution-denied signal.
- A call blocked before it ran, the missing-tool rule (#201638) and the dispatch catalog-target rule are unchanged.
- The cron `NO_REPLY` guard at `payloads.ts:488` is unchanged. A tool failure followed by `NO_REPLY` with no later successful call still fails the run (#116731, #120056), and so does a missing tool followed by `NO_REPLY` (#201638).

No new field, state, config or wording.

Limits:
- The tool is classified with empty arguments. `subagents`, `session_status` and `presence` count as replay-safe when no action is given, but the stored `mutatingAction` still keeps their mutating actions. A failed `subagents wait` would be recovered, which is harmless.
- Tools that are replay-safe only for a specific instance (plugin tools, `replaySafeToolNames`) and read-only `exec` commands such as a failed `cat` keep today's same-tool rule. Recoveries from those still record `error`, as they do on main.

Non-cron chat runs: `buildFailureWarning` only adds `⚠️ <Tool> failed` when the turn has no user-facing reply. The one chat change: a turn where one of those catalog read-only calls failed, a different call then ran and succeeded, and the turn ended with no reply text at all no longer gets that warning. Turns with a visible reply or `NO_REPLY` already showed no warning and are unchanged. So are failed mutations, browser and exec failures, and blocked calls.

## User Impact

A scheduled job that recovers from a failed `read` or `web_fetch`, including one caught inside a Code Mode cell, and then ends silently now records `ok`. It no longer sends a false failure alert, starts a repair turn or disables itself. A job whose tool failed and that did nothing successful afterwards still fails and alerts.

## Evidence

Built Gateway in secretless Docker, real isolated `agentTurn` cron jobs, scripted model. Captures: [evidence comment](#180922 (comment)).

| Scenario | main `ba0a7a5fac` | this PR `de3a57c978` |
|---|---|---|
| (a) `read` fails, `write` succeeds, `NO_REPLY` | `error` `⚠️ Read failed`, consecutiveErrors 1 | `ok`, `succeeded`, 0 |
| (b) Code Mode cell catches a failed nested `read`, cell completes, `NO_REPLY` | `error` `⚠️ Read failed`, consecutiveErrors 1 | `ok`, `succeeded`, 0 |
| #116731 shape: `read` fails, `NO_REPLY`, nothing else | `error` `⚠️ Read failed` | `error` `⚠️ Read failed` |
| #201638 control: missing tool, `NO_REPLY`, nothing else | `error` `⚠️ Cream Exec blocked` | `error` `⚠️ Cream Exec blocked` |
| review regression: browser `act` fails, `read` succeeds, `NO_REPLY` | `error` `⚠️ Browser failed` | `error` `⚠️ Browser failed` |
| normal run | `ok`, `succeeded` | `ok`, `succeeded` |

New observer regressions in `tool-terminal-outcome.test.ts`:
- A failed `read` is cleared by a later successful `write` or `exec`. This fails on main.
- A failed `exec` (`SYSTEM_RUN_DENIED`, started, read-only command) and a failed browser `act` are both kept after a successful `read`. The previous head failed both.

The existing failed-send case still keeps its warning. The payload, cron, subscribe and Codex dynamic-tool suites pass. The draft's QA scenario, mock planners and extra cron test are dropped.

Production: +11/-4 in `src/agents/tool-terminal-outcome.ts` (4 code lines, the rest comment). Tests: +19/-1.

Merge danger: two-way door. No state, config or schema changes; a revert restores the old recovery rule. Blast radius: which earlier tool failure a run still reports after later successful work, in cron outcomes and the no-reply chat warning.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit ee377fc)

Companion audit: No later source follow-up; retain the previously ported semantic dispatcher identity and expand only executed read-only recovery.

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 30, 2026
…l recovered from (openclaw#180922)

Root cause: `src/agents/tool-terminal-outcome.ts:110` (main `ccb01ee458`). The terminal observer lets a failed tool call be recovered only by a later success of the same tool name. A run whose `read` or `web_fetch` fails, and that then does other work that succeeds, still ends holding that failure. In a cron run that ends on `NO_REPLY`, `payloads.ts:488` turns it into `⚠️ <Tool> failed` and the run is recorded as `error`.

Fixes openclaw#207683

## What Problem This Solves

A scheduled run reads or fetches something that fails, keeps working, and ends on `NO_REPLY` with `stopReason: stop`. It is still recorded as failed. That counts toward the error streak, fires failure alerts (each starts a repair turn) and auto-disables one-shot jobs.

Reports:
- @jaxonparrott, 2026.10.7: 9 of 9 failed runs of one hourly job had this shape (`Web Fetch`, `Wait`, plugin tools). The model kept working after the error, and the next run succeeded.
- @abacha, 2026.11.6 and main `7f1f3242f09`, plus openclaw#207683: a `web_fetch` inside a Code Mode `exec` cell returns 403 and the cell catches it. The outer `exec` completes and the turn ends on `NO_REPLY`, yet the run is recorded as `error` and the one-shot job is disabled. The nested failure fills the same last-tool-error slot, and the successful outer `exec` cannot clear it because it has a different name.

## Why This Change Was Made

The fix is in the observer, where recovery is already decided. Recovery by a later, different call applies only when the failed call actually ran, was not mutating, and its tool has the catalog's static replay-safe fact: `isReplaySafeToolCall(toolName, {})`, which is true for `read`, `ls`, `web_search`, `web_fetch`, `memory_get` and `sessions_*`. Such a call changed nothing, so the next successful executed call recovers it. Nothing else changes:
- A failed mutation (a send, write, edit or spawn) still recovers only through the same tool. A failed message send is not undone by a later read (openclaw#107735, openclaw#139037).
- Tools with no catalog read-only fact keep the same-tool rule. A failed browser `act` followed by a successful `read` still reports the browser failure. An `exec`, including one denied with `SYSTEM_RUN_DENIED` after it started, still keeps the cron execution-denied signal.
- A call blocked before it ran, the missing-tool rule (openclaw#201638) and the dispatch catalog-target rule are unchanged.
- The cron `NO_REPLY` guard at `payloads.ts:488` is unchanged. A tool failure followed by `NO_REPLY` with no later successful call still fails the run (openclaw#116731, openclaw#120056), and so does a missing tool followed by `NO_REPLY` (openclaw#201638).

No new field, state, config or wording.

Limits:
- The tool is classified with empty arguments. `subagents`, `session_status` and `presence` count as replay-safe when no action is given, but the stored `mutatingAction` still keeps their mutating actions. A failed `subagents wait` would be recovered, which is harmless.
- Tools that are replay-safe only for a specific instance (plugin tools, `replaySafeToolNames`) and read-only `exec` commands such as a failed `cat` keep today's same-tool rule. Recoveries from those still record `error`, as they do on main.

Non-cron chat runs: `buildFailureWarning` only adds `⚠️ <Tool> failed` when the turn has no user-facing reply. The one chat change: a turn where one of those catalog read-only calls failed, a different call then ran and succeeded, and the turn ended with no reply text at all no longer gets that warning. Turns with a visible reply or `NO_REPLY` already showed no warning and are unchanged. So are failed mutations, browser and exec failures, and blocked calls.

## User Impact

A scheduled job that recovers from a failed `read` or `web_fetch`, including one caught inside a Code Mode cell, and then ends silently now records `ok`. It no longer sends a false failure alert, starts a repair turn or disables itself. A job whose tool failed and that did nothing successful afterwards still fails and alerts.

## Evidence

Built Gateway in secretless Docker, real isolated `agentTurn` cron jobs, scripted model. Captures: [evidence comment](openclaw#180922 (comment)).

| Scenario | main `ccb01ee458` | this PR `de3a57c978` |
|---|---|---|
| (a) `read` fails, `write` succeeds, `NO_REPLY` | `error` `⚠️ Read failed`, consecutiveErrors 1 | `ok`, `succeeded`, 0 |
| (b) Code Mode cell catches a failed nested `read`, cell completes, `NO_REPLY` | `error` `⚠️ Read failed`, consecutiveErrors 1 | `ok`, `succeeded`, 0 |
| openclaw#116731 shape: `read` fails, `NO_REPLY`, nothing else | `error` `⚠️ Read failed` | `error` `⚠️ Read failed` |
| openclaw#201638 control: missing tool, `NO_REPLY`, nothing else | `error` `⚠️ Cream Exec blocked` | `error` `⚠️ Cream Exec blocked` |
| review regression: browser `act` fails, `read` succeeds, `NO_REPLY` | `error` `⚠️ Browser failed` | `error` `⚠️ Browser failed` |
| normal run | `ok`, `succeeded` | `ok`, `succeeded` |

New observer regressions in `tool-terminal-outcome.test.ts`:
- A failed `read` is cleared by a later successful `write` or `exec`. This fails on main.
- A failed `exec` (`SYSTEM_RUN_DENIED`, started, read-only command) and a failed browser `act` are both kept after a successful `read`. The previous head failed both.

The existing failed-send case still keeps its warning. The payload, cron, subscribe and Codex dynamic-tool suites pass. The draft's QA scenario, mock planners and extra cron test are dropped.

Production: +11/-4 in `src/agents/tool-terminal-outcome.ts` (4 code lines, the rest comment). Tests: +19/-1.

Merge danger: two-way door. No state, config or schema changes; a revert restores the old recovery rule. Blast radius: which earlier tool failure a run still reports after later successful work, in cron outcomes and the no-reply chat warning.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant