Skip to content

fix(cron): preserve tool failures after silent replies - #120056

Merged
vincentkoc merged 1 commit into
openclaw:mainfrom
NarahariRaghava:fix/cron-silent-reply-clears-tool-error
Aug 23, 2026
Merged

vincentkoc merged 1 commit into
openclaw:mainfrom
NarahariRaghava:fix/cron-silent-reply-clears-tool-error

Conversation

@NarahariRaghava

@NarahariRaghava NarahariRaghava commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #116731

What Problem This Solves

Fixes an issue where cron jobs with a real tool failure could be recorded as successful when the terminal assistant reply was a silent control payload such as NO_REPLY. That reset the error streak and prevented the configured failure alert from reaching the operator.

Why This Change Was Made

The shared resolveCronPayloadOutcome classifier now removes terminal text recognized by the existing silent-reply contract before deciding whether a preceding tool warning recovered. Genuine visible terminal output still recovers tool warnings, and pure silent runs without an error remain successful.

This stays inside the classifier owner boundary. It does not change scheduler lifecycle, persistence policy or schema, configuration, provider behavior, WSL detection, or error-text matching.

Production LOC: +6/-6 (net 0) | Tests: +150/-2

User Impact

Recurring cron tool failures followed only by a silent reply now persist as errors, increment consecutiveErrors, and trigger failureAlert at the configured threshold. Operators see the existing alert text and retained tool error instead of a false successful run.

Release-note context: cron failure alerts now remain active when a tool error is followed by a silent assistant reply.

Evidence

  • Current-main red on 8578b8f55cf77ddb161891b662a02f8c8c2a80ba: 6 expected failures reproduced the bug across the classifier, real run finalization, and SQLite-backed CronService path.
  • Rewritten-head green: 148 assertions passed across src/auto-reply/tokens.test.ts and the three focused cron files.
  • Silent forms covered: canonical token, JSON string, action envelope, and reasoning-prefixed token.
  • Controls covered: genuine visible recovery remains successful; a pure silent run without an error remains successful.
  • CronService proof reads the persisted SQLite-backed store and verifies lastRunStatus: error, the original Bash error, consecutiveErrors: 1, a failure-alert timestamp, and Automation "mount check" failed 1 times.
  • Exact-head hosted CI on c6cb9436241d9b559e76d26fc11b7a5782ab7ff3: 211 successful checks, 44 skipped, one neutral, zero pending, and zero failures.
  • Exact-head Blacksmith Testbox changed gate passed before the conflict-free rebase: tbx_01m0qmfzsj51qf7ere72176b00 (Actions run).
  • Real isolated cron proof passed before the conflict-free rebase on 3beafccff71605825974b0d9f0faf415f03fe396: tbx_01m0qnzgabxs04m3wqs25g4evn (Actions run).
    • Started the real gateway and CronService with an isolated cron job.
    • The agent performed a real read tool call against a missing fixture, received the tool failure, and then emitted terminal NO_REPLY.
    • Run history recorded status: error and retained the tool-error summary.
    • SQLite-backed state recorded lastRunStatus: error, the retained tool error, consecutiveErrors: 1, and lastFailureAlertAtMs.
    • The configured webhook received Automation "mount check" failed 1 times with the retained read failure.
  • Rebasing onto current main produced head c6cb9436241d9b559e76d26fc11b7a5782ab7ff3 with no conflicts and the same stable patch ID, 7d7aa5a7fdc1f1b66d4cf04b8ea4d4d048221003. No commits between the old base and the rebase target touched the changed cron/token surfaces.
  • Fresh exact-head max-P1 autoreview: no actionable findings; patch correct with 0.94 confidence.
  • git diff --check and targeted formatting passed.

Punchcard-Session: brisk-valley-timber-85

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 12:51 PM ET / 16:51 UTC.

ClawSweeper review

What this changes

The PR makes cron preserve a preceding tool failure when the final assistant reply is a silent control payload, so the run remains an error and configured alerts fire.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No blocking findings. Current main still treats a normalized NO_REPLY as recovery from a tool warning; this PR corrects that classifier boundary and carries focused classifier, runner, persistence, and alert coverage.

Priority: P1
Reviewed head: c6cb9436241d9b559e76d26fc11b7a5782ab7ff3

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-boundary repair with strong persisted operator-outcome proof and no actionable review findings.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The linked isolated cron proof exercises a real missing-file read followed by NO_REPLY and records after-fix persisted error state plus the configured failure-alert webhook.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The linked isolated cron proof exercises a real missing-file read followed by NO_REPLY and records after-fix persisted error state plus the configured failure-alert webhook.
Evidence reviewed 6 items Current-main defect: Current main normalizes final assistant text and treats any nonempty value as recovering terminal output, so NO_REPLY can clear a preceding tool warning.
Owner-boundary repair: The PR filters the established silent-payload contract before all recovery decisions, leaving visible final text and successful payload recovery unchanged.
Canonical silent-reply contract: The existing classifier recognizes token-only, JSON-envelope, and reasoning-prefixed silent payload forms, matching the forms covered by this PR.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/cron/service.failure-alert-silent-reply.test.ts

Result: FAIL (partial) — step 2 expect_output CronService silent failure alerts: expected terminal output was not visible within 30 seconds: "CronService silent failure alerts"

node scripts/run-vitest.mjs src/cron/service.failure-alert-silent-reply.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-120056-kiFAwi/target$ node scripts/run-vitest.mjs src/cron/service.failure-alert-silent-reply.test.ts
node scripts/run-vitest.mjs src/cron/service.failure-alert-silent-reply.test.ts
[test] starting test/vitest/vitest.cron.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-120056-kiFAwi/target

 ✓  cron  src/cron/service.failure-alert-silent-reply.test.ts (1 test) 5358ms
     ✓ persists a tool failure and emits the configured operator alert  5355ms

 Test Files  1 passed (1)
      Tests  1 passed (1)
   Start at  16:52:23
   Duration  18.11s (transform 12.78s, setup 971ms, import 11.41s, tests 5.36s, environment 0ms)

[test] passed 1 Vitest shard in 24.24s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-120056-kiFAwi/target$ node scripts/run-vitest.mjs src/cron/service.failure-alert-silent-reply.test.ts
[test] starting test/vitest/vitest.cron.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-120056-kiFAwi/target































Assertions:

  • FAIL expect_output: CronService silent failure alerts
  • FAIL expect_output: persists a tool failure and emits the configured operator alert

How this fits together

Cron converts agent payloads and final reply text into a terminal run outcome. CronService persists that outcome and uses the error streak to decide whether to notify the operator.

flowchart LR
  A[Tool payloads] --> C[Cron outcome classifier]
  B[Final assistant reply] --> C
  C --> D[Terminal run status]
  D --> E[Persisted cron state]
  E --> F[Failure alert]
Loading

Before merge

  • Complete next step (P2) - No repair lane is needed: the current branch already contains the focused fix and only ordinary maintainer merge handling remains.
Agent review details

Security

None.

PR surface

Source 0, Tests +148. Total +148 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 6 0
Tests 3 150 2 +148
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 156 8 +148

Review metrics

Metric Value Why it matters
Production versus test delta production +6/−6 (net 0); tests +150/−2 The correction is absorbed into the existing classifier while coverage spans its direct contract, run finalization, and persisted alert behavior.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #116731
Summary: This PR is the active candidate fix for the cron failure-alert issue; an earlier similar PR was closed unmerged as superseded.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Land the classifier-boundary fix with its regression coverage so only substantive completion output can recover a cron tool warning.

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

Yes. Current-main source makes any nonempty final text recovery evidence, and the supplied pre-fix focused run reports the silent-reply error path failing before this change.

Is this the best way to solve the issue?

Yes. Filtering the canonical silent-reply representation at the shared outcome classifier fixes both interim and final consumers without adding scheduler, persistence, or configuration branches.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8deb9106631e.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P1: A real cron tool failure can otherwise be recorded as successful and suppress the configured operator failure alert.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The linked isolated cron proof exercises a real missing-file read followed by NO_REPLY and records after-fix persisted error state plus the configured failure-alert webhook.
  • proof: sufficient: Contributor real behavior proof is sufficient. The linked isolated cron proof exercises a real missing-file read followed by NO_REPLY and records after-fix persisted error state plus the configured failure-alert webhook.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Current-main blame attributes the recovery predicate to his recent classifier maintenance, and history shows repeated ownership of this cron path. (role: recent cron classifier maintainer; confidence: high; commits: 9b9afc3fda66, 05e534eae5f7; files: src/cron/isolated-agent/helpers.ts, src/cron/isolated-agent/run-finalize.ts)
  • scoootscooob: History identifies the earlier cron recovery behavior change as part of the feature lineage this fix narrows. (role: tool-warning recovery contributor; confidence: medium; commits: f5eafc151554; files: src/cron/isolated-agent/helpers.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-15T19:44:25.427Z sha 95ae999fe6da970c11c6674b3ff5fa390028786a :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-15T20:03:56.421Z sha d8d8b54c1d432895b68647cc4abb1215aa18a53c :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-15T21:54:22.684Z sha d8d8b54c1d432895b68647cc4abb1215aa18a53c :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-15T22:58:40.928Z sha d8d8b54c1d432895b68647cc4abb1215aa18a53c :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-19T23:11:55.998Z sha d8d8b54c1d432895b68647cc4abb1215aa18a53c :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-23T15:25:44.635Z sha 3beafccff71605825974b0d9f0faf415f03fe396 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-23T16:23:08.096Z sha 3beafccff71605825974b0d9f0faf415f03fe396 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-23T16:41:23.895Z sha c6cb943 :: needs maintainer review before merge. :: none

@NarahariRaghava

Copy link
Copy Markdown
Contributor Author

Boundary proof added

run.meta-error-status.test.ts now includes a test that uses the real resolveCronPayloadOutcome (via vi.importActual) for both the interim call in run-executor.ts and the finalize call in run-finalize.ts. It feeds an exec error payload with finalAssistantVisibleText: "NO_REPLY" and asserts status: error with the Bash error text in result.error the full pipeline, no harness stub absorbing the classification.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Aug 10, 2026
@NarahariRaghava
NarahariRaghava force-pushed the fix/cron-silent-reply-clears-tool-error branch from c4ab223 to 95ae999 Compare August 15, 2026 19:38
@NarahariRaghava

Copy link
Copy Markdown
Contributor Author

Real behavior proof: deterministic test + live investigation

Deterministic real-behavior test: Added
src/cron/cron-failure-alert-silent-reply.e2e.test.ts, which runs a real
CronService against a real on-disk store with the real (unmocked)
resolveCronPayloadOutcome classifier — only the embedded-agent call is
mocked. It proves the durable, operator-visible effect: after an exec tool
failure followed by a NO_REPLY reply, consecutiveErrors becomes 1,
lastRunStatus is persisted as "error", lastError contains the real
tool error text, and sendCronFailureAlert actually fires. Verified this
test fails against the pre-fix classifier (consecutiveErrors stays 0,
no alert) and passes with the fix restored. Screenshot of this test passing
attached below.

Live model investigation: I stood up a real, isolated dev gateway (fresh
state dir, free port — my live gateway was never touched) wired to a real
authenticated claude-cli (Claude Sonnet 4.6) session, and drove real cron
jobs against it end-to-end, specifically trying to get a live, unmocked
reproduction of the exact tool-failure + NO_REPLY scenario.

Confirmed genuinely live, piece by piece:

  • The isolated cron pipeline works end-to-end against a real model (a
    whoami cron task returned the real shell username, proving genuine tool
    execution and genuine model output through the real gateway/cron/exec
    path).
  • The model reliably produces a literal NO_REPLY final reply when a job's
    standing convention calls for it (confirmed across multiple live runs).
  • Real Bash/exec tool failures go through the same exec path exercised
    throughout the existing test suite.

What I could not get in one single live turn: a real tool failure and an
enforced-silent NO_REPLY reply, together, from an honestly-prompted model.
Across 11 live attempts with varied phrasing, the model either (a) flagged
the message as a prompt-injection attempt whenever the framing paired "run
this command" with "then say nothing about it" — correctly, since that
combination is a textbook injection pattern — or (b) predicted the turn
would end in NO_REPLY and skipped the tool call entirely before any
failure could occur, even when the check's outcome was genuinely
unpredictable to the model. I also confirmed --script cron payloads use a
separate executor (executeScriptCronJob) that never reaches
resolveCronPayloadOutcome, so that path can't exercise this fix either.

I read this as a real, positive property of the model's alignment rather
than a gap in the fix: reproducing the original bug's exact shape live
requires eliciting the same silent-swallow behavior the bug report is
about, and a well-aligned model resists being told to do that in the same
breath as running an arbitrary command.

Given the deterministic e2e test plus this piece-by-piece live confirmation,
I believe this represents the strongest good-faith proof available for this
fix without either fabricating a reproduction or spending further live model
calls chasing a combination the model's own safety training resists
producing. Open to guidance on what would move this forward from here.
Screenshot 2026-08-15 at 4 40 26 PM

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Aug 15, 2026
@vincentkoc
vincentkoc force-pushed the fix/cron-silent-reply-clears-tool-error branch from d8d8b54 to 3beafcc Compare August 23, 2026 15:19
@vincentkoc vincentkoc changed the title fix(cron): treat NO_REPLY as absent when classifying tool failure rec… fix(cron): preserve tool failures after silent replies Aug 23, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. label Aug 23, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

Exact-head real isolated cron proof is now in the PR body. It covers a real missing-file read failure followed by terminal NO_REPLY, persisted SQLite error state and failure streak, and the configured operator webhook alert.

@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 23, 2026
@clawsweeper clawsweeper Bot added 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 proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Aug 23, 2026
Closes openclaw#116731

Punchcard-Session: brisk-valley-timber-85
@vincentkoc
vincentkoc force-pushed the fix/cron-silent-reply-clears-tool-error branch from 3beafcc to c6cb943 Compare August 23, 2026 16:33
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

The required conflict-free rebase is complete at c6cb9436241d9b559e76d26fc11b7a5782ab7ff3, the stable patch ID is unchanged, and exact-head hosted CI is green with zero failures. The scrubbed real isolated cron proof remains documented in the PR body.

@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 23, 2026
@vincentkoc
vincentkoc merged commit e02009f into openclaw:main Aug 23, 2026
267 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 24, 2026
obviyus 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]>
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

P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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.

Cron failureAlert silently swallowed by quiet exits and misses WSL2 drvfs mount failure

2 participants