Repository navigation
fix(sessions): prevent OOM from consumed input history - #196277
Conversation
Keep consumed source receipts durable without loading them into resident actor state. Use indexed canonical reads for missing historical keys and preserve replay validation. Co-authored-by: RomneyDa <[email protected]>
|
🦞👀 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 excludes consumed input bodies from resident session actors while preserving durable receipts and replay validation. Example: A session contains 60,000 consumed collected-input messages of 4 KB each.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR repairs a source-confirmed memory problem still present on main, and the earlier read-budget finding is fixed; no new actionable defect was found. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe session actor hydrates worker-resident session facts from SQLite, prepares accepted inputs, and publishes committed snapshots to callers; durable receipts remain the source for historical replay checks. flowchart LR
A[Accepted input] --> B[Session worker]
B --> C[Resident unconsumed inputs]
B --> D[SQLite receipts]
D --> E[Exact replay lookup]
E --> B
B --> F[Transcript commit]
Technical reviewBest possible solution: Keep consumed receipts in durable storage, retain only unconsumed actor custody, and finish the current-head CI gates before landing. Do we have a high-confidence way to reproduce the issue? Current-main hydration includes consumed message bodies, and consumption retains collected-source rows; the PR reports a matching synthetic native-actor failure on base and success after the fix, but this review ran no target code. Is this the best way to solve the issue? The patch fixes residency at its existing producer and mutation owners, preserves transaction isolation and durable bytes, and reuses canonical readers instead of adding another historical-membership cache. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 06ecfc06b4ef. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +6, Tests +23, Docs +4, Other +1. Total +34 across 11 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 HistoryReview history (1 earlier review cycle)
Reviewed November 9, 2026, 8:39 PM ET / November 10, 2026, 01:39 UTC (Revision 2). |
Co-authored-by: RomneyDa <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Keep consumed source receipts durable without loading them into resident actor state. Use indexed canonical reads for missing historical keys and preserve replay validation. Release adaptation: port to release/2026.11.3 baseline 40223c5. Keep the baseline direct append reader (there is no preparedInputs optimization), apply all-source resident coverage before canonical fallback, and preserve the existing describe fixture. Supply the baseline actor factory's physical identity, birthtime and native location. Omit session-turn-resident.test-support.ts, a later-main harness absent from the release; memory-owner behavior is unchanged. Companion audit pinned at 472d778: no later same-path commits or #196277 mentions. Baseline reader, custody, transaction rollback, publication, worker hydration and lifecycle contracts are present-equivalent; selected changes close durable residency and replay. Other reported documentation, inventory, historical changelog, performance and sibling references require no prerequisite changes. No schema, retention or config change. Regression allocation: 32 net test lines cover consumed actor exclusion before and after restart/replay plus the retained exact-key lookup expectation. The extra baseline-native fixture identity setup explains the allocation adaptation. Validation: the owning collected-input regression fails on the pinned baseline (two consumed rows remain) and passes after the port. 38 consumed-input tests and 25 actor/pending-operation/memory sibling tests pass with one worker. Targeted TypeScript, type-aware lint, format, and diff checks pass. Independent P0-P2 review found no defects; full release qualification remains parent-owned. (cherry picked from commit 472d778) Co-authored-by: RomneyDa <[email protected]>
* fix(sessions): prevent OOM from consumed input history Keep consumed source receipts durable without loading them into resident actor state. Use indexed canonical reads for missing historical keys and preserve replay validation. Co-authored-by: RomneyDa <[email protected]> * test(sessions): account for retained receipt lookup Co-authored-by: RomneyDa <[email protected]> --------- Co-authored-by: RomneyDa <[email protected]>
Release adaptation: Keep the release SQLite planner helper private and omit agent-port-projections.ts, which does not exist on this release line. Preserve all baseline assertions by materializing four small test fixtures, and exercise lazy payload reads through the actual SQLite planner rather than a fake source. Allocate the exact 64 net test lines. No schema, config, or authority changes. Later same-path followups through 568d89f: 8633af9 (#194591) is the non-applicable PostgreSQL surrogate repair; b6ed907 (#193682) is the non-applicable schema41 hydration migration. Neither is a streaming prerequisite. Existing #195028 and #196277 repair contracts remain intact. Verified: baseline lazy-read regression fails; 32 focused tests pass across five suites, including compiled-worker publication and authority boundaries. Targeted types, lint, format, and whitespace checks pass. Fresh independent read-only review found no P0-P2 issues. (cherry picked from commit 7bc0ae7) Co-authored-by: vincentkoc <[email protected]> Co-authored-by: RomneyDa <[email protected]>
Backport source 472d778 (#196277). Preserve durable source receipts and indexed replay validation while retaining only unconsumed actor custody. Adapt regression acquisition to the canonical explicit physical identity contract and cover SQLite/PostgreSQL actor hydration. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
Related: #191847
What Problem This Solves
Fixes session-actor worker out-of-memory failures when ordinary hydration loads a large history of consumed collected-input source messages. This is a separate non-compaction path from #194536; it does not establish that the original report had this exact cause.
User Impact
Sessions no longer load consumed source-message bodies into the actor's resident pending-input map. Exact source receipts remain in SQLite and remain available for replay checks and history reads. No configuration, schema, durable retention, or migration changes; no user action required.
Why This Change Was Made
The resident pending-input map now represents unconsumed inputs only. Hydration filters consumed rows before serializing their bodies, and consumption removes their resident copies. Missing exact keys fall back to the existing indexed durable reader; collected-source validation uses the existing batched reader when the resident set is incomplete. Restaging a consumed receipt cannot bring it back into residency.
Tradeoff: a keyed input absent from active residency needs an indexed local SQLite lookup rather than treating absence as proof that it is new. Durable preparation already enters the worker, so this adds no worker RPC or model call. Avoiding all such lookups would require complete historical membership information in memory or changed replay semantics. The read-count tests now explicitly account for that lookup. Active admitted inputs still prepare without reads. This is not a general speedup claim: cold hydration still scans the retained table, and active pending inputs still consume memory.
Evidence
d5f45c66f550df85e3fe9b4eceb88aae1e0ce60f: consumption leaves source bodies resident. It also checks cold/restarted hydration, consumed-source restaging, exact retained bytes, replay rejection, and lifecycle cleanup.team-shape-fixture.idle.test.tspasses locally (one test); its CI cause remains unestablished, not classified as unrelated.Gaps: no original reporter database or live Gateway/model-turn reproduction. The diagnostic exercises the real native actor acquisition/hydration boundary, not the complete user turn. The PostgreSQL variant of the shared resident-preparation suite was not run locally. Broad CI remains the PR's validation path.