Repository navigation
feat(agents): end runs after confirmed final source replies - #170653
Conversation
End both agent loops after confirmed final replies or added final reactions on the current source. Preserve progress continuation and suppress later source text after completion, including Codex transcript projections. Replace generated NO_REPLY guidance with empty completion for optional turns. Keep legacy token parsing and required-reply policy unchanged. Related: #170147 (current-source completion subcase only)
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 20ae1fcc55
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| export function installMessageToolOnlyTerminalHook( | ||
| export function installMessageToolTerminalHook( |
There was a problem hiding this comment.
Update callers of the renamed terminal hook
Renaming this export without updating test/twitch-message-tool-delivery.test.ts leaves that test importing and invoking the removed installMessageToolOnlyTerminalHook symbol, so the Twitch delivery suite fails while loading instead of exercising its cases. Rename that caller too, or retain a compatibility alias.
AGENTS.md reference: AGENTS.md:L50-L53
Useful? React with 👍 / 👎.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs changes before merge. What this changesThis PR ends embedded and Codex runs after confirmed final source replies and suppresses subsequent source output. Example: The agent adds 👍 to the current inbound message using final:true.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: both prior findings are fixed, and the current-source completion repair remains useful; no new introduced defect was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe message delivery owner records confirmed source delivery; embedded and Codex lifecycle owners consume that fact to finish execution and suppress later reply projections. flowchart LR
A[Model tool call] --> B[Message delivery owner]
B --> C[Confirmed source delivery]
C --> D[Embedded completion hook]
C --> E[Codex lifecycle controller]
D --> F[Completed run]
E --> F
C --> G[Suppress later source output]
Technical reviewBest possible solution: Retain the canonical delivery-driven completion repair while leaving cross-chat silence and token-policy changes with their existing trackers. Do we have a high-confidence way to reproduce the issue? Current main exposes the continuation path, and the supplied native Gateway comparison reports matching before/after behavior; this review executed no target code. Is this the best way to solve the issue? Using the existing delivery owner’s committed fact is appropriate, preserves progress and route exclusions, and avoids relying on models to generate silence after successful completion. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c146b99c60ac. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +45, Tests +564, Docs +2. Total +611 across 50 files. Added test files: 3. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 13, 2026, 3:31 AM ET / 07:31 UTC (Revision 2). |
|
@clawsweeper re-review Final reviewed head: 078d15c. The last follow-up fixes stale Copilot assertions and keeps shared guidance accurate for harnesses outside the embedded/Codex termination paths. Focused branch/base tests, regenerated snapshots, scoped lint, ratchets, and full-branch isolated review pass. The PR body now includes the final 160-turn native Qwen comparison and its same-response duplicate/pre-final preview limitations. |
|
🦞👀 Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 078d15c7eb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| : "No source-conversation reply can be sent from this turn. Final assistant text remains private and returns to the invoking workflow; it is not automatically delivered to the source conversation." | ||
| : params.messageToolAvailable | ||
| ? "You can participate in the conversation throughout your work. Use `message` when you have something worth saying; you don’t need to wait until you’re finished, and sending a message doesn’t end your task. OpenClaw delivers your final response automatically." | ||
| ? "Use `message` with `final=false` for progress. A completed send to the current source conversation (`final=true`, or omitted) or an added reaction to its current message with `final=true` is your complete reply. Do not repeat delivered content. Otherwise, OpenClaw delivers your final response automatically." |
There was a problem hiding this comment.
Limit terminal guidance to harnesses that can stop
In automatic mode this shared guidance is also injected by extensions/copilot/src/prompt-guidance.ts, but the Copilot bridge converts a successful tool result to an SDK result without carrying terminate, and attempt-execution.ts still waits for session.sendAndWait() to complete the post-tool model loop. Consequently, when Copilot calls message with final:true or an omitted final, it still generates a subsequent assistant response that automatic delivery can send as a duplicate, despite this newly claiming the tool call is the complete reply. Keep the previous guidance for non-terminating harnesses or implement delivered-final termination and output suppression there too.
AGENTS.md reference: AGENTS.md:L82-L82
Useful? React with 👍 / 👎.
|
Merged via squash.
|
## What Problem This Solves The cancellation case in `src/gateway/server.chat.canonical-publication.test.ts` waited for a follow-up model request that can no longer occur after a final delivered message. Commit 7a5529f (#170653) deliberately ends ordinary turns after a confirmed final source reply. Message sends are final by default. Set `final: false` only on the cancellation scenario's synthetic message send, so it reaches the pending follow-up request that the test intends to abort. Preserve every cancellation, sanitized publication, attachment download and idempotent replay assertion. Other cases retain default finality. ## Evidence - Failing main evidence: https://github.com/openclaw/openclaw/actions/runs/38378024699/job/115231445890, `chat.send preserves canonical sanitized message publication through chat.history and artifacts.download`: `final request was not held`. - Culprit verified against its parent-relative patch: 7a5529f removes the message-tool-only restriction and installs whole-turn completion after a final delivered source reply. Current `resolveMessageToolSourceReplyFinal` treats omitted `final` as true. - Changed-file oxfmt, oxlint and `git diff --check` pass. One isolated Codex review covers this patch and the independent recovered-output fixture patch; status: scoped-clean at P2, no actionable findings. - Original failing case passed in PR CI run [38380534855](https://github.com/openclaw/openclaw/actions/runs/38380534855/job/115239951360): 37.186 seconds; Vitest 87.83 seconds. All ordinary PR CI leaves and required aggregate contexts passed on reviewed head `0c0421ce8846d73b9491b409fc9a50214d61eb45`. No local test suite was run. - Production LOC: 0. Test LOC: +2/-0. No production behavior, SQL/request count, T1, schema, SDK or update-path change. No SQL harness or local broad checks run. No removed production checks or new accepted edge cases.
…#170653) * feat(agents): finish turns with structured source replies End both agent loops after confirmed final replies or added final reactions on the current source. Preserve progress continuation and suppress later source text after completion, including Codex transcript projections. Replace generated NO_REPLY guidance with empty completion for optional turns. Keep legacy token parsing and required-reply policy unchanged. Related: openclaw#170147 (current-source completion subcase only) * fix(agents): preserve optional-turn silence guidance * test(codex): type source reply fixtures as JSON objects * fix(agents): preserve final delivery when result hooks throw * test(agents): align delivery checks with structured completion * test(codex): expect finality on delivered media * test(agents): keep delivery regression within line budget * fix(agents): align shared final reply guidance and callers * test(codex): freeze monotonic time in question refresh Keep the execution deadline on the fixture clock during cold asynchronous preparation. Preserve upstream zero-advance polling for prompt delivery. No production timeout or final-action termination policy changes. Co-authored-by: sunlit-deng <[email protected]> --------- Co-authored-by: sunlit-deng <[email protected]>
) ## What Problem This Solves The cancellation case in `src/gateway/server.chat.canonical-publication.test.ts` waited for a follow-up model request that can no longer occur after a final delivered message. Commit 12e06d3 (openclaw#170653) deliberately ends ordinary turns after a confirmed final source reply. Message sends are final by default. Set `final: false` only on the cancellation scenario's synthetic message send, so it reaches the pending follow-up request that the test intends to abort. Preserve every cancellation, sanitized publication, attachment download and idempotent replay assertion. Other cases retain default finality. ## Evidence - Failing main evidence: https://github.com/openclaw/openclaw/actions/runs/38378024699/job/115231445890, `chat.send preserves canonical sanitized message publication through chat.history and artifacts.download`: `final request was not held`. - Culprit verified against its parent-relative patch: 12e06d3 removes the message-tool-only restriction and installs whole-turn completion after a final delivered source reply. Current `resolveMessageToolSourceReplyFinal` treats omitted `final` as true. - Changed-file oxfmt, oxlint and `git diff --check` pass. One isolated Codex review covers this patch and the independent recovered-output fixture patch; status: scoped-clean at P2, no actionable findings. - Original failing case passed in PR CI run [38380534855](https://github.com/openclaw/openclaw/actions/runs/38380534855/job/115239951360): 37.186 seconds; Vitest 87.83 seconds. All ordinary PR CI leaves and required aggregate contexts passed on reviewed head `0c0421ce8846d73b9491b409fc9a50214d61eb45`. No local test suite was run. - Production LOC: 0. Test LOC: +2/-0. No production behavior, SQL/request count, T1, schema, SDK or update-path change. No SQL harness or local broad checks run. No removed production checks or new accepted edge cases.
…176141) Related: #170653, #176092 ## What Problem This Solves Fixes: a cron job stops right after it sends a message to its own delivery target, so its next steps never run. ## User Impact User impact: a cron job can send to its configured chat with the `message` tool and then continue, for example to update a state file or ledger. Before this fix the turn ended about 0.3 s after the send. A job that recorded "reserved" before sending never recorded "sent", and the next run refused to post because it could not prove delivery. Chat replies are unchanged. ## Why This Change Was Made Cron runs use the job's delivery target as the turn's current source. Since #170653, a confirmed send to that source with `final` omitted counts as the final source reply: - Codex interrupts the turn (`turn.dynamic_tool_terminal_release`, then `turn/interrupt`). - The embedded runner returns `terminate: true`. A cron target is a configured destination, not a conversation the turn answers, so the send should not end the turn. What changed: - The cron source-delivery plan now owns this decision: `messageTool.finalByDefault: false`, passed to runs as `messageToolFinalByDefault`. - One resolver, `resolveMessageToolSourceReplyFinal(args, finalByDefault)`, applies it at every place that decides finality: Codex dynamic tools, the embedded terminal hook and subscriber, and CLI evidence. - An explicit `final` still wins. - `resolveMessageToolSourceReplyFinal` is now exported from `plugin-sdk/agent-harness-runtime`, next to its sibling `isDeliveredMessageToolOnlySourceReplyResult`, so Codex uses the same owner. The public export budgets go up by one (callable 2206 to 2207, total 3808 to 3809), each with a recorded reason. - Chat turns keep the default (omitted `final` ends the turn). - Delivery facts do not change. A send still counts as reaching the cron target, so `announce` still skips its fallback and no duplicate posts. - The model's turn guidance (Codex `openclaw_source_delivery` context and embedded runtime instructions) now states the rule when the default is off. Chat guidance text is byte-identical. This change is compatible with #176093. That PR keys on an explicit `final: false`, and this change does not touch it. Comparison: hermes-agent never ends a turn on a send. Its cron same-target guard returns a skipped tool result and lets the turn continue (NousResearch/hermes-agent#1357). ### Decision Cron turns intentionally stop following the "omitted `final` ends the turn" default from #119605/#170653. That default fits a chat, where the send answers the inbound message. A cron target is a configured destination, and the job decides when it is done. - **Tradeoff accepted:** a cron send with `final` omitted costs one more model call, the call #170653 removed. Losing a job's post-send steps without notice costs more. - **Users see no duplicates:** `announce` still skips its fallback after a send, and `none` keeps the final text private. - **Unchanged:** chat turns and an explicit `final`. ## Evidence **Live failure (Codex runtime, stock main):** - A daily cron photo job sent its photo (`ok: true`). - The trajectory then shows `tool.result`, then `turn.dynamic_tool_terminal_release` 4 ms later, then `model.completed` with no assistant text, then `session.ended`. - The job's next step, marking its ledger entry `sent`, never ran. The next run blocked on the unconfirmed entry. **End-to-end, QA Lab** (real gateway, cron scheduler, qa-channel, mock-openai; the Codex cell runs the real `codex app-server`). New scenario `cron-send-then-continue` covers delivery modes `none` and `announce`. In each, the model sends to the delivery target without `final`, then writes a marker file, then finishes. | | embedded | codex | |---|---|---| | main `adb12365084` (no fix) | fail: one request, turn ended after send | fail: one request, turn ended after send | | this PR | pass: send, then `write`, one channel message per mode | pass: send, then `bash`, one channel message per mode | Each runtime cell's scenario details now include the request trace for each delivery mode (`message -> next tool -> final`, plus what qa-channel received). This run is at the PR head: ```text codex none: message -> exec_command -> final; channel=["QA-CRON-SEND-CONTINUE-SENT"] | announce: message -> exec_command -> final; channel=["QA-CRON-SEND-CONTINUE-SENT"] embedded none: message -> write -> final; channel=["QA-CRON-SEND-CONTINUE-SENT"] | announce: message -> write -> final; channel=["QA-CRON-SEND-CONTINUE-SENT"] ``` On main, both cells stop after the first request: `requests=[{"tool":"message",...}]`, and no further tool call follows. **Regression scenarios on both runtimes:** 10 message-tool, cron, sub-agent and A2A scenarios, run under `--runtime-pair openclaw,codex`. - Pass, with no change in the chat paths: `group-visible-reply-tool`, `message-tool-stranded-final-reply`, `group-message-tool-unavailable-fallback`, `cron-send-then-continue`. `runtime-tool-message-tool` skipped. - Fail: `cron-failed-tool-terminal-finalization` (Codex cell), `a2a-message-tool-mirror-dedupe`, `message-delivery-decision-inspection`, `subagent-forked-context`, `yield-rejection-no-warning` (Codex cell). Each fails in the same runtime cells on unpatched main `adb12365084` on this host, so these failures already exist on main and are not caused by this change. **Unit:** - New matrices in the Codex dynamic-tool and embedded terminal-hook suites, plus a cron run assertion. On main, exactly the bug cells fail (7 failed); with this PR all pass. - 17 affected files, 572 tests, all passing. This includes the existing duplicate-reply protection suites (`message-tool-terminal*.test.ts`, `dynamic-tools.source-reply`, `run-attempt-lifecycle-controller`, `event-projector.source-finish`, `message-tool-execution`) and `agent-tools.prefix-stability`, all unchanged. **Lint:** `oxlint --type-aware` reports `max-lines` on `run-attempt-dispatch.ts` and three unresolved-type errors in `dynamic-tools.ts`. All four already appear on main with the same local setup. Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#176141) Related: openclaw#170653, openclaw#176092 ## What Problem This Solves Fixes: a cron job stops right after it sends a message to its own delivery target, so its next steps never run. ## User Impact User impact: a cron job can send to its configured chat with the `message` tool and then continue, for example to update a state file or ledger. Before this fix the turn ended about 0.3 s after the send. A job that recorded "reserved" before sending never recorded "sent", and the next run refused to post because it could not prove delivery. Chat replies are unchanged. ## Why This Change Was Made Cron runs use the job's delivery target as the turn's current source. Since openclaw#170653, a confirmed send to that source with `final` omitted counts as the final source reply: - Codex interrupts the turn (`turn.dynamic_tool_terminal_release`, then `turn/interrupt`). - The embedded runner returns `terminate: true`. A cron target is a configured destination, not a conversation the turn answers, so the send should not end the turn. What changed: - The cron source-delivery plan now owns this decision: `messageTool.finalByDefault: false`, passed to runs as `messageToolFinalByDefault`. - One resolver, `resolveMessageToolSourceReplyFinal(args, finalByDefault)`, applies it at every place that decides finality: Codex dynamic tools, the embedded terminal hook and subscriber, and CLI evidence. - An explicit `final` still wins. - `resolveMessageToolSourceReplyFinal` is now exported from `plugin-sdk/agent-harness-runtime`, next to its sibling `isDeliveredMessageToolOnlySourceReplyResult`, so Codex uses the same owner. The public export budgets go up by one (callable 2206 to 2207, total 3808 to 3809), each with a recorded reason. - Chat turns keep the default (omitted `final` ends the turn). - Delivery facts do not change. A send still counts as reaching the cron target, so `announce` still skips its fallback and no duplicate posts. - The model's turn guidance (Codex `openclaw_source_delivery` context and embedded runtime instructions) now states the rule when the default is off. Chat guidance text is byte-identical. This change is compatible with openclaw#176093. That PR keys on an explicit `final: false`, and this change does not touch it. Comparison: hermes-agent never ends a turn on a send. Its cron same-target guard returns a skipped tool result and lets the turn continue (NousResearch/hermes-agent#1357). ### Decision Cron turns intentionally stop following the "omitted `final` ends the turn" default from openclaw#119605/openclaw#170653. That default fits a chat, where the send answers the inbound message. A cron target is a configured destination, and the job decides when it is done. - **Tradeoff accepted:** a cron send with `final` omitted costs one more model call, the call openclaw#170653 removed. Losing a job's post-send steps without notice costs more. - **Users see no duplicates:** `announce` still skips its fallback after a send, and `none` keeps the final text private. - **Unchanged:** chat turns and an explicit `final`. ## Evidence **Live failure (Codex runtime, stock main):** - A daily cron photo job sent its photo (`ok: true`). - The trajectory then shows `tool.result`, then `turn.dynamic_tool_terminal_release` 4 ms later, then `model.completed` with no assistant text, then `session.ended`. - The job's next step, marking its ledger entry `sent`, never ran. The next run blocked on the unconfirmed entry. **End-to-end, QA Lab** (real gateway, cron scheduler, qa-channel, mock-openai; the Codex cell runs the real `codex app-server`). New scenario `cron-send-then-continue` covers delivery modes `none` and `announce`. In each, the model sends to the delivery target without `final`, then writes a marker file, then finishes. | | embedded | codex | |---|---|---| | main `6d14590f417` (no fix) | fail: one request, turn ended after send | fail: one request, turn ended after send | | this PR | pass: send, then `write`, one channel message per mode | pass: send, then `bash`, one channel message per mode | Each runtime cell's scenario details now include the request trace for each delivery mode (`message -> next tool -> final`, plus what qa-channel received). This run is at the PR head: ```text codex none: message -> exec_command -> final; channel=["QA-CRON-SEND-CONTINUE-SENT"] | announce: message -> exec_command -> final; channel=["QA-CRON-SEND-CONTINUE-SENT"] embedded none: message -> write -> final; channel=["QA-CRON-SEND-CONTINUE-SENT"] | announce: message -> write -> final; channel=["QA-CRON-SEND-CONTINUE-SENT"] ``` On main, both cells stop after the first request: `requests=[{"tool":"message",...}]`, and no further tool call follows. **Regression scenarios on both runtimes:** 10 message-tool, cron, sub-agent and A2A scenarios, run under `--runtime-pair openclaw,codex`. - Pass, with no change in the chat paths: `group-visible-reply-tool`, `message-tool-stranded-final-reply`, `group-message-tool-unavailable-fallback`, `cron-send-then-continue`. `runtime-tool-message-tool` skipped. - Fail: `cron-failed-tool-terminal-finalization` (Codex cell), `a2a-message-tool-mirror-dedupe`, `message-delivery-decision-inspection`, `subagent-forked-context`, `yield-rejection-no-warning` (Codex cell). Each fails in the same runtime cells on unpatched main `6d14590f417` on this host, so these failures already exist on main and are not caused by this change. **Unit:** - New matrices in the Codex dynamic-tool and embedded terminal-hook suites, plus a cron run assertion. On main, exactly the bug cells fail (7 failed); with this PR all pass. - 17 affected files, 572 tests, all passing. This includes the existing duplicate-reply protection suites (`message-tool-terminal*.test.ts`, `dynamic-tools.source-reply`, `run-attempt-lifecycle-controller`, `event-projector.source-finish`, `message-tool-execution`) and `agent-tools.prefix-stability`, all unchanged. **Lint:** `oxlint --type-aware` reports `max-lines` on `run-attempt-dispatch.ts` and three unresolved-type errors in `dynamic-tools.ts`. All four already appear on main with the same local setup. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #170147 (current-source completion subcase only).
What Problem This Solves
A delivered final source reply could trigger another model request and an extra confirmation, even though the user had already received the complete response.
User Impact
In embedded and Codex runs, a confirmed final send, reply, thread reply, poll, or added reaction to the current source ends the run in automatic and message-tool delivery modes. Models may choose a final reaction as their complete reply. Progress (
final:false), removals, no-op or failed reactions, dry runs, partial deliveries, and actions on other messages do not trigger this terminal action. Existing settled-turn handling of progress followed by empty output is unchanged.Optional no-action turns retain their existing
NO_REPLYguidance. Direct messages, mentions, commands, and accepted groups by default retain their visible-reply requirement. This does not change required/optional admission or the policy in #152786.Why This Change Was Made
The message delivery owner already knows whether an action reached the current source. Embedded and Codex-backed runs now consume that fact to finish after sibling tools settle and suppress later source text, errors, and mirrored assistant codas. Tool-authored replies awaiting delivery retain their separate whole-batch admission contract. Delivery and finality are captured before presentation hooks, so a hook that redacts or throws cannot erase a committed reply; error diagnostics remain. Only the obsolete after-action token instructions are removed. Shared harness guidance describes the completed-reply contract without promising host termination in unrelated harnesses; the host termination paths implemented and proven here are embedded and Codex.
NO_REPLYandHEARTBEAT_OKparsing, stripping, and replay compatibility are unchanged. Production models and user-authored prompts, skills, and AGENTS files still emit these tokens. Any future removal must start with telemetry/counting and an explicit migration decision.Codex's native tool handler marks tool calls as needing follow-up (stream_events_utils.rs); its loop combines that with pending input (turn.rs) before stop handling (turn.rs). I inspected these exact sibling-source files. This uses OpenClaw's existing host terminal-release mechanism; it does not change the Codex protocol.
Merge refresh (October 13)
Merged
origin/mainated4e2f875004ec8f9d933075dae402e1c11d093cinto this branch with a normal two-parent merge,c3451d7f2a6ae513369b18edc05218ee2c35c7bc. The three conflicts were generated snapshots:telegram-direct-codex-message-tool.md,discord-group-codex-message-tool.md.diff, andtelegram-heartbeat-codex-tool.md.diffundertest/fixtures/agents/prompt-snapshots/codex-runtime-happy-path/. Canonical snapshot regeneration resolved them, preserving main's newer cron tool description and this PR's final-action guidance. Main's newer source-completion retry handling and test-owner changes merged automatically. No manual production-code resolution was needed; this PR's production files are unchanged from the previously reviewed head, so its clean code autoreview is retained. The follow-up silence-marker branch was not changed.The generated text change relative to the previous head is:
The remaining generated diff is hashes and derived counts. Text-only token estimates are unchanged; estimates including tools change from 24,795 to 24,797 for the DM, 25,274 to 25,276 for the group, and 25,252 to 25,255 for the heartbeat. Snapshot generation passed in 62.74s.
Merged-head validation: core source-delivery, retry persistence, terminal resolution, settled-turn finalization, terminal-hook and real-Agent suites pass 213/213 across 11 files (822.01s wrapper wall). Codex source delivery, projection, lifecycle and turn parameters pass 70/70 (540.84s); Copilot selected guidance/SDK cases pass 5/5, with 84 unrelated cases intentionally skipped (226.92s). All seven core/extension production and test type graphs pass (341.97s). Formatting passes for all 47 selected files; diff check passes. Line-cap (11.28s), max-lines (95.48s), assertion safety (208.94s), timeout-race, mock-export, config-doc and plugin-inventory ratchets pass. Scoped lint passes for 24 core files (369.75s) and 19 extension files (605.48s, including SDK declaration generation). All wrappers exited successfully; no test failure, code edit, or baseline exception was needed.
The live model measurements below remain explicitly pinned to their original measured runtime; they were not rerun for this generated-only conflict resolution. The later question-refresh failure and its test-fixture repair are described under CI follow-up. The merge was confirmed mergeable at publication; the PR remains open and unlanded.
Evidence
The original terminal hook fails the real-Agent regression: a confirmed final source action makes two model requests instead of one; the
final:falseprogress control passes. The repaired loop and source-delivery boundaries pass. Fresh review also found a throwing post-tool hook could erase committed delivery; a real-Agent regression reproduced the extra request before the fix and now passes with result redaction, argument mutation, and the error diagnostic retained.New loop assertions execute in milliseconds; most elapsed time is cold compiled-worker preparation and imports. Completed passing shards are reused where inputs stayed unchanged; canceled sibling runs and source-restoration-invalidated runs are excluded. Core and extension production/test typechecks, scoped lint, formatting, max-lines, line-cap, assertion safety, timeout-race, mock-export, config-doc and plugin-inventory checks pass. The measured-head real-Gateway runtime build (
OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build qaRuntime) passed in 408.25s at46a141ddf45b571123d0146cc54a7922b9d79001. Release-wide declaration generation was stopped after 54 minutes; the targeted SDK declaration gate used by extension lint passed. Pre-merge head078d15c7eb9c00d5b0b5463d71ce499c39663490passes full-branch isolated Codex autoreview through P2, with no findings, after fixing the confirmed hook-exception finding. Final scoped extension lint passes (223.18s); assertion safety (41.05s), max-lines (43.34s), and line-cap (9.19s) pass again before push.CI follow-up
Question-refresh CI repair
Repair commit:
13d8115b40ebf4a08829488d900a14ce1eee3f32. GitHub confirms this head is mergeable; CI run 38372900973 has started (preflightin progress). CI completion is not claimed.The previous head's CI run 38368011842 failed the gateway-backed case in
extensions/codex/src/app-server/run-attempt.question-refresh.test.tswhile queueing input. The failure occurs beforereload_runtime, and this fixture makes no final source send or reaction. Its request counter also prevents terminal release while native user input remains outstanding, so changing that production policy would not repair this failure.Five unchanged-head repetitions reproduced a related earlier failure in the same case: four runs passed; the fifth failed before the question prompt was delivered. Running the same five-file CI scope also failed that case (23 passed, one failed). The fixture froze
Dateand timeout callbacks while execution deadlines useperformance.now()captured before asynchronous preparation. Cold preparation could therefore exhaust the real five-second monotonic budget, and subsequent fake-clock polling fired an already-expired deadline.The fixture now freezes
performancewith its other clocks. It also retains the zero-advance prompt polling introduced upstream in #170709. CI's synthetic merge already had that polling change; freezing the missing clock is the additional repair. No production code, timeout budget, behavior assertion, prompt, or snapshot changes. The existing gateway/secret/staged-secret scenarios remain the regression coverage.Validation: the five-file CI scope passes 24/24 (390.41s). Codex source-reply, projector, lifecycle and turn-parameter checks pass 70/70 (299.90s); Copilot passes all five selected cases (202.92s). Extension-test types pass (12.63s), scoped lint passes (172.73s), and formatting passes (0.55s). Line-cap (22.26s), max-lines (93.22s), assertion safety (121.34s), timeout-race (20.85s), and mock-export (43.36s) ratchets pass. Isolated review of the repair is clean through P2. Core source delivery, terminal resolution, settled finalization, retry persistence and terminal-hook checks pass 213/213 across 11 files (478.78s). Five repaired fresh-process repetitions pass all three cases each: 265.80s, 87.69s, 56.69s, 61.11s and 86.08s. All wrappers joined successfully and verified their input generations. Repair size: production +0/-0; tests +7/-3 relative to the prior head. Prompts and generated snapshots are unchanged. The existing live-model measurements remain pinned to their original runtime head.
The first ready-PR run exposed stale partial-delivery and media-payload expectations, a missed Twitch test caller of the renamed hook, and the existing 1,000-byte policy-fragment budget. The test callers/expectations are migrated, and redundant guidance is shortened to retain that budget. The partial-delivery owner passes 98/98 (59.35s), Twitch 12/12 (120.30s), turn parameters 11/11 (82.09s), and the two corrected media cases 2/2 (354.63s, dominated by module import/transform). The selected test typechecks pass (667.65s including artifact waits). The final partial-delivery assertion uses the canonical state without growing the oversized test file; its two cases pass (205.16s). The exact CI base passes the original partial/Twitch assertions, confirming branch attribution. A later changed-extension shard found two Copilot assertions matching redundant wording removed for the budget; both now assert the completed-reply contract. Shared guidance uses that contract without promising native termination to unrelated harnesses. The final Codex turn-parameter suite passes 11/11 (177.00s wrapper wall). The two Copilot files pass all five selected cases (179.27s); unchanged assertions pass all five on exact CI base
0348a2526c561d8ccce61bfd23931024a6b8f13e(224.21s), establishing attribution.On this Mac, the real-Gateway Codex cache test gets past the repaired size check but fails because the native request omits
instructions; the untouched exact CI base fails at the same assertion. Branch wall time was 280.33s. Separately, CI'sagents-sessionstype failure atmain-session-restart-recovery-admission.test.ts:705reproduces identically on exact basec2074b2b7c9bb4526a01f7ec2845b8aa712ff535(20.16s). Neither is claimed passing locally.Pre-merge CI and review disposition
Pre-merge head
078d15c7eb9c00d5b0b5463d71ce499c39663490CI run 38362337380 completed with the changed-code suites passing, including the repaired Copilot shard.openclaw/ci-gateis red becausechecks-node-compact-small-4fails two Teams reaction-read integration assertions. This is inherited from exact CI basec146b99c60acdad642f90289d8655745f19e8f3e: its4526ce20ef05d(#151128) decoder reads Graph's nesteduser.user, whiletest/msteams-read-authority.integration.test.tsstill supplies the flat fixture. Both failures reproduce unchanged on that base in 126.32s (users: []versus the expected user); the same two cases pass on this branch in 79.58s. The CI classifier calls this new because its older scheduled-main job passed and it did not compare selected scope; the exact-base reproduction establishes inheritance. No unrelated Teams code or fixtures are changed here.ClawSweeper reviewed pre-merge head
078d15c7eb9c00d5b0b5463d71ce499c39663490: both prior Copilot findings are resolved, and there are no actionable code findings. Its sole before-merge item was classifying the Teams failure, now reproduced above. The full-branch isolated review is also clean through P2.Proof limit: native Codex and Telegram Test Server E2E were not run; the supplied live proof is the isolated macOS Gateway/Ollama QA channel comparison, with Codex lifecycle/projector coverage in process.
Why optional silence guidance stays
A separate 1,800-trial probe on this Mac tested compact source-derived prompts through direct provider APIs and native Ollama, including synthetic successful tool results. Clean no-text turns were 0/60 for Sonnet, 20/60 for Haiku, 28/30 for Opus (two U+200B responses), 60/60 for each tested OpenAI interface/model, and 0/60 for each Qwen model. Literal
NO_REPLYwas substantially more reliable: Sonnet 60/60, Opus 30/30, Haiku 58/60, and Qwen 8B 47/60. Qwen 4B often exhausted its output budget; these results do not establish its eventual completion behavior. This is direct API evidence, separate from the full Gateway comparison below.The probe also observed duplicate confirmations after successful source actions. Host termination avoids asking for that continuation at all. It does not rely on every model reliably producing an empty assistant message.
Prompt changes
Only obsolete current-source after-action silence advice is removed; optional no-action token guidance remains. Boot notifications and native Feishu drive-comment actions retain their advice because they can send outside the current-source terminal path. Representative changes:
Snapshots were regenerated with
pnpm prompt:snapshots:gen; generated outputs were not hand-edited. Generator estimates (text / including dynamic tools):These are rough
ceil(chars/4)estimates, not provider billing counts.Native local-model comparison
Completed 160 fresh-session turns on macOS: four scenarios × two models × two revisions × N=10. Baseline:
799b7a347c502912efb704b1722e117bc0a644ed. Branch:46a141ddf45b571123d0146cc54a7922b9d79001. The previous branch measurements at20ae1fcc5502b884e80f65a8ad3e2de58439da16are archived and superseded by this complete rerun after the prompt-budget repair.These are real native Ollama calls through an isolated OpenClaw Gateway, the embedded harness, automatic source delivery, and the QA channel. Input/transport fixtures are synthetic. This exercises real model execution, message tools, delivery, and settled-turn finalization at the Gateway/channel boundary; it is not external messaging-service delivery proof. Optional no-action and heartbeat scenarios were excluded after the scope decision to retain their existing guidance; the separate provider silence probe covers that decision.
The baseline made 28 extra native calls across 28 confirmed-final turns. The branch made 0 across 29. Baseline produced 22 retained source text replies after first final receipt, or 45 visible text IDs including previews. The branch counts were 1 retained source text and 1 visible text ID including previews. The branch exception is a same-native-response sibling-tool duplicate: one 4B response contained two identical final sends, and both reached the transport before the first persisted tool result. This is included in all duplicate/post-receipt counts, not a later model continuation. Actual tool-start/hook-confirmation timestamps are unavailable; transport receipts do not establish that boundary.
All-run duplicates changed 25 → 5. Four remaining branch duplicates came from capped 4B outputs with no confirmed final tool action; the fifth is the sibling-tool send above. Required numeric controls produced exactly one correct text reply and no tool calls in 40/40 baseline turns and 40/40 branch turns. Across all 160 runs: leaked-token turn count 1, 0 canned host fallbacks, 0 missing required visible replies, 0 error-marked host replies, and 0 harness errors. The branch leaked-token turn exposed
NO_REPLYin 54 transient preview edits during 4B group-mention deliberation before its clean13final. It was a no-tool, pre-final output path with the intentionally retained optional group guidance; no parser, prompt, or parameter was retuned. Successful final reactions: 4B 0/10 → 2/10; 8B 10/10 → 10/10. Successful final source sends: 4B 8/10 → 7/10; 8B 10/10 → 10/10. Semantic action failures stay in the data; prose mentioning the requested marker does not count as a source send.Settings were frozen: native Ollama 0.40.3;
qwen3:4bandqwen3:8b, Q4_K_M; temperature 0.2; 32,768 context; 1,024 output limit;think:falseplus/no_thinkon every input. Stock 4B still emitted deliberation and some calls hit the cap (15 baseline, 11 branch; all 4B). No settings or scenario prompts were retuned after seeing results. These small samples establish observed host behavior, not improved model action selection. Wall times are observations on a shared Mac, not a throughput claim.Counts below are totals per cell. Time and prompt-token columns are means; native prompt tokens sum
prompt_eval_countacross every request in a turn. Wall time includes admission through settled-turn observation. Leaks include temporary previews. Missing means no required visible action; semantic failures are separate. Canned fallback matches only the two exact host fallback strings.Conditional analysis requires an actual native final call matched one-to-one to successful exact-source transport receipts. Sends are final unless explicitly
false; reactions require explicittrue, addition, and the current source message. Post-receipt text is ordered by QA cursor, including previews and same-response sibling sends. The final duplicate column isolates multiple final effects from the first native response; it is not subtracted from the other columns.—means no confirmed final to assess.Reproduction from each pinned, built checkout:
Use
branch-finalwithTURN_FINISH_EXPECT_HEAD=46a141ddf45b571123d0146cc54a7922b9d79001for the branch. The harness boots via plainpnpm openclaw --profile … gateway run, validates generated config, and waits for the QA inbound poll acknowledgment after dispatch settles. The daemon, Gateway state/config/profile/ports, and workspaces are isolated; no operator Gateway or shared Ollama listener is changed.Final follow-up commit
078d15c7eb9c00d5b0b5463d71ce499c39663490only updates shared non-embedded harness wording, the matching tests, and Codex snapshots; the measured embedded runtime and model-facing inputs are unchanged. Raw evidence, request ownership audit, native usage, exact-source receipts, method, and generated tables are retained under/private/tmp/oc-lm-turn-finish/measurement/.audit.jsonverifies exact heads, all 160 unique runs, N=10 cells, request ownership, frozen native settings, mention facts, automatic delivery, complete usage, and control behavior. This is macOS-only proof.Change size
Production: +227/-182 lines (net +45). Tests: +817/-249; generated snapshots: +46/-46; docs: +6/-4. The positive production delta carries canonical delivery completion through the Codex lifecycle and output projector, and suppresses later embedded output across stream/final/error paths. Nearby obsolete branches were removed; further reduction would obscure these ownership boundaries.
Follow-ups and scope
donetool and changes to required/optional policy remain undecided.NO_REPLYon required turns, an opposite policy direction. [Feature]: Distinguish clean-empty cron completions from deliberate silence #162342 is an issue proposing separate cron clean-empty and deliberate-silence outcomes; that outcome/status design remains separate.