Skip to content

Fix heartbeat runner failure copy#82848

Merged
joshavant merged 2 commits into
mainfrom
fix/heartbeat-background-failure-copy
May 17, 2026
Merged

Fix heartbeat runner failure copy#82848
joshavant merged 2 commits into
mainfrom
fix/heartbeat-background-failure-copy

Conversation

@joshavant

Copy link
Copy Markdown
Contributor

Summary

  • Scope generic external runner failure copy so heartbeat/background runs do not tell users to reset the foreground session with /new.
  • Normalize stale generic runner-failure payloads in heartbeat delivery before sending them to the channel.
  • Add regression coverage for raw heartbeat runner failures and heartbeat delivery fallback rewriting.

Verification

  • node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-execution.test.ts src/infra/heartbeat-runner.tool-response.test.ts
  • .agents/skills/codex-review/scripts/codex-review --mode auto

Behavior addressed: heartbeat/background runner failures could surface the foreground generic failure text, including /new guidance, into the channel.
Real environment tested: Crabbox on AWS, provider aws, lease cbx_a7790d85a34e, run run_c01ca3c5129b.
Exact steps or command run after this patch: reran the original live heartbeat repro shape against the dirty branch synced into Crabbox.
Evidence after fix: fixed=true, leakedGeneric=false, delivered Discord message used the heartbeat-specific failure copy.
Observed result after fix: the heartbeat send completed with "Heartbeat check failed before it could produce an update. The main chat session remains available." and did not include /new.
What was not tested: broad GitHub CI is pending on this PR.

Fixes #82708

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels May 17, 2026
@clawsweeper

clawsweeper Bot commented May 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge.

Summary
The PR factors external runner failure copy, returns heartbeat-specific copy for heartbeat runs, rewrites stale generic heartbeat payloads at delivery, adds regression tests, and updates the changelog.

Reproducibility: yes. at source level: current main can convert an unclassified heartbeat runner error into the generic foreground failure payload, and the linked issue includes a live Discord report. I did not execute the repro in this read-only review.

Real behavior proof
Sufficient (live_output): The PR body includes after-fix Crabbox live output for the Discord heartbeat repro, including the observed heartbeat-specific copy and absence of /new.

Next step before merge
The PR has a protected maintainer label and one narrow classification finding; a maintainer or PR author should decide whether to fold that fix into this branch before merge.

Security
Cleared: The diff only changes TypeScript failure-copy handling, tests, and changelog text; no dependency, workflow, credential, or supply-chain surface is modified.

Review findings

  • [P2] Classify direct heartbeat failures as failed — src/infra/heartbeat-runner.ts:1829
Review details

Best possible solution:

Keep the PR focused on the heartbeat failure-copy fix, but classify both stale generic rewrites and direct heartbeat-specific runner-failure payloads as failed heartbeat events before merge.

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

Yes, at source level: current main can convert an unclassified heartbeat runner error into the generic foreground failure payload, and the linked issue includes a live Discord report. I did not execute the repro in this read-only review.

Is this the best way to solve the issue?

No, not quite: the copy split is in the right area, but the delivery-side failure classification only handles stale generic rewrites and misses the new direct heartbeat-specific failure path.

Full review comments:

  • [P2] Classify direct heartbeat failures as failed — src/infra/heartbeat-runner.ts:1829
    The new agent-runner path returns HEARTBEAT_EXTERNAL_RUN_FAILURE_TEXT for raw heartbeat failures before the heartbeat runner sees the payload. Because deliveredAgentRunFailure is only replacement.replaced, that normal path sends the fixed copy but still emits a sent heartbeat event with no agent-runner-failure reason. Treat the heartbeat-specific failure copy or metadata as an agent-runner failure too, and cover the full runner path.
    Confidence: 0.87

Overall correctness: patch is incorrect
Overall confidence: 0.84

Acceptance criteria:

  • node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-execution.test.ts src/infra/heartbeat-runner.tool-response.test.ts
  • .agents/skills/codex-review/scripts/codex-review --mode auto

What I checked:

  • Current main source path: Current main still defines the generic external runner failure text with /new guidance and uses it as the fallback for unclassified external runner errors before the PR changes this path. (src/auto-reply/reply/agent-runner-execution.ts:582, d887eb8dc2cc)
  • PR direct heartbeat copy path: On the PR head, buildExternalRunFailureReply returns HEARTBEAT_EXTERNAL_RUN_FAILURE_TEXT whenever isHeartbeat is set, before later generic/CLI mismatch fallbacks run. (src/auto-reply/reply/agent-runner-execution.ts:607, 0a87501f4cb5)
  • PR delivery classification gap: The heartbeat runner only sets deliveredAgentRunFailure from replacement.replaced, so an already heartbeat-specific failure payload from the new direct path is delivered with sentStatus = "sent". (src/infra/heartbeat-runner.ts:1829, 0a87501f4cb5)
  • Regression coverage shape: The new heartbeat-runner test covers a stale generic payload rewrite and expects a failed heartbeat event, while the direct raw external error test stops at runAgentTurnWithFallback and does not cover the full heartbeat runner event path. (src/infra/heartbeat-runner.tool-response.test.ts:273, 0a87501f4cb5)
  • Related canonical issue: GitHub search found the linked bug report and this PR as the matching heartbeat /new failure-copy cluster; no more canonical merged fix was found in that search result set.
  • Real behavior proof in PR body: The PR body reports a Crabbox AWS run (cbx_a7790d85a34e, run_c01ca3c5129b) where the Discord heartbeat message used heartbeat-specific failure copy and did not include /new. (0a87501f4cb5)

Likely related people:

  • steipete: Recent commits touch both heartbeat runner behavior and agent-runner fallback/failure paths, including heartbeat reply fallback binding and auto-fallback probing. (role: recent area contributor; confidence: high; commits: bea4f0d2f4b4, c8782d18ebd4, 391b4916dcf2; files: src/infra/heartbeat-runner.ts, src/auto-reply/reply/agent-runner-execution.ts)
  • zeroaltitude: Authored a recent multi-agent heartbeat cadence and session-target fix touching the central heartbeat runner area. (role: heartbeat feature contributor; confidence: medium; commits: b247b1432fc2; files: src/infra/heartbeat-runner.ts)
  • joshavant: Beyond authoring this PR, recent current-main history shows a merged fallback provenance fix in the agent-runner execution area. (role: adjacent fallback-path contributor; confidence: medium; commits: 1dac68c0bbe7; files: src/auto-reply/reply/agent-runner-execution.ts)
  • hclsys: Recent heartbeat-runner history includes pending-delivery replay behavior, adjacent to the heartbeat delivery normalization path touched here. (role: adjacent heartbeat contributor; confidence: medium; commits: 06d8cd1b230b; files: src/infra/heartbeat-runner.ts)

Remaining risk / open question:

  • Focused tests and Crabbox proof are reported in the PR body, but this read-only review did not execute tests locally.
  • The PR body says broad GitHub CI was still pending.

Codex review notes: model gpt-5.5, reasoning high; reviewed against d887eb8dc2cc.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. P2 Normal backlog priority with limited blast radius. impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. labels May 17, 2026
@joshavant
joshavant merged commit 39a9a34 into main May 17, 2026
189 of 198 checks passed
@joshavant
joshavant deleted the fix/heartbeat-background-failure-copy branch May 17, 2026 03:23
galiniliev pushed a commit to galiniliev/openclaw that referenced this pull request May 20, 2026
* fix: scope heartbeat runner failures

* chore: add heartbeat failure changelog
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 24, 2026
* fix: scope heartbeat runner failures

* chore: add heartbeat failure changelog
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 24, 2026
* fix: scope heartbeat runner failures

* chore: add heartbeat failure changelog
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 24, 2026
* fix: scope heartbeat runner failures

* chore: add heartbeat failure changelog
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* fix: scope heartbeat runner failures

* chore: add heartbeat failure changelog
galiniliev pushed a commit to galiniliev/openclaw that referenced this pull request May 25, 2026
* fix: scope heartbeat runner failures

* chore: add heartbeat failure changelog
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
* fix: scope heartbeat runner failures

* chore: add heartbeat failure changelog
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
* fix: scope heartbeat runner failures

* chore: add heartbeat failure changelog
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
* fix: scope heartbeat runner failures

* chore: add heartbeat failure changelog
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* fix: scope heartbeat runner failures

* chore: add heartbeat failure changelog
SYU8384 pushed a commit to SYU8384/openclaw that referenced this pull request Jun 3, 2026
* fix: scope heartbeat runner failures

* chore: add heartbeat failure changelog
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
* fix: scope heartbeat runner failures

* chore: add heartbeat failure changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Heartbeat/background failure can surface generic user-request error in Discord

1 participant