Repository navigation
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. What this changesThis PR makes isolated final answers reuse the settled engine-selected conversation instead of reopening raw history. Example: A completed workspace write receives an empty assistant response and triggers isolated finalization.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR repairs a confirmed finalization-context bug with no actionable findings; current-head CI remains pending. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe built-in agent harness passes settled conversation context to embedded history preparation, which bounds and sanitizes the tool-free provider request while the original session manager retains transcript writes. flowchart LR
A[Engine selected conversation] --> B[Settled attempt snapshot]
B --> C[Restricted finalization adapter]
C --> D[Existing history preparation]
D --> E[Tool free provider request]
E --> F[Final answer]
G[Original session manager] --> F
Technical reviewBest possible solution: Land the frozen-view handoff through the existing history owner once the reviewed head satisfies its normal CI gates. Do we have a high-confidence way to reproduce the issue? Supplied built-Gateway comparisons reproduce excluded history returning on main and disappearing on the candidate through actual isolated finalization; this review executed no target code. Is this the best way to solve the issue? The smallest complete repair transports the existing frozen selected view to history preparation, preserving its bounds and transcript custody without restoring the live engine or introducing a second context owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 41b50b4dbcba. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +60, Tests 0. Total +60 across 5 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label 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 (3 earlier review cycles)Reviewed October 27, 2026, 8:14 PM ET / October 28, 2026, 00:14 UTC (Revision 4). |
|
Thanks @ericcaiwx-star for picking up #186244. We had started on the same defect and stopped once we saw this draft, so this is yours. A few findings from our source audit that may save you a round:
The already-delivered-message admission question in the issue is tracked separately in #179003 and doesn't need to be solved here. |
|
@clawsweeper re-review The implementation and exact-head Linux Gateway proof, lifecycle/cancellation controls, and persisted-session compatibility evidence are now in the PR body for |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Final head |
|
🦞👀 Re-review progress:
|
Independent current-main Gateway proofRechecked against main The experiment used built Gateways in secretless Linux/Node 24.22.1 isolation, real
Both source requests excluded the old canary before finalization. Lifecycle records were unchanged between each settled tool-result request and its actual isolated-finalizer request: no extra bootstrap, maintenance, assemble, ingestion, afterTurn, or commitTurn calls. Auxiliary activity-summary requests were distinguished from finalizers by their system-role metadata prompt and were not counted in the table. Normal-finalization controls on both revisions returned a visible answer directly after the write, retained the selected summary/current receipt, omitted the old canary, and never entered isolated finalization. All six measured turns completed with Maintainer audit points: the fix transports the frozen settled view, not the live engine; it adds no heuristic current-turn split or assembly lifecycle; the existing history owner applies its normal byte/event and tool-result bounds. The detached regression covers reusing the original view across an empty finalizer retry. Compaction remains under the existing snapshot/capture owner's rules. Already-delivered-message admission (#179003) stays out of scope. Latest contributor head passed the two changed suites (11 tests across two routed shards), focused Oxlint, and Oxfmt in isolation. The retained selected-view regression failed on main because excluded history reappeared. Whole-PR delta: production +65/-5 (net +60), tests +104/-104 (net 0); no ceiling or baseline changed. The contributor independently supplied the same test-line repair while this experiment was running, so no redundant cleanup commit was added. These are measured HTTP request bytes, not real-provider token usage or billing. Fixtures are synthetic; no live channel, OAuth, or third-party context-engine deployment claim is made. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Refreshed main integration and Gateway proofMerged current main The history owner merged cleanly. Both responsibilities remain: main's Rebuilt both refs in secretless Linux/Node 24.22.1 isolation and ran one fresh real built-Gateway turn per ref with the selected context-engine fixture, committed workspace write, empty post-tool answer and recording SSE provider:
Both turns completed with The two focused finalization suites passed again (11 tests), as did main's bounded-context owner suite (8 tests), including cleared Anthropic runtime-context/prompt-update accounting. Focused lint and formatting passed. The PR still has zero net test-line growth and no ceiling change. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 1714e20. Thanks @ericcaiwx-star. Isolated final answers now use the context engine's selected view. |
…86288) fix(agents): use the context engine's selected view for isolated final answers Isolated final-answer finalization rebuilt the request from the raw session history instead of the view the context engine had selected, so the finalizer request restored history the engine had excluded and could grow very large. Finalization now uses a private, frozen snapshot of the engine-selected view. Evidence: built Gateway turns where the context engine excluded history and finalization ran isolated. On main the finalizer request was about 52 KB and contained the excluded raw history (three runs); with this change it was about 2.5 KB with the engine-selected summary and the current write receipt, and no excluded history (three runs, including on the head merged with current main). Finalizers offered no tools and added no context-engine lifecycle calls, and normal finalization works on both refs. Details: openclaw#186288 (comment). Production +65/-5. Thanks @ericcaiwx-star. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Isolated post-tool finalization reopened raw session history even when the selected context engine had already excluded that history from the source attempt. A short final answer could therefore send a much larger conversation to the provider.
Fixes #186244. Already-delivered-message admission is tracked separately in #179003 and is outside this repair, as confirmed by the maintainer.
Why This Change Was Made
The restricted built-in adapter passes the frozen settled model view through a host-private parameter. It uses the explicit OpenClaw transcript capture when present, otherwise the canonical settled
messagesSnapshot; an explicitly unavailable or foreign-harness projection is refused.The existing
prepareEmbeddedAttemptHistoryowner selects this view instead of rehydrated raw history and reuses the existing session byte/event window and tool-result omission policy. An empty selected view also replaces the hydrated messages. The original SessionManager retains all transcript writes and receipts.The finalizer still receives no live context engine. Its bootstrap, maintenance, ingestion, afterTurn hooks, ambient prompt contributors, tools and trajectory capabilities are not restored. Empty-finalizer retries reuse the original settled view. This adds no config/env/schema or public SDK capability and introduces no new current-turn boundary inference.
User Impact
Excluded old history stays out of the isolated finalization request while the current request, completed tool evidence and selected summary remain available. Durable history is retained. Finalization remains tool-free, and interrupted work cannot be completed by replaying tools during this step.
Evidence
Refreshed main integration
Merged main
342da13c92e0af1add7936f9bc479394f01e426cinto the latest contributor head, producinga8cad32e618122fbe474a5102890fe34e5fc9b57. The history owner preserves both main's Anthropic turn-scoped system-update clearing and the frozen selected-view snapshot. Fresh built-Gateway proof measured one finalizer request per ref: 52,085 bytes on main (excluded raw canary restored) versus 2,490 bytes on the merged candidate (summary and current write receipt retained, canary absent). Both turns completed successfully, offered zero finalizer tools, and added no engine lifecycle calls. The 11 finalization tests and 8 upstream bounded-context tests passed again, with focused lint/formatting. Test-line growth remains zero.Independent current-main comparison
Independent built-Gateway evidence compares current main
4b27ee88cec9a78377a04b2e3a352ba7c503450etwice with the candidate production code twice, plus normal-finalization controls on both revisions. Isolated finalizer requests measured 52,100 bytes on main in both runs versus 2,505 bytes on the candidate in both runs. Main restored the excluded raw canary; the candidate retained the selected summary and current write receipt without the canary. Every isolated finalizer offered zero tools and left context-engine lifecycle counters unchanged. All six measured turns completed successfully. The latest contributor head changes only tests and passed both changed suites (11 tests), focused lint and formatting. Whole-PR test-line delta is zero, without a ceiling change.Contributor's earlier proof
Named base:
63ba4974f67c1eba483f8b7121c2bf7416d75ae4.Candidate:
a037f29b1bad9717aca3a3db9559b941534e4efd.Real built CLI/Gateway proof on Linux
Both revisions completed frozen dependency installation and full builds. Final candidate full build exited 0 in 3m2.2s; the actual built CLI reported
OpenClaw 2026.10.7 (a037f29).The primary fixture uses a real Gateway,
sessions.create, two agent CLI turns and an actual committedwriteto a task-owned file. Its HTTP/SSE Responses provider and context-engine plugin are synthetic local fixtures. The empty post-tool answer really enters isolated finalization; the finalizer offers zero tools. A plain read-only continuation is not used as a substitute for that admission.ocpr prove --phase prerecorded command exit 1, with successful tool commit and clean Gateway shutdown.assemble=5,commitTurn=2,maintain=3,bootstrap=1, with no finalizer engine callbacks.chat.abort, omit its cancelled output, preserve the committed write, and close cleanly. The cancelled CLI exits 1 as expected for this cancellation control; each proof driver exits 0 only after the positive cancellation and cleanup assertions.Exact commands executed by
ocpr:Actual captured post-proof stdout
These byte counts use consistent JSON reserialization, not provider token accounting or billing. Provider usage values are synthetic. No real Discord, lossless-claw, OAuth, token-price or cache-savings acceptance is claimed. All three Gateways exited 0, closed their ports and reported clean shutdown; no Docker was used.
Regression, checks and independent review
The existing detached finalization regression failed on pre-fix code because omitted history reappeared in the finalizer. It now preserves tool receipts and the original transcript manager across empty retries. Earlier oversized-precheck and unclosed-user-turn fixture failures were separately classified and retained; they are not claimed as the product regression.
The implementation candidate passed 84 tests in eight relevant files (77.15s), including screenshot-heavy bounded current-request history, length/incomplete outcomes, unavailable context, delivery, silence, transport, detached custody and empty retries. The final test-only consolidation was rerun on this exact head: 46 tests in both changed suites plus the required runner sibling, three shards, exit 0 (26.05s). Changed-test lint and all core-test type shards passed; the production files are byte-identical to the previously reviewed and proven implementation.
The first Ready CI run 40600657717 exposed a test-line budget failure: the merge tree was already above the ceiling and this PR added 52 test lines. The final commit consolidates duplicate setup in the same two existing suites, shares source-view acceptance/rejection cases, and retains callback custody, frozen context, both transient-failure admission cases, receipt contents across empty retries, hidden prompts and subsequent real-user persistence. The complete PR now has zero net test-line growth. No baseline, config, ignore or formatter policy was changed. That first CI result remains a failure; the latest head's CI gate now passes.
The complete changed-file command exits 1 only on two global dead-export failures:
extensions/knowledge/src/scribes-catalog.ts: runPromptandui/src/pages/activity/activity-page.test-support.ts: settleActivity. The same dead-export command was actually run on the exact named base and failed on the identical two exports. Those unrelated files were not changed; the full command is not reported green.Canonical independent AutoReview of the exact candidate, pinned base, P0–P2, completed
scoped-cleanwith no actionable findings (Codexgpt-6.1-sol, no fallback). It included the complete bounded selector, limits, snapshot/capture owners, finalization caller and harness lifecycle/selection contracts. Runtime proof above is separate from that review.Exact-head hosted gates
Refreshed head
a8cad32e618122fbe474a5102890fe34e5fc9b57has a successful CI gate and exact-head ClawSweeper review: overall readiness 5/6, proof confidence 5/6, patch quality 5/6, no actionable findings. No failing jobs remain; one auxiliary auto-response job was cancelled.Merge Risk
Two-way door: reverting restores the old finalization-context selection without a schema or persisted-format change. Blast radius is the built-in OpenClaw runtime's isolated post-tool final answers; an incorrect selection could omit necessary settled context or restore excluded history. Ordinary finalization, context-engine lifecycle ownership and durable transcript writes remain unchanged.