Skip to content

fix(agents): scheduled runs fail after a read or fetch error the model recovered from - #180922

Merged
obviyus merged 5 commits into
mainfrom
fix/cron-model-declared-outcome
Nov 29, 2026
Merged

obviyus merged 5 commits into
mainfrom
fix/cron-model-declared-outcome

Conversation

@obviyus

@obviyus obviyus commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

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:

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:

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.

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.

… runs

A scheduled run that hit a tool error, kept working and ended with NO_REPLY
was recorded as failed, with a synthetic tool warning as its result. Code
overrode the model's own outcome, and repeated recovered runs could trip
failure alerts, repair requests and auto-disable. Respect a deliberate
NO_REPLY in scheduled runs as in chat; aborts, runtime errors, timeouts,
denied commands and delivery failures keep their fatal paths.
@clawsweeper

clawsweeper Bot commented Oct 22, 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 gateway Gateway runtime agents Agent runtime and tooling extensions: qa-lab size: M labels Oct 22, 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. clawsweeper:intake:needs-repro 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 22, 2026
@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR lets scheduled runs finish successfully with NO_REPLY after ordinary tool errors, without requiring confirmed message-tool delivery.

Example: An hourly stock check encounters a view_image error, continues its work, and finishes with NO_REPLY.

  • Before: Cron records an error with “View Image failed” and increments the failure streak.
  • After: Cron records ok and stays silent unless a separate runtime failure applies.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The production change is focused and follows the accepted direction, but proof is limited to reported scripted-provider runs and a new mocked regression that misses the original cron distinction.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored PR is outside the ordinary contributor proof gate; its body reports real Gateway cron RPC runs with mock-openai, while inspectable code provides in-process coverage rather than captured real-model behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Preference · Worth it: Yes · Fix scope: Complete
User problem: A scheduled job that continues after a tool error and deliberately finishes silently can receive a failure result and unwanted failure handling.
Reason: The previous cron exception was intentional, so this changes outcome policy rather than restoring its original design; collaborator authorship supplies the owner decision, and the body explicitly accepts the accounting and notification consequences.

Merge readiness

✅ Ready for maintainer review

Keep open: this collaborator-authored PR makes a distinct, explicitly chosen change to cron completion policy that remains absent from main; no introduced production defect was found.

Priority: P2
Reviewed head: 3b55ef4a19bb594b89630e0d59d9f307d3aff344

Before merge

None.

Findings

None.

Tests

  • Low-value test src/cron/isolated-agent/run.meta-error-status.test.ts: Remove or replace the new “records a silent finish after a recovered tool error as successful” case: it omits the base implementation’s isCronTrigger input, so its constructed payload and mocked cron result already pass before the fix; exercise production cron terminal preparation instead.
  • Missing end-to-end proof: The supplied Gateway QA uses a scripted provider without captured output, and no real-model execution or base-red result is shown.
Agent review details

How this fits together

The embedded runner converts assistant output and tool failures into reply payloads; cron combines those payloads with structured runtime results to determine delivery, history, and failure handling.

flowchart LR
  A[Scheduled job] --> B[Agent execution]
  B --> C[Terminal reply preparation]
  C --> D[Reply payload construction]
  D --> E[Cron outcome classification]
  B --> E
  E --> F[Delivery and run history]
  E --> G[Failure handling]
Loading

Technical review

Best possible solution:

Keep the shared payload owner responsible for authored silence while preserving structured runtime failures as the scheduler’s failure authority.

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

Current-main cron preparation passes isCronTrigger=true, causing an ordinary tool error followed by NO_REPLY without confirmed delivery to produce an error payload; no target code was executed during this review.

Is this the best way to solve the issue?

Removing the exception from the existing payload owner is the smallest complete implementation of the chosen policy, and the caller updates complete the internal cutover.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Scheduled silence and delivered-report exception changes intended behavior with a stated reason (e731216: Allow scheduled reports to finish silently after confirmed visible delivery while preserving failures when delivery is unproven.)
  • Cron classifier treatment of silent replies changes intended behavior with a stated reason (e02009f: Prevent silent control replies from clearing tool failures and suppressing configured operator alerts.)
  • Conversational intentional silence keeps the original intent (9acc2f9: Respect an authored silent conversational outcome instead of replacing it with a synthetic tool warning.)
  • QA cron planner dispatch keeps the original intent (075b466: Exercise scheduled-job send-and-continue behavior through scripted provider responses; the extraction preserves existing dispatch priority.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +24, Tests -6, Docs 0, Other +145. Total +163 across 16 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 58 34 +24
Tests 8 47 53 -6
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 145 0 +145
Total 16 251 88 +163

Labels

Label changes:

No label changes.

Label justifications:

  • P2: False scheduled-run failures can trigger unnecessary alerts, repair requests, and eventual disabling, with a bounded impact on jobs that finish silently after tool errors.
  • merge-risk: 🚨 compatibility: Existing silent jobs lose the previous tool-warning failure accounting; the collaborator-authored PR explicitly accepts that behavioral change.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Provide a regression through cron terminal preparation that fails on the pinned base and passes with the change.
  • Attach redacted Gateway output showing a real model receiving a tool error, finishing with NO_REPLY, and leaving successful run history.

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 October 22, 2026, 3:29 PM ET / 19:29 UTC.

@jaxonparrott

Copy link
Copy Markdown
Contributor

Production evidence for this change, from 2026.10.7 (official image, Linux, isolated cron).

Over 14 days, one hourly isolated agentTurn job recorded 9 failed runs, and every one has this shape. I read all 9 transcripts: the final assistant message is NO_REPLY with stopReason: stop, and the run error is the synthetic warning for an earlier tool call that the model had already seen and moved past. The warnings were ⚠️ Web Fetch failed (3), ⚠️ Wait failed (3), ⚠️ Brain Observe failed (2, a plugin tool) and ⚠️ Brain Query Graph failed (1). The job itself was healthy: the next scheduled run succeeded each time.

The narrow unknown-tool exception in #181884 would not cover these, for two reasons:

  • They are executed calls, not unknown names. All of them started execution, and the model kept working for more turns afterwards.
  • Nested Code Mode calls make the error last longer. In the latest run (2026-10-30 02:36Z), the failed tool was a web_fetch nested inside a Code Mode program, recorded as openclaw.nested-tool.v1. It probed three guessed URLs and got a 404 from each. The program then completed, and the outer wait returned completed. The model ended on NO_REPLY. Because createToolErrorState clears only when the same tool name succeeds, the nested web_fetch failure outlived the successful outer call and became the run error.

These false failures also cost more than a status flag. Each one fed cron.failureAlert, which starts a repair agent turn, so 9 healthy runs paid for 9 investigations. Respecting NO_REPLY in scheduled runs, as this PR does, fixes all 9. Aborts, timeouts and provider errors stay fatal.

@jaxonparrott

Copy link
Copy Markdown
Contributor

Another 2026.10.7 data point (official image, Linux container), this time with an error the model could not have caused.

A manual run of an isolated scheduled agentTurn job got OpenClaw's own transient exec refusal, Direct shared-state reader requires current integrity admission (#177656), on one exec call. The model switched to MCP tools, finished its work, and about 40 s later ended on NO_REPLY with stopReason: stop. The run was still recorded as an error, ⚠️ Exec failed.

So the error this rule promotes isn't always the model's tool use: here it was an internal Gateway failure that the agent could neither avoid nor fix. Respecting NO_REPLY in scheduled runs, as this PR does, would have recorded the run as ok.

@abacha

abacha commented Nov 29, 2026

Copy link
Copy Markdown

Re-verified 2026-11-29 on our install, OpenClaw 2026.11.6, and on main at cb59aaa3106.

  • 2026.11.6 still carries the cron guard this PR removes: dist/payloads-D470_Isq.mjs:415 keeps !e.isCronTrigger || hasVisibleCommittedMessagingToolDeliveryEvidence(e) && hasCompletedMessagingToolDeliveryEvidence(e), and main keeps it at src/agents/embedded-agent-runner/run/payloads.ts:488.
  • A second shape hits the same guard: [Bug]: Nested Code Mode tool call caught by the guest's try/catch becomes lastToolError and fails a silent cron run (status=error, one-shot auto-disabled) #207683. A tool call made inside a Code Mode exec cell fails, the cell catches it, the turn ends on NO_REPLY, and the run is still recorded as an error (A/B on 2026.11.6 on 2026-11-28: nested web_fetch 403 → error; the same run plus one successful web_fetch → ok). Reading this diff, respectIntentionalSilence = hasIntentionalSilentFinal && !params.runAborted and the resolveCronPayloadOutcome change would cover that case too.

Question: is this PR still planned to leave draft? If yes, we will treat #207683 as covered by it and validate on the release that ships it. If not, #207683 needs its own fix in the tool-end handler.

Resolve payloads.errors.test.ts against main's summary table, take main's
mock-openai server.ts, and drop the draft's QA scenario, mock planners and the
cron regression that passed on base. Remove the last isCronTrigger test inputs.
…l failures

- hasCompletedMessagingToolDeliveryEvidence lost its only reader with the cron NO_REPLY guard.
- Docs: a job that must report tool failures should reply with the failure instead of NO_REPLY.
@obviyus
obviyus marked this pull request as ready for review November 29, 2026 04:34
@obviyus

obviyus commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator Author

Review finding accepted (local ClawSweeper round 1 on 2407d013d162):

@obviyus

obviyus commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator Author

Gateway proof: a built Gateway in secretless Docker, real isolated agentTurn cron jobs run through cron.add and cron.run, and a scripted model fixture. Each row shows the latest cron.runs entry. ce is consecutiveErrors from cron.get.

Base: origin/main ba0a7a5fac3e2f1b642d05502273b98dc75adf4f (OpenClaw 2026.11.10)
Candidate: e748a89de587 (merge of origin/main + cut), then exact PR head 2407d013d162f1bc78b50df2ba8d2ffcab9d69b9
  (e748a89 + removal of the now-unused hasCompletedMessagingToolDeliveryEvidence + one docs sentence)
Both built in a secretless node:24.22.1 container (volumes bugloop-180922-base, bugloop-180922-cand, bugloop-180922-head):
  harness/build.sh <label> <sha>  (pnpm install --frozen-lockfile && pnpm build)
Harness: proofs/180922/harness/{build.sh,run.sh,model.mjs,client.mjs}
  Built Gateway (`openclaw gateway run`), task-owned OPENCLAW_HOME/STATE_DIR/CONFIG_PATH under /w (checked),
  agent main on a scripted openai-completions fixture (mock/p180922-model, openclaw runtime), real tools.
  Operator WS client: cron.add (sessionTarget isolated, payload agentTurn, delivery none unless noted),
  cron.run {mode: force, waitTimeoutMs}, then cron.runs + cron.get.
Commands: SCENARIOS=recovered,unrecovered,deliver,normal CODEMODE=0 harness/run.sh <base|cand> plain<N>
          SCENARIOS=codemode CODEMODE=1 harness/run.sh <base|cand> cm<N>      (tools.codeMode: true)

Scenarios (model script, model.mjs):
  recovered   read(missing file) -> tool error -> write(status file) ok -> "NO_REPLY" (stopReason stop)
  codemode    exec cell: try { await read(missing) } catch { status = "handled" }; cell completes -> "NO_REPLY"
              (model saw {"status":"completed",...,"value":"input missing, handled: File not found: ..."})
  unrecovered read(missing file) -> tool error -> empty final, no reply             (control)
  deliver     visible report, delivery announce telegram:123456789, no telegram bot token (control)
  normal      write ok -> "All checks passed."                                      (control)

Observed (cron.runs latest entry; consecutiveErrors from cron.get):
  scenario     | base pass1                   | base pass2                   | cand pass1        | cand pass2
  recovered    | error "⚠️ Read failed" ce=1  | error "⚠️ Read failed" ce=1  | ok succeeded ce=0 | ok succeeded ce=0
  codemode     | error "⚠️ Read failed" ce=1  | error "⚠️ Read failed" ce=1  | ok succeeded ce=0 | ok succeeded ce=0
  unrecovered  | error "⚠️ Read failed"       | error "⚠️ Read failed"       | error "⚠️ Read failed" | error "⚠️ Read failed"
  deliver      | ok, completionStatus failed, not-delivered (Telegram bot token missing) on all four runs
  normal       | ok, completionStatus succeeded on all four runs
Run dirs: runs/base-plain1-20261129T094441 runs/base-plain2-20261129T094627 runs/base-cm1-20261129T094527
          runs/base-cm2-20261129T094648 runs/cand-plain1-20261129T094541 runs/cand-plain2-20261129T094658
          runs/cand-cm1-20261129T094601 runs/cand-cm2-20261129T094713
Note: a delivery-only failure is recorded as status ok + completionStatus failed by design (docs
automation/cron-jobs/managing-jobs.md); the control shows that stays unchanged.

Exact head 2407d013d162 (harness/run.sh head plain1|plain2|cm1|cm2):
  recovered    ok succeeded ce=0 (x2)
  codemode     ok succeeded ce=0 (x2)
  unrecovered  error "⚠️ Read failed" completionStatus failed ce=1 (x2)
  deliver      ok + completionStatus failed, not-delivered (x2)
  normal       ok succeeded (x2)
Run dirs: runs/head-plain1-20261129T101332 runs/head-plain2-20261129T101404 runs/head-cm1-20261129T101354 runs/head-cm2-20261129T101419

Pre-push (on e748a89, production identical to head except the dead helper): ocx test over 33 files (touched tests + importers
of payloads.ts/terminal-preparation.ts/cron helpers.ts): 9 Vitest shards passed. pnpm check:changed: all lanes ok except
dead-export scan; ours (hasCompletedMessagingToolDeliveryEvidence) removed in 2407d013d1; the other two entries
(AgentCommandPluginIngressOpts, clearNativeRepositorySourceModulesForTest) are untouched main files.

Restore the cron NO_REPLY guard, isCronTrigger and the delivery-evidence
helper to main. Recovery is decided in the terminal observer instead: a
read-only call that ran and failed changed nothing, so the next successful
executed call recovers it. A failed mutation, or a call blocked or denied
before it ran, still recovers only through the same tool; missing tools and
dispatch keep their rules.

A failed read followed by a successful write, or a Code Mode cell that
caught a failed nested call and completed, no longer leaves a fatal cron
warning. A failure followed by NO_REPLY and nothing else still fails.
@openclaw-barnacle openclaw-barnacle Bot added size: XS and removed docs Improvements or additions to documentation gateway Gateway runtime size: S labels Nov 29, 2026
@obviyus

obviyus commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator Author

Gateway proof for the narrowed head caea7b868c: built Gateway in secretless Docker, real isolated agentTurn cron jobs via cron.add and cron.run, scripted model fixture. This supersedes the earlier evidence comment, which covered a version that has been withdrawn.

Base: origin/main ba0a7a5fac3e2f1b642d05502273b98dc75adf4f (OpenClaw 2026.11.10), volume bugloop-180922-base
Head: caea7b868c9e9b347128c592e9f2466d9bff20b4 (pushed PR head), volume bugloop-180922-head3
Both built in a secretless node:24.22.1 container: harness/build.sh <label> <sha> (pnpm install --frozen-lockfile && pnpm build)
Harness: proofs/180922/harness/{build.sh,run.sh,model.mjs,client.mjs}
  Built Gateway (`openclaw gateway run`), task-owned OPENCLAW_HOME/STATE_DIR/CONFIG_PATH under /w (checked),
  agent main on a scripted openai-completions fixture (mock/p180922-model, openclaw runtime), real tools.
  Operator WS client: cron.add (sessionTarget isolated, payload agentTurn, delivery none),
  cron.run {mode: force, waitTimeoutMs}, then cron.runs + cron.get.
Commands: SCENARIOS=recovered,silent,missingtool,normal CODEMODE=0 harness/run.sh <base|head3> n-plain
          SCENARIOS=codemode CODEMODE=1 harness/run.sh <base|head3> n-cm        (tools.codeMode: true)
          base missing-tool control rerun: SCENARIOS=missingtool harness/run.sh base n-missing
          (the first base n-plain missingtool row is void: the fixture kept re-calling the missing tool
           until the stream guard replaced it with text; fixed by stepping that script per request)

Scenarios (model.mjs):
  recovered    read(missing file) -> tool error -> write ok -> "NO_REPLY"
  codemode     exec cell: try { await read(missing) } catch {...}; the cell completes -> "NO_REPLY"
  silent       (#116731 shape) read(missing file) -> tool error -> "NO_REPLY", nothing else
  missingtool  (#201638 control) cream_exec (no such tool) -> "NO_REPLY", nothing else
  normal       write ok -> "All checks passed."

Observed (latest cron.runs entry; ce = consecutiveErrors from cron.get):
  scenario     | main ba0a7a5fac                          | head caea7b868c
  recovered    | error "⚠️ Read failed" ce=1              | ok succeeded ce=0
  codemode     | error "⚠️ Read failed" ce=1              | ok succeeded ce=0
  silent       | error "⚠️ Read failed" ce=1              | error "⚠️ Read failed" ce=1
  missingtool  | error "⚠️ Cream Exec blocked" ce=1       | error "⚠️ Cream Exec blocked" ce=1
  normal       | ok succeeded ce=0                        | ok succeeded ce=0
Run dirs: runs/base-n-plain-20261129T102702 runs/base-n-cm-20261129T102721 runs/base-n-missing-20261129T102816

@obviyus obviyus changed the title fix(cron): scheduled runs fail after a tool error the model recovered from fix(agents): scheduled runs fail after a read-only tool error the model recovered from Nov 29, 2026
…-only

A failed call is recovered by an unrelated later success only when the
catalog's static replay fact proves the tool read-only (read, ls, web_fetch,
web_search, memory_get, sessions_*). A failed browser act, or an exec denied
after it started, keeps the same-tool rule, so neither can be cleared by a
later read.
@obviyus

obviyus commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator Author

Gateway proof for head de3a57c978: built Gateway in secretless Docker, real isolated agentTurn cron jobs via cron.add and cron.run, scripted model fixture. This supersedes the earlier evidence comments.

Base: origin/main ba0a7a5fac3e2f1b642d05502273b98dc75adf4f (OpenClaw 2026.11.10), volume bugloop-180922-base
Head: de3a57c9787d3d702044e122a8b9c3387f1ed3fd (pushed PR head), volume bugloop-180922-head4
Previous head (withdrawn): caea7b868c9e9b347128c592e9f2466d9bff20b4, volume bugloop-180922-head3
All built in a secretless node:24.22.1 container: harness/build.sh <label> <sha> (pnpm install --frozen-lockfile && pnpm build)
Harness: proofs/180922/harness/{build.sh,run.sh,model.mjs,client.mjs}
  Built Gateway (`openclaw gateway run`), task-owned OPENCLAW_HOME/STATE_DIR/CONFIG_PATH under /w (checked),
  agent main on a scripted openai-completions fixture (mock/p180922-model, openclaw runtime), real tools.
  Operator WS client: cron.add (sessionTarget isolated, payload agentTurn, delivery none),
  cron.run {mode: force, waitTimeoutMs}, then cron.runs + cron.get.
Commands: SCENARIOS=recovered,silent,missingtool,normal harness/run.sh <label> n-plain
          SCENARIOS=codemode CODEMODE=1 harness/run.sh <label> n-cm                 (tools.codeMode: true)
          SCENARIOS=browseract BROWSER=1 harness/run.sh <label> n-browser          (tools.alsoAllow [browser], toolSearch false)
          base missing-tool control: SCENARIOS=missingtool harness/run.sh base n-missing
          (the first base n-plain missingtool row is void: the fixture kept calling the missing tool until the
           stream guard replaced it with text; fixed by stepping that script per request)

Scenarios (model.mjs):
  recovered    read(missing file) -> tool error -> write ok -> "NO_REPLY"
  codemode     exec cell: try { await read(missing) } catch {...}; the cell completes -> "NO_REPLY"
  silent       (#116731 shape) read(missing file) -> tool error -> "NO_REPLY", nothing else
  missingtool  (#201638 control) cream_exec (no such tool) -> "NO_REPLY", nothing else
  browseract   (review P2) write ok -> browser act fails (no browser running) -> read ok -> "NO_REPLY"
  normal       write ok -> "All checks passed."

Observed (latest cron.runs entry; ce = consecutiveErrors from cron.get):
  scenario     | main ba0a7a5fac                    | previous head caea7b868c | head de3a57c978
  recovered    | error "⚠️ Read failed" ce=1        | ok                       | ok succeeded ce=0
  codemode     | error "⚠️ Read failed" ce=1        | ok                       | ok succeeded ce=0
  silent       | error "⚠️ Read failed" ce=1        | error                    | error "⚠️ Read failed" ce=1
  missingtool  | error "⚠️ Cream Exec blocked" ce=1 | error                    | error "⚠️ Cream Exec blocked" ce=1
  browseract   | error "⚠️ Browser failed" ce=1     | ok (the P2 regression)   | error "⚠️ Browser failed" ce=1
  normal       | ok succeeded ce=0                  | ok                       | ok succeeded ce=0
Run dirs: runs/base-n-plain-20261129T102702 runs/base-n-cm-20261129T102721 runs/base-n-missing-20261129T102816

@obviyus obviyus changed the title fix(agents): scheduled runs fail after a read-only tool error the model recovered from fix(agents): scheduled runs fail after a read or fetch error the model recovered from Nov 29, 2026
@obviyus
obviyus merged commit ee377fc into main Nov 29, 2026
135 of 136 checks passed
@obviyus
obviyus deleted the fix/cron-model-declared-outcome branch November 29, 2026 05:51
@obviyus

obviyus commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in ee377fc. Scheduled runs are no longer recorded as failed when a read or fetch call failed, the agent then did other work that succeeded, and the run ended quietly. A failed tool followed by a quiet end with no later success still records an error and alerts, and failed browser actions, sends and exec commands keep today's rule. Thanks @jaxonparrott and @abacha for the reports and re-verification; recoveries after plugin-tool or exec failures are not covered yet, as the PR notes.

vincentkoc added a commit that referenced this pull request Nov 29, 2026
* commit 'ea8cd30a48de1f42962bb95535d2e1b3b201fc36': (599 commits)
  fix(ui): show a subtle placeholder while a new chat gets its title (#207809)
  fix: remove dismissed chat suggestions without waiting (#207792)
  test(gateway): isolate publication recovery memory pressure (#207993)
  fix(workboard): let users delete an empty default board (#207909)
  fix(ui): remove Open PR from the session menu (#207808)
  feat(ui): offer Add to Home agent when Home sidebar is open (#207773)
  fix(ui): keep narrow desktop composers on desktop icon and control sizes (#207772)
  fix: remove extra space on the right of the compact iPad chat bar (#207763)
  fix: keep the task progress options button inside the Details header (#207940)
  fix(workboard): update the active list when you archive or restore a card (#207790)
  fix: move dropped sessions into their Workboard column immediately (#207787)
  fix(whatsapp): retain sender for explicit current-message reactions (#190121)
  fix: return the agent ID when agents add finishes offline (#207926)
  fix: stop sending internal steering errors to the chat (#207150)
  fix(agents): scheduled runs fail after a read or fetch error the model recovered from (#180922)
  fix: confirm recovered config edits while the Gateway is busy (#207918)
  fix: make desktop chat presence avatars slightly smaller (#207966)
  fix: list and select routed Claude models without requiring Claude CLI (#207806)
  fix(ci): check out verifier before plugin preflight reuse
  test(reply): prove channel replacement on user messages (#207813)
  ...
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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

3 participants