Repository navigation
fix: avoid repeated transcript copies during manual compaction - #199840
Conversation
Use the existing internal read-only branch accessor for manual Gateway preflight. Preserve hydrated immutable payload ownership through preparation instead of requesting writable SDK copies. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> Co-authored-by: jalehman <[email protected]>
Worked on by: - @RomneyDa - @vincentkoc - @jalehman Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> Co-authored-by: jalehman <[email protected]> OpenClaw-Publication: 69c46a07-b290-85a3-adca-74cdf8832368
|
🦞👀 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 uses the existing internal read-only transcript accessor during manual compaction preflight and extends the composition regression to check payload ownership. Example: Manual compaction prepares the regression fixture with seven current messages, including 500,000-character assistant outputs.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this maintainer-authored draft open: the copying defect remains on main, and this focused patch addresses it without an identified correctness regression. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway sessions.compact handler prepares a session transcript under the lifecycle owner, checks whether compaction is useful, and passes the prepared session to the existing compactor. flowchart TD
A[Manual compaction request] --> B[Session lifecycle owner]
B --> C[Prepare transcript]
C --> D[Internal read-only branch]
D --> E[Compaction preflight]
E --> F[Existing compactor]
Technical reviewBest possible solution: Use the existing internal accessor for read-only preflight while preserving writable public access and the current compaction lifecycle. Do we have a high-confidence way to reproduce the issue? Source inspection establishes the unnecessary detachment path on current main; the body reports an exact-base failing regression, but no target code was executed during this read-only review. Is this the best way to solve the issue? This is the smallest complete fix for the stated preparation-stage defect: reuse the existing read-only accessor and extend the existing composition regression without adding state, workers, or parallel owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7de99f0419bb. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +4, Tests +5. Total +9 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. 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 Reviewed November 15, 2026, 6:24 PM ET / 23:24 UTC. |
Manual preflight copy fix: retained partial evidenceIncomplete: neither cohort reached five pairs; no warm acceptance observations were collected. Each table is a separate n=3-per-arm cold prefix. Nearest-rank p95 is the maximum of three, not the frozen n=5 acceptance result. No samples are pooled, corrected, discarded or replayed. Human merge is not performance acceptance. Base: 9f0f895. Candidate: 54617a8. Workload: f30da43971c6b210df2e89962d0af639bc04107e. Source regression is base-red/fix-green; 30 delegate and 27 unchanged codec checks pass. Both exact builds and four separately tagged real-Gateway qualifiers passed. Those facts do not make the incomplete performance comparison pass. Original cohortGateway restart; seventh slot never reached measured compaction. Six native-valid cold observations, one interrupted/non-eligible slot and thirteen unattempted slots remain separate and unchanged.
Whole-process CPU/RSS include workers. Main CPU is independently sampled with uncorrected RPC bracket overhang. Heap and RSS are sampled peaks; lifecycle peaks differ from the RPC window. Parsing/transfer/thread counters cover observed primary transcript-worker tasks, not main-thread parsing or all Gateway workers; worker count 1 does not mean only one worker existed in the process. The maximum adjacent gap from the nominal 100 ms main-isolate sampler includes bracket overhang and is neither exact blocking duration nor unrelated-session RPC latency. All adverse moves are retained above. Recovery cohort 1Awaited controller call aborted; seventh slot has measured compaction but no complete cleanup/native terminal receipt. Six native-valid cold observations, one interrupted/non-eligible slot and thirteen unattempted slots remain separate and unchanged.
Whole-process CPU/RSS include workers. Main CPU is independently sampled with uncorrected RPC bracket overhang. Heap and RSS are sampled peaks; lifecycle peaks differ from the RPC window. Parsing/transfer/thread counters cover observed primary transcript-worker tasks, not main-thread parsing or all Gateway workers; worker count 1 does not mean only one worker existed in the process. The maximum adjacent gap from the nominal 100 ms main-isolate sampler includes bracket overhang and is neither exact blocking duration nor unrelated-session RPC latency. All adverse moves are retained above. Scope and remaining proofThis covers one real observed generation with synthetic fixed summaries and successful 8192-byte physical-session follow-ups for completed observations, not provider quality or a broad corpus. Neither prefix satisfies the declared cold/warm no-regression rule. Automatic compaction and during-window other-session responsiveness remain separate work. Independent raw-metadata audit: 192 raw metric cells, 320 summary cells and all 32 table rows reconciled with zero discrepancies; 199 inspected metadata files remained unchanged. Original CPU/pulse bracket overhang was 10–85 ms before and 1–79 ms after; recovery was 9–99 ms before and 21–94 ms after. Neither interrupted slot is eligible, and the empty ineligible list in each explicit six-tag aggregate does not mean no interrupted slot existed. |
Qualify the beta.4 equivalent of #199840 (canonical commit 675297f). Beta.4 delegates getBranch directly to SessionEntryNavigation and does not have the writable-copy boundary introduced by main-only #195961. Assert payload identity across repeated manual-preparation branch reads. Hydration creates private mutable containers once, so main's owned-payload brand assertion does not apply; no product ownership change is needed. Focused manual compaction regression, formatting and lint pass. Co-authored-by: RomneyDa <[email protected]>
…law#199840) * fix: avoid repeated transcript copies during manual compaction Use the existing internal read-only branch accessor for manual Gateway preflight. Preserve hydrated immutable payload ownership through preparation instead of requesting writable SDK copies. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> Co-authored-by: jalehman <[email protected]> * fix: avoid repeated transcript copies during manual compaction Worked on by: - @RomneyDa - @vincentkoc - @jalehman Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> Co-authored-by: jalehman <[email protected]> OpenClaw-Publication: 69c46a07-b290-85a3-adca-74cdf8832368 --------- Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> Co-authored-by: jalehman <[email protected]>
Related: #199561
What Problem This Solves
Fixes unnecessary transcript copying when manual compaction prepares a session, adding work on the Gateway's main thread before summarization begins.
User Impact
Manual compaction preparation no longer requests writable copies of immutable transcript payloads merely to inspect them. Performance acceptance remains pending. This PR does not fix automatic warm-session compaction or all main-thread stalls. No configuration or migration is required.
Why This Change Was Made
Use the existing internal read-only branch accessor for synchronous manual preflight, instead of requesting writable copies immediately before context projection. Public SDK mutation isolation, model-context filtering, extension behavior, and writer/cancellation checks are unchanged; no worker or cache is added.
Requested and guided by @RomneyDa.
Work sessions
Linked for team reference; these sessions aren’t public.
Evidence
9f0f89522a633826aa5c64483cca3bec3dacca34at retained payload ownership and passes with this change. Delegate suite: 30/30 passed; unchanged codec siblings: 27/27 passed.git diff --checkpass. CI-only pinned-Bun parity was not run locally. Canonical local autoreview (Codex, P0–P2) found no actionable findings in the exact-base/final local snapshot. Published head54617a8c765a8672c1459da190ad08567e38bb0ehas the same tree as reviewed/tested signed commit7bcfe0a3b7757a50ee0a759add452b620b54989a.sourcePerformancebuilds pass. Workloadf30da43971c6b210df2e89962d0af639bc04107epassed 17 isolated admission/control-flow contracts and fresh canonical local P0–P2 autoreview. All four separately tagged real-Gateway qualifiers passed and were audited: native compaction, physical-session 8192-byte continuity, matched two-request summary work, default limits, CPU brackets and cleanup.Prospective performance rule — published before comparison timing
Real manual compaction through isolated built Gateways, the same private long-session fixture, native import and same-physical-session 8192-byte follow-up. Compare exact base
9f0f89522a633826aa5c64483cca3bec3dacca34against exact published head54617a8c765a8672c1459da190ad08567e38bb0e. Workloadf30da43971c6b210df2e89962d0af639bc04107epreserves the five canonical rig/turn/mock/importer/observer files from007777bbf9917bdc62a488b9e348990fc06c6a04. Successful exact builds, fixture/workload/protocol hashes, native admission and the complete order are frozen before accepted runs. Qualification timings are excluded.Five serial interleaved baseline/candidate pairs cold, then five pairs process-warm, without profiling. Report every outcome, median, nearest-rank p95 (=maximum at n=5), min/max and spread for compaction/follow-up latency, whole-process and independently sampled main-thread CPU, RPC/lifecycle RSS and heap, and main-thread pulse gaps. Include bracket overhang and host load; all native integrity and cleanup checks must pass. No selective reruns, pooling or outlier removal.
A win requires copying reduction and measurable real-flow improvement without worse user-facing metrics. After each complete five-pair population, a 20% or greater adverse median or p95 in any measured cell stops before another population. Missing measurements block; zero-baseline/positive-candidate values stop. Smaller adverse cells remain visible and require explicit informed owner acceptance before landing. With no measurable gain, do not land as a performance improvement. Recovery must retain the interrupted original cohort and use separately declared fresh tags/bindings, never rewrite its receipts or silently combine populations.
Evidence reuse and measurement limits
The successful exact-base build is reused, not rebuilt. A separate audited schema supplement retains original install/build receipts and hashes. Whole-tree/dist fingerprints were observed at prior diagnostic admission/end and rechecked, not retroactively observed at build completion; that observation gap remains explicit. The candidate install/build binds the exact published head. Literal probe/install shell-child decoding preserves the actual recorded command without repeating the successful install.
The unchanged nominal 100 ms main-isolate sampler gives a coarse maximum adjacent gap over the inclusive RPC bracket, including overhang. It cannot resolve sub-100 ms blocking or replace other-session RPC latency. Process CPU/RSS include workers; worker-only zero counters do not mean zero main-thread parsing.
Process-warm manual compaction is not resident automatic compaction. Unrelated-session RPC probes occur after compaction, so concurrent responsiveness remains unproven. The fixture is one whole observed generation with fixed mock summaries, not a broad corpus or provider-quality test.
Worked on by