Repository navigation
fix(usage): avoid retaining decoded incognito transcript payloads - #156673
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 retains compact navigation and usage records instead of decoded message payloads during incognito usage refresh. Example: Refresh usage for an incognito session containing 36 MiB of appended text.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: current main still retains decoded incognito transcript payloads during usage refresh, and this PR provides a focused repair with no actionable introduced defects found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe incognito usage scanner consumes immutable transcript snapshots from the session actor and produces branch-aware usage rollups and checkpoints for Gateway usage reports. flowchart LR
A[Gateway usage request] --> B[Session actor snapshot]
B --> C[Parse and project events]
C --> D[Select visible branch]
D --> E[Aggregate usage and checkpoint]
E --> F[Actor usage report]
Technical reviewBest possible solution: Keep the immediate projection in the existing memory scanner, preserving canonical navigation fields, usage contributions, and the raw-tail checkpoint hash. Do we have a high-confidence way to reproduce the issue? Current-main source directly shows whole-transcript decoded retention, corroborated by the supplied matched Gateway observations and constrained-heap failure; this read-only review ran no target code. Is this the best way to solve the issue? The patch removes the unnecessary retained payloads at their producer and reuses existing navigation and aggregation owners without adding a competing path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 37df1431d43d. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +13, Tests +93. Total +106 across 2 files. Added test files: 1. 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 (9 earlier review cycles; latest 8 shown)
Reviewed October 23, 2026, 7:06 AM ET / 11:06 UTC (Revision 10). |
Production follow-up: fatal Gateway process crashes, not only stale usage totalsThe unpatched deployment at The operator reports that interacting with the iPhone app, including pressing Connect, precedes the failures. The Gateway remained on the same PID for approximately 50 minutes between 23:55:49 and 00:45:31; the operator reported another Connect attempt immediately before the latter crash. This is an observed trigger correlation, not a controlled reproduction or proof that the connection handler itself is defective. Sanitized journal sequence for the three most recent fatal events (CEST):
The fatal signature is Importantly, there are also worker-only failures: Scope and remaining uncertainty: The repeated temporal sequence strongly implicates the usage/transcript worker path and warrants revisiting the assumption that impact is confined to stale cost statistics. However, we have not yet established the exact failing worker/RPC causal chain, explained why some OOMs are contained and others abort the process, or proven that this PR prevents the iPhone-associated fatal crashes. The existing synthetic before/after worker-memory proof remains valid; it is not live proof of this wider failure mode. No deliberate production crash reproduction was performed. |
a0e38bf to
c494c6d
Compare
|
@clawsweeper re-review Updated on current main in |
|
🦞👀 Re-review progress:
|
c494c6d to
24cb681
Compare
|
Rebased the focused three-file repair onto main The current actor routes, authorization/currentness checks and compute-scope cleanup remain intact. The same 648 MiB fixture OOMs on the unpatched base and passes with this patch at the unchanged 512 MiB worker limit. All 79 focused tests passed, including the current actor-compute and reconciliation suites. The PR body contains the commands, timings and proof boundaries. Static checks and new-head CI are still running. The local catalog performance failure remains explicitly unresolved; no catalog changes or assertions were folded into this repair. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
24cb681 to
a6b683e
Compare
|
Added the requested shipped-Gateway behavior proof to the PR body; code head remains Both base and head were executed from the built Gateway CLI with matching Control UI, a real incognito session, one local synthetic-provider turn and 48 actor-owned document appends (36 MiB of text). The production keyed The body includes captured stdout, exact revisions, fixture/ownership path and memory method: in this single matched pair, head's observed refresh RSS peak was 39.29 MiB lower and observed V8 heap peak 8.73 MiB lower. These are observations, not statistical benchmarks or a claim that resident actor/snapshot memory is bounded. The separate constrained scanner OOM proof remains clearly distinguished. The aggregate Usage page returned zero on both revisions; that screenshot is explicitly not offered as successful UI-total proof. The new evidence is the real keyed Gateway refresh, with that separate aggregate behavior recorded for investigation. Native-build environment failures and the unused minimal-inventory CLI-help metadata limitation are also disclosed. No production data, credentials, or installation was used. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in a247b26. Thanks @HerbertHuerto. Incognito usage refresh no longer holds every transcript in memory at once. |
|
Merged with the current actor-memory scanner repair and shipped-Gateway proof. Thanks @HerbertHuerto for the fix and the earlier investigation; usage totals and navigation/checkpoint behavior remain preserved while decoded message payloads are released during refresh. |
…enclaw#156673) fix(usage): don't hold every decoded transcript in memory during keyed incognito usage refresh Keyed incognito usage refresh decoded every transcript payload and kept all of them in memory at once before summing usage, which added avoidable heap pressure and risked Gateway out-of-memory failures on large histories. It now reads and drops each payload as it goes; the usage results are unchanged. Evidence: built Gateway, eight incognito sessions each filled with 48 × 768 KiB chat.inject appends through the shipped RPC. During a keyed usage refresh, main retained 50 decoded messages (about 37.7 million characters) at the scanner boundary (twice); with this change it retains none (twice), and the reported usage is identical. Thanks @HerbertHuerto. Co-authored-by: Ayaan Zaidi <[email protected]>
…56673) fix(usage): don't hold every decoded transcript in memory during keyed incognito usage refresh Keyed incognito usage refresh decoded every transcript payload and kept all of them in memory at once before summing usage, which added avoidable heap pressure and risked Gateway out-of-memory failures on large histories. It now reads and drops each payload as it goes; the usage results are unchanged. Evidence: built Gateway, eight incognito sessions each filled with 48 × 768 KiB chat.inject appends through the shipped RPC. During a keyed usage refresh, main retained 50 decoded messages (about 37.7 million characters) at the scanner boundary (twice); with this change it retains none (twice), and the reported usage is identical. Thanks @HerbertHuerto. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit a247b26) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit a56591b2a49a5fba692d71d1a3b1eb9debc40ea7)
What Problem This Solves
Incognito usage refresh retains every decoded transcript message while computing small usage totals. Large conversations therefore incur an unnecessary second decoded-text allocation during refresh.
What Changed
Project each parsed event into the existing canonical navigation fields and its usage contribution immediately, rather than retaining its message payload. Preserve the canonical hash of the last raw event before dropping it. Branch selection, rewind/side appends, totals and checkpoint semantics are unchanged. This updates the contributor's repair for the current actor-owned memory route; it does not restore the retired worker/cursor implementation.
Evidence
Built Gateway CLI, Node 24.22.1 in isolated Linux Docker, fresh state per arm. State was created only through authenticated shipped RPCs:
sessions.create(incognito: true), a realchat.sendagainst a local streaming provider, 48chat.injectdocument appends per session, then keyedsessions.usage. Eight sessions each contain 36 MiB of appended text. A small real model turn and refresh calibrated the scanner boundary before the large workload.Two completed main-baseline runs consistently retained 50 decoded messages (37,749,447 text characters) per measured scan. The candidate retained zero message payloads at the same production scanner boundary. Forced-GC inspector samples at that boundary showed roughly 151 MB additional heap on main versus 75–76 MB on the candidate. These are retained-boundary observations, not peak-RSS measurements or a claim that total session memory is bounded. The actor transcript and immutable serialized snapshot still scale with input size; one event is still parsed whole.
All eight normalized public usage responses were identical between baseline and candidate: 101 input / 7 output tokens, 50 messages (one user, 49 assistant), identical costs and model/tool totals. Both completed main runs and candidate stayed on one authenticated connection. An earlier baseline attempt timed out collecting inspector GC and is not counted.
gpt-5-miniturn through the built CLI returnedLIVE_GATE_OK, exit 0. The first setup attempt could not resolve the model before catalog refresh; the corrected shipped catalog-refresh sequence succeeded.Simplification reuses
projectTranscriptNavigationFields, removing the contributor's duplicate navigation-field projection. Whole production delta: +20/-7 lines; regression tests: +93 lines. Growth is the per-event usage/navigation projection and raw-tail hash needed to release decoded payloads without changing branch or checkpoint behavior. No SDK, configuration, schema or permissions change.Merge Risk
Two-way door: reverting restores the previous scan behavior without a migration. Blast radius is incognito usage refresh and its branch/checkpoint accounting; durable transcript scanners and provider behavior are unchanged.