Repository navigation
perf(sessions): batch eager model-context payload reads - #138168
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 4, 2026, 6:28 AM ET / 10:28 UTC. ClawSweeper reviewWhat this changesThe PR batches SQLite payload reads for detached model-context loading so long session histories require bounded query executions while preserving selected-message order and projections. Merge readiness⛔ Blocked before merge - 3 items remain Keep this PR open for an explicit maintainer landing decision. The current main branch still uses one eager payload query per selected entry, while the introduced batching preserves the separate lazy reader and existing model-context projections; no actionable correctness defect was found in the reviewed change. Priority: P3 Review scores
Verification
How this fits togetherSession context loading reads persisted transcript events from each agent’s SQLite database and turns selected events into model-visible conversation history. The eager model-context path feeds agent execution, while full-fidelity callback readers retain a separate lazy path. flowchart LR
A[Stored transcript events] --> B[Context navigation snapshot]
B --> C[Selected model entries]
C --> D[Bounded payload batches]
D --> E[Detached model context]
B --> F[Lazy full-fidelity reader]
F --> G[Callback consumer]
Decision needed
Why: The PR is marked maintainer and the repository state identifies its author as a MEMBER, so automated cleanup must leave the landing decision to a maintainer despite the absence of source-level findings. Before merge
Agent review detailsSecurityNone. PR surfaceSource +23, Tests +45. Total +68 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one eager, projected batch-read path inside the existing SQLite snapshot and retain the distinct lazy full-fidelity reader; accept it only after the maintainer confirms the performance tradeoff and exact-head validation is green. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main performs one prepared payload query for each selected entry, and the added real-SQLite test exercises a 1,200-message context with an execution-count bound. The test was not run because this is a read-only review. Is this the best way to solve the issue? Yes. The implementation keeps projection at the SQLite owner boundary, batches only the eager detached-reader path, and leaves the full-fidelity callback reader lazy; no existing alternative path duplicates this behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 605e68260516. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
What Problem This Solves
Opening a long model context executes one SQLite payload query per selected transcript entry. A synthetic 4,000-message context requires 4,002 statement executions even though the caller needs a complete, detached result.
Why This Change Was Made
Fetch selected eager payloads in bounded batches of 400 within the existing read snapshot. Restore the existing navigation order and keep replay/private-field projection inside SQL. Full-fidelity callback readers remain lazy and close their iterators before the snapshot ends.
User Impact
Long eager context reads perform fewer database operations. Model content, ancestry, compaction handling, admission fences, stored transcript bytes, and the public API stay unchanged. SQLite remains the only backend; there is no schema or configuration change.
Evidence
d058173f883a1c396c195fcacdded217924a69b4, with the same statement-count reductions, matching projected bytes, and unchanged durable bytes. Uninstrumented second-run large-case medians were 36.59→32.57 ms and 122.61→111.43 ms. Source tree6ca87bf8058550e4bf127b9b5fa7205d0773e5d0matched before/after.