Skip to content

fix(agents): preserve silent reply after settled tools - #130675

Merged
obviyus merged 1 commit into
mainfrom
fix/silent-tool-finalization
Aug 27, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/silent-tool-finalization

Conversation

@obviyus

@obviyus obviyus commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

An embedded heartbeat can use tools, finish with the exact silent token NO_REPLY, and still trigger settled-turn finalization. The extra model call can produce unrelated prose that OpenClaw then sends to the user.

Root cause

Reply payload preparation correctly removes NO_REPLY from outbound payloads. Settled-tool recovery then sees zero visible payloads, selects the earlier tool-use assistant as the completed batch, and treats the turn as missing a final answer. It ignored the preserved assistant text that already proved deliberate silence.

Codex treats a completed assistant message as terminal when no tool follow-up remains (codex-rs/core/src/session/turn.rs:395-501). OpenClaw owns the additional NO_REPLY delivery contract.

Fix

  • Reuse the canonical silent-reply classifier before settled-tool finalization when the caller does not require a visible reply.
  • Preserve finalization for required direct turns, blank stops, mixed prose, and failed tools.
  • Add owner-boundary regressions for heartbeat silence and the required direct-turn counter-case.

Proof

Final-head Telegram result

The canonical local telegram-e2e-userbot recorder drove heartbeat → tool → NO_REPLY on f8d8058a6a0410d5c29fba900c5af91c27a7535e. The provider received exactly two requests, the second carried the matching tool output, no finalization request occurred, and Telegram observed no SUT message, edit, or deletion.

Scope

  • Production: +1 line.
  • Tests: +54 lines.
  • No config, storage, protocol, provider, or channel contract changes.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels Aug 27, 2026
@obviyus
obviyus force-pushed the fix/silent-tool-finalization branch from 54f6738 to 21c2651 Compare August 27, 2026 04:09
@obviyus
obviyus force-pushed the fix/silent-tool-finalization branch from 21c2651 to f8d8058 Compare August 27, 2026 04:21
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 12:27 AM ET / 04:27 UTC.

ClawSweeper review

What this changes

The PR stops reply-optional settled-tool runs from requesting an extra final response when the preserved assistant result is a deliberate NO_REPLY, while retaining recovery for reply-required runs.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for explicit maintainer handling: the source-level repair is focused and plausible, but the PR’s stated final-head behavior evidence and cited Codex contract remain unverified.

Priority: P1
Reviewed head: f8d8058a6a0410d5c29fba900c5af91c27a7535e
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation is focused with a credible source-level regression, but final-head delivery proof and the cited Codex contract check remain outstanding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-labeled PR is exempt from the external-contributor proof gate, though its own body still identifies final-head Telegram evidence as outstanding; redact private details in any trace or recording.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-labeled PR is exempt from the external-contributor proof gate, though its own body still identifies final-head Telegram evidence as outstanding; redact private details in any trace or recording.
Evidence reviewed 7 items Current-main gap: Current main has no silent-reply guard in settled-tool continuation; the PR adds it at the recovery owner.
Caller preserves required replies: Terminal resolution passes allowEmptyStopContinuation only when the run requires a visible reply; a heartbeat remains optional.
Canonical silent-output contract: The reused classifier requires every nonempty assistant text to be a silent payload, and normal reply preparation suppresses such payloads before delivery.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/terminal-resolution.test.ts

Result: PASS (completed)

[test] starting test/vitest/vitest.agents-embedded-agent-run.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130675-hxzWDp/target

 ✓  agents-embedded-agent-run  src/agents/embedded-agent-runner/run/terminal-resolution.test.ts (36 tests) 628ms
     ✓ surfaces provider recovery guidance for 'auth' terminal failures  395ms

 Test Files  1 passed (1)
      Tests  36 passed (36)
   Start at  04:28:25
   Duration  12.17s (transform 9.13s, setup 1.06s, import 10.10s, tests 628ms, environment 0ms)

[test] passed 1 Vitest shard in 18.51s
[test] starting test/vitest/vitest.agents-embedded-agent-run.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130675-hxzWDp/target

 ✓  agents-embedded-agent-run  src/agents/embedded-agent-runner/run/terminal-resolution.test.ts (36 tests) 606ms
     ✓ surfaces provider recovery guidance for 'auth' terminal failures  374ms

 Test Files  1 passed (1)
      Tests  36 passed (36)
   Start at  04:28:44
   Duration  5.99s (transform 3.11s, setup 486ms, import 4.66s, tests 606ms, environment 0ms)

[test] passed 1 Vitest shard in 12.13s

Assertions:

  • NOT OBSERVED expect_output: keeps explicit silence terminal only for reply-optional settled turns — command exited successfully; expected output was not observed in the captured pane

How this fits together

Embedded agent runs collect assistant output and tool results, then terminal recovery decides whether another model call is needed before output can reach a channel. Background runs that deliberately end silently should finish without creating an extra model response.

flowchart LR
A[Heartbeat or user run] --> B[Embedded agent attempt]
B --> C[Tools settle]
C --> D[Terminal recovery]
D --> E{Reply required?}
E -->|Optional and silent| F[Finish silently]
E -->|Required or not silent| G[Request final answer]
G --> H[Outbound channel delivery]
Loading

Decision needed

Question Recommendation
Should this maintainer-labeled PR wait for final-head behavior evidence and direct validation of its cited Codex terminal contract before approval? Require the outstanding evidence: Keep the PR open until it includes redacted final-head behavior proof and a reviewer validates the cited Codex source behavior.

Why: Repository policy requires explicit maintainer handling for the label, while the submitted evidence defers the real-flow proof and its external-contract rationale could not be directly checked.

Before merge

  • Resolve merge risk (P1) - The final-head heartbeat-to-channel behavior remains unobserved; the PR body says Telegram proof will be added before merge.
  • Resolve merge risk (P1) - The stated Codex terminal-semantics support cannot be relied on until the required sibling source is directly inspected.
Agent review details

Security

None.

PR surface

Source +1, Tests +54. Total +55 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 0 +1
Tests 1 54 0 +54
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 55 0 +55

Review metrics

Metric Value Why it matters
Production versus regression test delta production +1, tests +54 The one-line recovery guard is paired with a focused scenario that separates optional heartbeat silence from required user replies.

Merge-risk options

Maintainer options:

  1. Prove the heartbeat recovery path (recommended)
    Add redacted final-head evidence that the silent heartbeat flow makes no extra model request or Telegram delivery and that required replies still take the continuation path.
  2. Accept the evidence gap
    A maintainer may merge with the focused source and unit evidence while accepting the missing end-to-end delivery observation.

Technical review

Best possible solution:

Merge only after redacted final-head evidence shows a settled heartbeat ending in NO_REPLY produces neither isolated finalization nor an outbound message, while the required-reply control case still finalizes.

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

Yes at the source decision point: current main lacks this guard and the focused regression models the heartbeat/tool/silent-terminal sequence. A final-head channel-flow reproduction has not yet been supplied.

Is this the best way to solve the issue?

Yes, provisionally: the change belongs in the settled-tool finalization owner, reuses the canonical silent-reply classifier, and retains the required-reply branch. Direct Codex-contract and final-flow proof remain needed before approval.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6b842df52e5c.

Labels

Label changes:

  • add P1: The reported recovery error can send unrelated prose to a real user after a background run.
  • add merge-risk: 🚨 message-delivery: This branch changes the decision that can trigger an additional model output for channel delivery.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-labeled PR is exempt from the external-contributor proof gate, though its own body still identifies final-head Telegram evidence as outstanding; redact private details in any trace or recording.

Label justifications:

  • P1: The reported recovery error can send unrelated prose to a real user after a background run.
  • merge-risk: 🚨 message-delivery: This branch changes the decision that can trigger an additional model output for channel delivery.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-labeled PR is exempt from the external-contributor proof gate, though its own body still identifies final-head Telegram evidence as outstanding; redact private details in any trace or recording.

Evidence

What I checked:

Likely related people:

  • obviyus: Authored this PR and earlier merged post-tool recovery work in the same area. (role: recent area contributor; confidence: high; commits: f8d8058a6a04, 0b9842d138c0; files: src/agents/embedded-agent-runner/run/incomplete-turn-recovery.ts, src/agents/embedded-agent-runner/run/terminal-resolution.test.ts)
  • Peter Steinberger: Current-main blame and recent history connect him to the settled terminal-tool recovery policy. (role: recent area contributor; confidence: high; commits: a872abc97829, c55d9b6d207b, 41009e765c22; files: src/agents/embedded-agent-runner/run/incomplete-turn-recovery.ts, src/agents/embedded-agent-runner/run/terminal-resolution.ts)

Rank-up moves

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

  • Add redacted final-head evidence that the heartbeat tool flow ends silently without an extra delivery.
  • Validate the cited Codex terminal behavior from the required sibling source checkout before approval.

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.

@obviyus

obviyus commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

Final-head Telegram real-user proof for f8d8058a6a0410d5c29fba900c5af91c27a7535e:

  • Runner: canonical telegram-e2e-userbot mock-SUT recorder, local exact-head checkout, dedicated leased QA user, DM target; credentials omitted.
  • Action: immediate heartbeat system event at 1,000 ms; completed in 4,314 ms.
  • Provider trace: request 1 emitted the exec tool call; request 2 contained the matching function_call_output and returned NO_REPLY; total requests = 2.
  • Recovery check: no third request, no settled-turn finalization prompt, and no HEARTBEAT_RECOVERY_JUNK fixture response consumed.
  • Telegram timeline: 2 SUT typing events; 0 SUT messages, edits, or deletions; sutRevisionTexts=[].
  • Gateway trace: no settled post-tool turn lacked a final answer, no isolated finalization, and no outbound send.

Interpretation: a tool-using heartbeat now terminates silently on exact NO_REPLY; required direct turns remain covered by the counter-regression test.

@obviyus
obviyus merged commit 32f980d into main Aug 27, 2026
218 checks passed
@obviyus
obviyus deleted the fix/silent-tool-finalization branch August 27, 2026 05:00
vincentkoc added a commit that referenced this pull request Aug 27, 2026
…-retirement-v13

* origin/main: (243 commits)
  fix: preserve Gateway error reasons in text logs (#130645)
  refactor(video): deduplicate generation contracts (#130635)
  fix(agents): preserve direct-message sender identity (#124548)
  fix(agents): preserve silent reply after settled tools (#130675)
  fix(talk): preserve replacement speech when an old utterance is canceled (#130687)
  fix(browser): preserve literal names and formatter-owned snapshot refs (#130599)
  fix(auth): reset only the profile replaced by a successful login (#124014)
  fix: bind session creation to admitted Gateway (#130686)
  refactor(qa-lab): reuse model reference splitter (#130317)
  docs(gateway): clarify independent HTTP endpoint switches (#130690)
  fix(ui): Control UI smooth scrolling ignores the reduced-motion preference (#130428)
  refactor(lmstudio): remove unreachable catalog merge (#130689)
  fix(crabbox): restore cloud machine CPU and RAM (#130684)
  fix(secrets): compare proxy bearer tokens directly (#127054)
  fix(matrix): show recovery key availability in text status (#128051)
  fix(ios): restore approval settings navigation and remove duplicate shell state (#130651)
  refactor(agents): use fixed tool-loop defaults directly (#130681)
  refactor(qa-lab): share process tree metric reader (#130419)
  refactor(models): simplify prepared owner access (#130683)
  fix(parallels): main install and update smoke cannot complete (#130658)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
Prevent reply-optional tool turns ending in NO_REPLY from triggering an extra model call and user-visible junk. Required direct turns still finalize normally.

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 maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant