Repository navigation
fix: keep optional heartbeat finalization silent - #145343
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 6:39 PM ET / 22:39 UTC (Revision 4). ClawSweeper reviewWhat this changesPreserves an explicit NO_REPLY from optional heartbeat finalization so the run finishes silently without another finalizer request or a missing-summary warning. Merge readiness✅ Ready for maintainer review Keep open: this is a useful, bounded repair that current main and the latest release still lack. The supplied runtime evidence supports the fix, and no blocking introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherAfter tools finish without a final answer, OpenClaw can request a tool-free summary. The finalization owner converts that result into terminal state and reply payloads for heartbeat delivery. flowchart TD
A[Completed tool work] --> B[Tool-free finalizer]
B --> C[Validate assistant result]
C --> D{Explicit silence allowed?}
D -->|Yes| E[Finish without a payload]
D -->|No| F[Existing answer or recovery handling]
F --> G[Heartbeat delivery]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +30, Tests +101. Total +131 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep deliberate silence within the existing finalization owner while preserving normal alerts, required replies, and failure handling. Do we have a high-confidence way to reproduce the issue? Yes: an optional, silence-enabled run whose isolated finalizer returns NO_REPLY reaches the retry/fallback path on current main. Source inspection and the supplied pre-fix failure support this mechanism; this read-only review did not execute tests. Is this the best way to solve the issue? Yes: preserving the authored token and applying the existing silence classifier at finalization is a narrow repair that avoids another policy or delivery path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c92ce0278f4a. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
landpr-approve-admin-merge |
|
Thanks @PollyBot13! Proof: A real Gateway heartbeat completed silently in the Discord QA channel. Alert and acknowledgment controls retained their expected behavior.
|
Related: #146331. Supersedes #146595 by @MasterSwords1. Thanks @fray-ai for reporting it. ## What Problem This Solves After replay cleanup removes old messages, an assistant can lose the current task and successful tool results from later requests, even though chat history still shows them. ## Why This Change Was Made Normalize replay before prompt preparation records the history boundary. Session setup seeds the count; prompt preparation replaces it after history assembly and cleanup. Submission consumes that prepared history; it no longer shortens history after the boundary is set. The contributor's production fix is preserved. Tests now use complete fixtures and real prompt preparation/submission, with a clean-history control. ## User Impact Current instructions and tool results remain available across multiple tool calls. No setting or migration is needed. ## Evidence Authenticated Gateway `chat.send`, an isolated history-only context engine, and two actual file reads: | Captured request | Main, six silent history messages | Candidate | | --- | --- | --- | | First | Current task present | Current task present | | Second | Task and first result absent | Task and first result present | | Third | Task and both results absent | Task and both results present | Both runs completed the reads and retained the entire turn in chat history. The no-silent-history control passes on both. Responses were deterministic; this proves request contents, not model answer quality. The corrected regression fails on main because the active prompt is missing, and passes with the fix. Five selected test files pass on fresh merge `3e4442b9890b85e579eb36f657e88261ca0ef825` (parents `aa2bcb6ebe293c76eb1c715dae9a386da3750dfc` and `fa5b2d16805c7c81e2c395fbbc0ff27312b16da1`): 160 distinct tests, 250 successful executions across the two test configurations. <details> <summary>Commands and captured result</summary> Gateway driver commands, using the retained proof directory: ```sh node "$PROOF/reproduce.mjs" candidate-six 6 node "$PROOF/assert-tail.mjs" candidate-six node "$PROOF/reproduce.mjs" candidate-clean 0 node "$PROOF/assert-tail.mjs" candidate-clean ``` Both candidate assertions exit 0. The same assertion exits 1 on the recorded main reproduction. Captured candidate checks: three requests; two completed reads; current task retained in every request; first result retained in request two; both results retained in request three; chat history retains all markers. Selected tests: ```sh node scripts/run-vitest.mjs \ src/agents/embedded-agent-runner/run/attempt-context-advancement.test.ts \ src/agents/embedded-agent-runner/run/attempt-prompt-context.test.ts \ src/agents/embedded-agent-runner/run/attempt-prompt-submit.test.ts \ src/agents/embedded-agent-runner/run/attempt-prompt-phase.test.ts \ src/agents/embedded-agent-runner/tool-result-context-guard.test.ts ``` The fresh merge used `node --import tsx scripts/ci-run-node-test-shard.mts`, with these five include paths and the embedded-agent and embedded-agent-run configurations. Exit 0. Six additional direct-caller files also passed on that merge (165 tests), covering replay recovery, projections, settlement, media hints, and tool-result budgets. Typechecks remain for CI. </details> ## Compatibility No schema, protocol, dependency, configuration, or durable transcript change. Existing context-engine commit semantics remain intact. ## Consumers The shared boundary also serves turn completion, usage fallback, and legacy context finalization. They consume the normalized count. The independent CLI history boundary is unchanged. ## Invalidation Each attempt computes the boundary after replay cleanup. No persistent cache or new state owner is added. ### Ordering and consumers Session setup seeds the history count. Prompt preparation replaces it after history assembly and replay cleanup, then submission consumes the prepared history. The same count serves tool-loop advancement, reply flushing, usage fallback, and legacy turn completion. Hook and budget projections and the active-run snapshot use that prepared history. Optional settled-turn finalization still reads the newly completed assistant from the stream subscription, preserving the authored `NO_REPLY` behavior from #145343. ### Validation scope The retained Gateway proof checks actual request contents and completed file reads with deterministic responses. Main loses the active task and results after replay cleanup; the candidate retains them. Both clean-history controls pass. Runtime proof was captured at `9dc8e3a19ad7ea694bc40ca520f1e2597e7fdc22`; the final commit changes only tests. The fresh merge includes #145343, #147139, and #147394. Its selected suites pass 160 distinct tests, with 250 executions due to configuration overlap, plus 165 tests in six additional consumer files. This does not claim a separate fresh execution of the finalizer-silence scenario, browser rendering, or answer quality. Typechecks remain for CI. CI run [34789473564](https://github.com/openclaw/openclaw/actions/runs/34789473564) completed successfully at `aa2bcb6ebe293c76eb1c715dae9a386da3750dfc`, including the hosted type checks. Co-authored-by: MasterSwords1 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Keep authored NO_REPLY during built-in optional finalization and apply the existing silence policy before retry or fallback. Preserve required replies, tool failures, timeouts, and cancellation. Co-authored-by: Ayaan Zaidi <[email protected]>
…47531) Related: openclaw#146331. Supersedes openclaw#146595 by @MasterSwords1. Thanks @fray-ai for reporting it. ## What Problem This Solves After replay cleanup removes old messages, an assistant can lose the current task and successful tool results from later requests, even though chat history still shows them. ## Why This Change Was Made Normalize replay before prompt preparation records the history boundary. Session setup seeds the count; prompt preparation replaces it after history assembly and cleanup. Submission consumes that prepared history; it no longer shortens history after the boundary is set. The contributor's production fix is preserved. Tests now use complete fixtures and real prompt preparation/submission, with a clean-history control. ## User Impact Current instructions and tool results remain available across multiple tool calls. No setting or migration is needed. ## Evidence Authenticated Gateway `chat.send`, an isolated history-only context engine, and two actual file reads: | Captured request | Main, six silent history messages | Candidate | | --- | --- | --- | | First | Current task present | Current task present | | Second | Task and first result absent | Task and first result present | | Third | Task and both results absent | Task and both results present | Both runs completed the reads and retained the entire turn in chat history. The no-silent-history control passes on both. Responses were deterministic; this proves request contents, not model answer quality. The corrected regression fails on main because the active prompt is missing, and passes with the fix. Five selected test files pass on fresh merge `3e4442b9890b85e579eb36f657e88261ca0ef825` (parents `aa2bcb6ebe293c76eb1c715dae9a386da3750dfc` and `4492504cc1f3704f8b3a5459f75a9c57e1f96edd`): 160 distinct tests, 250 successful executions across the two test configurations. <details> <summary>Commands and captured result</summary> Gateway driver commands, using the retained proof directory: ```sh node "$PROOF/reproduce.mjs" candidate-six 6 node "$PROOF/assert-tail.mjs" candidate-six node "$PROOF/reproduce.mjs" candidate-clean 0 node "$PROOF/assert-tail.mjs" candidate-clean ``` Both candidate assertions exit 0. The same assertion exits 1 on the recorded main reproduction. Captured candidate checks: three requests; two completed reads; current task retained in every request; first result retained in request two; both results retained in request three; chat history retains all markers. Selected tests: ```sh node scripts/run-vitest.mjs \ src/agents/embedded-agent-runner/run/attempt-context-advancement.test.ts \ src/agents/embedded-agent-runner/run/attempt-prompt-context.test.ts \ src/agents/embedded-agent-runner/run/attempt-prompt-submit.test.ts \ src/agents/embedded-agent-runner/run/attempt-prompt-phase.test.ts \ src/agents/embedded-agent-runner/tool-result-context-guard.test.ts ``` The fresh merge used `node --import tsx scripts/ci-run-node-test-shard.mts`, with these five include paths and the embedded-agent and embedded-agent-run configurations. Exit 0. Six additional direct-caller files also passed on that merge (165 tests), covering replay recovery, projections, settlement, media hints, and tool-result budgets. Typechecks remain for CI. </details> ## Compatibility No schema, protocol, dependency, configuration, or durable transcript change. Existing context-engine commit semantics remain intact. ## Consumers The shared boundary also serves turn completion, usage fallback, and legacy context finalization. They consume the normalized count. The independent CLI history boundary is unchanged. ## Invalidation Each attempt computes the boundary after replay cleanup. No persistent cache or new state owner is added. ### Ordering and consumers Session setup seeds the history count. Prompt preparation replaces it after history assembly and replay cleanup, then submission consumes the prepared history. The same count serves tool-loop advancement, reply flushing, usage fallback, and legacy turn completion. Hook and budget projections and the active-run snapshot use that prepared history. Optional settled-turn finalization still reads the newly completed assistant from the stream subscription, preserving the authored `NO_REPLY` behavior from openclaw#145343. ### Validation scope The retained Gateway proof checks actual request contents and completed file reads with deterministic responses. Main loses the active task and results after replay cleanup; the candidate retains them. Both clean-history controls pass. Runtime proof was captured at `9dc8e3a19ad7ea694bc40ca520f1e2597e7fdc22`; the final commit changes only tests. The fresh merge includes openclaw#145343, openclaw#147139, and openclaw#147394. Its selected suites pass 160 distinct tests, with 250 executions due to configuration overlap, plus 165 tests in six additional consumer files. This does not claim a separate fresh execution of the finalizer-silence scenario, browser rendering, or answer quality. Typechecks remain for CI. CI run [34789473564](https://github.com/openclaw/openclaw/actions/runs/34789473564) completed successfully at `aa2bcb6ebe293c76eb1c715dae9a386da3750dfc`, including the hosted type checks. Co-authored-by: MasterSwords1 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #143580
What Problem This Solves
Fixes an issue where users receive an unnecessary missing-summary warning after a heartbeat's tool-free finalizer explicitly chooses
NO_REPLY, even though the run permits silence.Why This Change Was Made
The host retains the authored silent token through finalizer projection and accepts it under the existing optional/allowed-silence contract. Required replies, genuinely blank output, original tool failures, original timeouts, and cancellation cannot use this exception. No new API or policy flag is introduced.
This is a narrow unwanted-chatter repair, not a claim to fix the reported transcript loss, prolonged wedge, or duplicate delivery. The separate timeout-retention change in #141072 is complementary; combined execution has not been tested.
User Impact
Quiet heartbeat results stay quiet without a second finalizer request or a synthetic fallback warning. Legitimate alerts and HEARTBEAT_OK behavior remain unchanged.
Evidence
AI-assisted
Inspectable loopback execution output
Head:
953c3fbf55f099944acd41e5dc2fd2b9304280f2. The excerpts below are copied from the existing exact-head run (September 12, 00:13 CEST), not a new run or inferred source behavior. The task-only test uses real SQLite transcript persistence, built-in restricted finalization, history assembly and HTTP/SSE transport to a local synthetic responder. Auth availability is supplied by a synthetic registry; the responder emits a fixed assistant text andfinish_reason=stop. No real credentials, external provider or live channel is involved.Invocation:
node node_modules/vitest/vitest.mjs run --config <artifact-dir>/fix.config.mts. The artifact config extends the repository Vitest config and aliases missing workspace links to existing installed package bytes; it is not a standard clean-install run.Captured NO_REPLY request and resulting terminal payloads
The responder's assistant text is
NO_REPLY. This is the complete saved request/outcome JSON: one HTTP request, no offered tools, retained synthetic completed-tool history and no emitted payload.answeredis the internal finalization classification that ends retries, not a visible answer.{ "finalizationOutcome": "answered", "payloads": [], "requests": [ { "model": "synthetic", "messages": [ { "role": "user", "content": "Heartbeat monitor: check the synthetic inbox. If nothing needs attention reply HEARTBEAT_OK." }, { "role": "assistant", "content": null, "tool_calls": [ { "id": "inbox", "type": "function", "function": { "name": "exec", "arguments": "{\"command\":\"synthetic-inbox\"}" } } ] }, { "role": "tool", "content": "[] (synthetic inbox empty)", "tool_call_id": "inbox" }, { "role": "user", "content": "The previous assistant turn completed its tool calls but did not produce a user-visible answer. Continue from the current transcript and produce the final user-visible answer now. Do not repeat completed tool calls or restart from scratch. Tools are unavailable in this step: it is a text-only pass, so reply with plain text and do not attempt any tool call." } ], "stream": true, "stream_options": { "include_usage": true }, "max_completion_tokens": 2048 } ] }Acknowledgment/alert controls and exact-head terminal output
Projected from the saved control request/outcome JSON (only request count, payloads and outcome shown):
{ "ok": { "requestCount": 1, "payloads": [ { "text": "HEARTBEAT_OK", "replyToTag": false } ], "finalizationOutcome": "answered" }, "alert": { "requestCount": 1, "payloads": [ { "text": "Synthetic alert: inbox needs attention", "replyToTag": false } ], "finalizationOutcome": "answered" } }Copied terminal output; local checkout prefix removed:
Earlier red run against the unfixed implementation (before rebase; not exact-head):
The earlier pre-fix raw request snapshot was overwritten by successful captures; the retained red assertion above is the directly inspectable pre-fix evidence. The exact-head capture and passing assertions establish one request and zero payloads after the fix. This does not establish the reporter's transcript-loss, wedge or duplicate-delivery scenario.
Hosted verification at this checkpoint: CI run, including
openclaw/ci-gate, production/test typechecks and lint, passed. Local full build/typecheck limitations above remain disclosed.What Problem This Solves
A quiet heartbeat can send “The tool run finished, but no final summary was produced” after its finalizer deliberately returns
NO_REPLY.Why This Change Was Made
The built-in runtime now retains that authored token and accepts it through the existing optional-reply policy. The host finalization owner makes this decision; no new setting or state store is added.
User Impact
Quiet heartbeats stay quiet with one finalizer request. Alerts still arrive. Required replies, blank output, tool failures, original timeouts, and cancellation retain their existing checks.
Evidence
Independently executed head
953c3fbf55f099944acd41e5dc2fd2b9304280f2through a real Gateway heartbeat and leased Discord bots:NO_REPLYNO_REPLYHEARTBEAT_OKThe quiet run completed successfully and retained one
NO_REPLYin history. Each recording lasted three minutes. Ordinary retries before finalization are separate and unchanged.Candidate owner checks: 69 passed. Fresh-merge checks: 401 passed; one fallback-notice assertion failed identically on plain main and the relevant prior-merge parent. Test routing, changed-file lint, and formatting passed. Hosted CI gate passed.
Consumers
Optional finalizers, reply shaping, heartbeat delivery, background completion, and terminal snapshots retain the same silence contract. Writer authority and failure handling remain intact; derived output is rebuilt per attempt.
This proof covers the built-in runtime. A separate plugin still erases silent tokens before host finalization; that pre-existing limit remains. This does not fix lost history, long stalls, or duplicate delivery in the linked report.
AI-assisted.
Latest exact-head hosted verification: CI run 34786156188, successful at
953c3fbf55f099944acd41e5dc2fd2b9304280f2.