Repository navigation
refactor(agents): consolidate runner, compaction, and delivery flow - #167325
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. |
|
Coverage log, part 1 of 3. Per-file decisions: rows 1–132 of 380Base 643 net production lines removed (1,069 added / 1,712 deleted) across 103 changed or new production files. Tests, fixtures, test support, generated files, and declarations are excluded from that count. All 285 assigned runner files and 26 assigned subscriber files have recorded decisions. This complete table also includes adjacent owners, for 380 unique files in total. There are no decision gaps or changed-file focused-test-target gaps. The entries record implementation and differential evidence; validation results belong to the PR's proof summary.
|
|
Coverage log, part 2 of 3. Per-file decisions: rows 133–261 of 380Base 643 net production lines removed (1,069 added / 1,712 deleted) across 103 changed or new production files. Tests, fixtures, test support, generated files, and declarations are excluded from that count. All 285 assigned runner files and 26 assigned subscriber files have recorded decisions. This complete table also includes adjacent owners, for 380 unique files in total. There are no decision gaps or changed-file focused-test-target gaps. The entries record implementation and differential evidence; validation results belong to the PR's proof summary.
|
|
Coverage log, part 3 of 3. Per-file decisions: rows 262–380 of 380Base 643 net production lines removed (1,069 added / 1,712 deleted) across 103 changed or new production files. Tests, fixtures, test support, generated files, and declarations are excluded from that count. All 285 assigned runner files and 26 assigned subscriber files have recorded decisions. This complete table also includes adjacent owners, for 380 unique files in total. There are no decision gaps or changed-file focused-test-target gaps. The entries record implementation and differential evidence; validation results belong to the PR's proof summary.
|
|
|
Codex review: blocked before merge. Reviewed October 8, 2026, 12:36 PM ET / 16:36 UTC. ClawSweeper reviewWhat this changesThis PR consolidates repeated agent execution, cancellation, conversation summarization, delivery, and provider-failure handling while preserving existing contracts. Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness⛔ Blocked before merge - 2 items remain Keep this owner-authored consolidation open. The introduced diff contains useful remaining work, and review found no concrete correctness or security regression. Confidence in runtime equivalence rests mainly on source inspection and reported differential/unit validation. Priority: P3 Before merge
FindingsNone. Provenance
Tests
Agent review detailsHow this fits togetherThe agent runtime turns user requests and conversation history into model requests, tool execution, and delivered replies. Its summarization and cancellation paths keep conversations within model limits and settle interrupted work. flowchart TD
A[User request and conversation history] --> B[Prepared model and credentials]
B --> C[Agent attempt runner]
C --> D[Model stream and tools]
C --> E[Conversation summarization]
D --> F[Reply delivery and completion]
E --> C
G[Cancellation or provider failure] --> C
Technical reviewBest possible solution: Keep the consolidation within the existing runtime owners and preserve its explicit differences in cancellation, redaction, delivery, prompt bytes, and public declarations. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes behavior-preserving consolidation rather than a reported malfunction. Is this the best way to solve the issue? Yes: sharing repeated operations in their existing owners is a maintainable direction, and the reviewed hunks retain the relevant ordering and variant-specific contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against aa236d49ac68. Provenance checked
TestingProof path: unit tests only. Added test files: 3. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfacePR surface statistics unavailable: the file list is incomplete. Stored data modelPersistent data-model change detected: 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 |
|
Compatibility review for exact head I fetched every page of the PR files API and compared its 107 unique paths with No schema, migration, persisted-data shape, protocol shape, or upgrade path changes are introduced. Existing transcript and delivery operations remain with their owners; the shared code retains field omission, ordering, recovery, and replay behavior. The final native SDK comparison also reports zero added/removed entrypoints and zero changed signatures or reachable declarations. All three compaction prompt byte comparisons are identical. The PR body records the full 529-file / 8,682-test run, focused proof after the SDK restorations, and exact source identities. The complete 380-file coverage log is linked there. No compatibility waiver or migration is needed; these two compatibility checklist items are resolved by the complete file inventory and contract proof. The review reports no concrete correctness or security findings. Exact-head hosted CI remains the landing gate. |
…penclaw#167325) * refactor(agents): consolidate embedded runner and delivery mechanics * refactor(agents): keep defaults and compaction setup explicit * refactor(agents): preserve reachable SDK contracts * refactor(agents): preserve chunker SDK declaration
## What Problem This Solves Routine diagnostic instrumentation builds state and performs message/tool-schema work with no product consumer. The chat pane keeps a separate timing buffer that is only written; the Debug page reads the Gateway event log instead. Agent preparation also recounts compaction messages and serializes tool definitions solely for routine debug summaries. ## User Impact No user-visible behavior, configuration, protocol, or SDK change. Routine successful operations no longer produce the retired trace summaries; operator failures, lifecycle events, and documented slow-stage diagnostics remain available. ## Why This Change Was Made Remove the pane-local timing buffer, correlation map, timing-only paint callback, hydration timing events, and their mechanism-only tests. Keep the real after-paint hydration scheduler, send/progress/request clocks, queue state, recovery, and Gateway timing protocol unchanged. Remove CLI argv/environment/session trace formatting, Decision tool-surface measurement and its first-primary-request observer, compaction debug recounts, the now-orphaned provider routing log formatter, and routine prompt/run/memory-preflight success traces. Authentication/environment policy, Decision pruning, compaction execution, failure logs, OTel IDs/events, and documented slow-stage warnings stay with their existing owners. No config, protocol, SDK, persistence, dependency, or release change. Net production removal: **868 lines** (+4/-872 against the branch base, excluding tests, fixtures, test support, generated files, and declarations). Test reductions only remove assertions for retired instrumentation; retained behavior coverage stays. ## Best-effort tradeoffs accepted - Pane timing history and cross-ACK diagnostic correlation disappear rather than retaining a bounded map for an unread buffer. The latest bound fix [#171146](#171146) describes diagnostic metadata, not an activation/foundation. Actual outbox/progress clocks and Gateway timing fields remain; slow startup remains diagnosed by the Gateway. - CLI per-invocation argv, auth-key-name inventories, and hashed resume summaries are no longer logged. The extracted owner came through [#166711](#166711); its real auth/environment operations remain unchanged. Operators retain failures and existing content-free process outcome metadata. - Decision debug schema-size counters and the first-request observation callback disappear. [#153340](#153340) used the counters for experiment verification; the feature is implemented and its permission/pruning/restoration tests remain. No model quality, token-cost, or performance claim depends on these normalized-character counters. - Compaction no longer walks/re-estimates all messages before and after work just to print debug deltas/top contributors. The extracted diagnostics owner came through [#167325](#167325); real conversation detection, model-call IDs, hooks, failures, fallback warnings, and usage accounting stay. No recovery or durability guard is removed. - Routine successful prompt/run lifecycle and memory preflight traces are quiet. Canonical lifecycle events, failure logs, slow-stage warnings, and actual policy decisions stay. No security, live-authority, concurrency, or data-integrity guard is removed. ## Evidence Initial exact-head CI on b2922ae (run 38857825275) exposed two stale test expectations for the deliberately removed logs. The repair removes only the CLI info-log spy/assertion and the Decision diagnostic-record assertion/setup. All three CLI purposes retain output/trigger/spawn assertions; all four recorded-carrier cases retain request, budget, compaction, usage, and error assertions. No production code changes in this CI repair. Independent P0-P2 review of the complete two-file repair is scoped-clean, with final unchanged-source verification complete; formatting and diff checks pass. | Initial failing job | Attribution | | --- | --- | | checks-node-changed-compact-large-1-1 (116833564544) | Ours: three CLI utility cases asserted the retired trace. Assertions for actual execution remain. | | checks-node-changed-compact-large-1-2 (116833564644) | Ours: two recorded-carrier cases asserted the retired Decision log. All four behavioral combinations remain. | | check-prod-types (116833927964) | Unrelated unused LitContent import in ui/src/pages/chat/chat-view.tsx:16. Identical TS6133 actually reproduced on unrelated PR #173879, head 5ad6fb8, run 38859044898, [job 116838613238](https://github.com/openclaw/openclaw/actions/runs/38859044898/job/116838613238). This PR does not change that file. | | check-lint-core-2 (116833927918) | Same untouched import; identical eslint(no-unused-vars) actually reproduced in the independent run, [job 116838613165](https://github.com/openclaw/openclaw/actions/runs/38859044898/job/116838613165). | | openclaw/ci-gate (116835410676) | Summary of the four jobs above, not a separate product failure. | Focused local replays of the recorded-carrier cases and CLI utility suite were stopped after more than ten minutes without assertion results on the saturated host (exit 143). These are incomplete proof, not passing tests or evidence of a product defect. The fresh suppression run completed with 2 passed / 1 failed: the untouched scripts/lib/control-ui-warm-reload-probe.ts unbound-method allowlist mismatch. Vitest duration 350.15s, wrapper 476.06s; no test, timeout, retry, skip, or suppression change. The next exact-head hosted CI is the broad gate; no CI rerun or unchanged-head push was requested. Independent isolated review completed with no accepted/actionable P0-P2 findings; final unchanged-source verification passed. Exact-head hosted CI is pending. No merge or green CI gate is claimed yet. Completed local boundary proof: nine UI files, 231 tests; provider attribution policy, 19 tests; production core and UI typechecks, exit 0; runtime value cycles: 0; Madge cycles: 0; mock-export and assertion-safety shrink ratchets pass. Every runtime/test command uses a task-owned HOME/OpenClaw/XDG environment. The changed checker completed: core-test graph types (29 graphs), formatting, core lint, UI style checks, cycles and architecture/security guards passed. Its earlier attributable core/UI type and ratchet failures were repaired and those exact gates replayed successfully. Dead-export findings remain in untouched subagent/session/Gateway/UI owners; they are not claimed inherited solely by path. Agent-focused proof remains incomplete: the memory-fallback private-buffer case timed out at 120 seconds; the following usage-accounting case passed at 119 seconds. Host load was about 177 on 16 cores. The task-owned run was stopped rather than extending timeouts or changing tests; no passing or product-defect conclusion is drawn from it. Exact-head CI must cover those agent suites. If CI fails in a changed graph, attribution/replay/drop rules apply. Initial UI fork startup timeout left five files unexecuted, not failed assertions; all five subsequently passed in the recorded focused runs with unchanged timeouts. An initial agent build was invalidated by the orphan-formatter cleanup during artifact preparation; final frozen-source proof replaces that attempt. The local suppression suite reports an untouched warm-reload-probe expected-entry mismatch; the diff adds no suppression. The broad local check also reports an untouched chat-message max-lines suppression against moving main. Neither is represented as a successful gate or an exact-head hosted CI attribution.
## What Problem This Solves Routine diagnostic instrumentation builds state and performs message/tool-schema work with no product consumer. The chat pane keeps a separate timing buffer that is only written; the Debug page reads the Gateway event log instead. Agent preparation also recounts compaction messages and serializes tool definitions solely for routine debug summaries. ## User Impact No user-visible behavior, configuration, protocol, or SDK change. Routine successful operations no longer produce the retired trace summaries; operator failures, lifecycle events, and documented slow-stage diagnostics remain available. ## Why This Change Was Made Remove the pane-local timing buffer, correlation map, timing-only paint callback, hydration timing events, and their mechanism-only tests. Keep the real after-paint hydration scheduler, send/progress/request clocks, queue state, recovery, and Gateway timing protocol unchanged. Remove CLI argv/environment/session trace formatting, Decision tool-surface measurement and its first-primary-request observer, compaction debug recounts, the now-orphaned provider routing log formatter, and routine prompt/run/memory-preflight success traces. Authentication/environment policy, Decision pruning, compaction execution, failure logs, OTel IDs/events, and documented slow-stage warnings stay with their existing owners. No config, protocol, SDK, persistence, dependency, or release change. Net production removal: **868 lines** (+4/-872 against the branch base, excluding tests, fixtures, test support, generated files, and declarations). Test reductions only remove assertions for retired instrumentation; retained behavior coverage stays. ## Best-effort tradeoffs accepted - Pane timing history and cross-ACK diagnostic correlation disappear rather than retaining a bounded map for an unread buffer. The latest bound fix [openclaw#171146](openclaw#171146) describes diagnostic metadata, not an activation/foundation. Actual outbox/progress clocks and Gateway timing fields remain; slow startup remains diagnosed by the Gateway. - CLI per-invocation argv, auth-key-name inventories, and hashed resume summaries are no longer logged. The extracted owner came through [openclaw#166711](openclaw#166711); its real auth/environment operations remain unchanged. Operators retain failures and existing content-free process outcome metadata. - Decision debug schema-size counters and the first-request observation callback disappear. [openclaw#153340](openclaw#153340) used the counters for experiment verification; the feature is implemented and its permission/pruning/restoration tests remain. No model quality, token-cost, or performance claim depends on these normalized-character counters. - Compaction no longer walks/re-estimates all messages before and after work just to print debug deltas/top contributors. The extracted diagnostics owner came through [openclaw#167325](openclaw#167325); real conversation detection, model-call IDs, hooks, failures, fallback warnings, and usage accounting stay. No recovery or durability guard is removed. - Routine successful prompt/run lifecycle and memory preflight traces are quiet. Canonical lifecycle events, failure logs, slow-stage warnings, and actual policy decisions stay. No security, live-authority, concurrency, or data-integrity guard is removed. ## Evidence Initial exact-head CI on b2922ae (run 38857825275) exposed two stale test expectations for the deliberately removed logs. The repair removes only the CLI info-log spy/assertion and the Decision diagnostic-record assertion/setup. All three CLI purposes retain output/trigger/spawn assertions; all four recorded-carrier cases retain request, budget, compaction, usage, and error assertions. No production code changes in this CI repair. Independent P0-P2 review of the complete two-file repair is scoped-clean, with final unchanged-source verification complete; formatting and diff checks pass. | Initial failing job | Attribution | | --- | --- | | checks-node-changed-compact-large-1-1 (116833564544) | Ours: three CLI utility cases asserted the retired trace. Assertions for actual execution remain. | | checks-node-changed-compact-large-1-2 (116833564644) | Ours: two recorded-carrier cases asserted the retired Decision log. All four behavioral combinations remain. | | check-prod-types (116833927964) | Unrelated unused LitContent import in ui/src/pages/chat/chat-view.tsx:16. Identical TS6133 actually reproduced on unrelated PR openclaw#173879, head 5ad6fb8, run 38859044898, [job 116838613238](https://github.com/openclaw/openclaw/actions/runs/38859044898/job/116838613238). This PR does not change that file. | | check-lint-core-2 (116833927918) | Same untouched import; identical eslint(no-unused-vars) actually reproduced in the independent run, [job 116838613165](https://github.com/openclaw/openclaw/actions/runs/38859044898/job/116838613165). | | openclaw/ci-gate (116835410676) | Summary of the four jobs above, not a separate product failure. | Focused local replays of the recorded-carrier cases and CLI utility suite were stopped after more than ten minutes without assertion results on the saturated host (exit 143). These are incomplete proof, not passing tests or evidence of a product defect. The fresh suppression run completed with 2 passed / 1 failed: the untouched scripts/lib/control-ui-warm-reload-probe.ts unbound-method allowlist mismatch. Vitest duration 350.15s, wrapper 476.06s; no test, timeout, retry, skip, or suppression change. The next exact-head hosted CI is the broad gate; no CI rerun or unchanged-head push was requested. Independent isolated review completed with no accepted/actionable P0-P2 findings; final unchanged-source verification passed. Exact-head hosted CI is pending. No merge or green CI gate is claimed yet. Completed local boundary proof: nine UI files, 231 tests; provider attribution policy, 19 tests; production core and UI typechecks, exit 0; runtime value cycles: 0; Madge cycles: 0; mock-export and assertion-safety shrink ratchets pass. Every runtime/test command uses a task-owned HOME/OpenClaw/XDG environment. The changed checker completed: core-test graph types (29 graphs), formatting, core lint, UI style checks, cycles and architecture/security guards passed. Its earlier attributable core/UI type and ratchet failures were repaired and those exact gates replayed successfully. Dead-export findings remain in untouched subagent/session/Gateway/UI owners; they are not claimed inherited solely by path. Agent-focused proof remains incomplete: the memory-fallback private-buffer case timed out at 120 seconds; the following usage-accounting case passed at 119 seconds. Host load was about 177 on 16 cores. The task-owned run was stopped rather than extending timeouts or changing tests; no passing or product-defect conclusion is drawn from it. Exact-head CI must cover those agent suites. If CI fails in a changed graph, attribution/replay/drop rules apply. Initial UI fork startup timeout left five files unexecuted, not failed assertions; all five subsequently passed in the recorded focused runs with unchanged timeouts. An initial agent build was invalidated by the orphan-formatter cleanup during artifact preparation; final frozen-source proof replaces that attempt. The local suppression suite reports an untouched warm-reload-probe expected-entry mismatch; the diff adds no suppression. The broad local check also reports an untouched chat-message max-lines suppression against moving main. Neither is represented as a successful gate or an exact-head hosted CI attribution.
What Problem This Solves
The embedded agent runner and its immediate compaction, delivery, and failover owners repeat operations across closely related paths, making behavior harder to maintain consistently.
User Impact
No user-visible behavior change. Features, prompt and error text, configuration, CLI and protocol shapes, persisted data, authority checks, recovery, replay, and plugin SDK declarations remain unchanged.
Why This Change Was Made
Shared code now handles cancellation settlement, checkpoint prompt scaffolding, tool-payload traversal, delivery receipt projection, ordered failover classification, stream construction, and chunk metadata emission. Real differences remain explicit, including abort-error construction, redaction mode, omitted versus undefined fields, and transport/recovery behavior. Single-use forwarding and redundant internal parameter threading are removed where ownership already supplies the value.
This is d03's third and final PR, submitted under the coordinator's 500–999-line exception with complete coverage: 643 net production lines removed (1,069 added / 1,712 deleted), across 103 production files. Counts use
git diff --numstat origin/main...HEAD, excluding tests, fixtures, test support, generated files and declarations. Of this reduction, 314 lines are inside the runner directory and 329 are in its immediate owners/callers.The largest-file-first pass covers all 285 runner production files and 26 assigned subscriber files, then adjacent owners. It implemented and measured shared-core alternatives, including rejected prototypes that were longer or obscured behavior. The implementation window exceeded two hours. Complete per-file decisions and measured alternatives: part 1, part 2, part 3.
Evidence
34e39db29179ceb9b7f2ce09f727c2aeded0b83a: zero added/removed entrypoints and zero changed exports or reachable declarations. Testbox run, verified source treea1f1b52fe5b6607bfea3089ad3e036b947425d21; comparison command completed in 567.6 seconds.328c9d7c559ba43c08b4338fdcd68f6efe98ef14, verified treecec7c62a0837da6e52597fafb1691cb0eacd2597. Runtime/E2E build passed in 341.9 seconds; test wrapper took 2,262.99 seconds. The task-owned Testbox lease was stopped after proof.pnpm test <exact files> --maxWorkers=1; the final diff retains three of those fixture changes. No test timeout, retry, skip, or worker budget changed. The assertion-safety baseline shrinks only.Local changed-check attribution
node scripts/check-changed.mjspassed core production/test types and its preceding checks, then stopped at two untouched branch-base dead exports:SessionPendingInputStateinsrc/config/sessions/session-accessor.sqlite-pending-inputs.ts, fixed upstream by19f37f076862830f9b8953287f94a4725e3b8908.discardStreamSegmentIndexesinui/src/pages/chat/stream-segment-pruning.ts, fixed upstream bye8e341ecebf70a0d3802b3f52deecb4d53ec1ebb.Both files are byte-identical to this branch's base. Fresh target main
ea7cc1066568fbbeece9151c497ecab15923bd2apassed all three native deadcode scans with zero findings. All eight checks after that stop were run separately and passed. These are resolved branch-base findings, not a current-main-red waiver; exact-head hosted PR checks remain the landing gate.