Repository navigation
[BACKPORT #127162] perf(sessions): avoid loading full transcripts for newest-event checks - #129010
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-01a021f5-984a-7628-a30c-491c166ff247 Co-authored-by: Amp <[email protected]> (cherry picked from commit 096a970)
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 1:59 AM ET / 05:59 UTC. ClawSweeper reviewWhat this changesThis PR backports lazy newest-first SQLite transcript scanning so recent-event and idempotency checks stop after a match instead of materializing an entire transcript. Regression provenancePossible regression — probable (reviewed change; known regression link). No predecessor PR is attributed. Merge readinessKeep open for release-owner scope judgment. The backport matches the already-merged upstream performance fix, but its target is the separate pinned release branch, so current main does not make this work redundant. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherSession accessors read per-agent SQLite transcript rows for event existence and assistant idempotency decisions. Their result tells gateway and transcript-write paths whether to append or suppress a message. flowchart LR
A[Incoming message] --> B[Session accessor]
B --> C[SQLite transcript rows]
C --> D[Newest-first iterator]
D --> E{Matching event?}
E -->|Yes| F[Return immediately]
E -->|No| G[Continue or report absent]
F --> H[Gateway idempotency decision]
G --> H
Decision needed
Why: The code matches the already-merged main fix, but repository policy makes optional backports an operator-selected release-scope decision. Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +31. Total +31 across 2 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: If the release owner selects this performance fix, merge the exact two-file upstream backport after exact-head release CI is green; otherwise close it as intentionally excluded from the release train. Do we have a high-confidence way to reproduce the issue? Yes—source reproduction is high confidence: the release base materializes Is this the best way to solve the issue? Yes technically: reusing the existing lazy iterator is the narrow owner-boundary fix and matches current main; whether to carry it into this release remains a release-scope choice. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 610fefdabbce. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
/merge |
What Problem This Solves
On the pinned release branch, newest-event transcript lookups load every SQLite
event_jsonrow before testing the newest event. An existence or idempotency check therefore incurs CPU and heap usage proportional to the entire session transcript even when the newest row already answers the query.Why This Change Was Made
Cleanly backport upstream #127162 (
096a9708208a4f4af863069f6cc1e260e8f2120d) tosjf_openclaw_2026-07-31. Consume the existing synchronous SQLite iterator directly and stop stepping rows as soon as the matcher succeeds. No schema, protocol, ordering, malformed-row handling, or public API changes.User Impact
Recent-event checks no longer allocate the full transcript. The upstream 10,002-row, roughly 40 MiB fixture reduced five newest-row probes from 50,010 SQLite rows and +217 MiB heap to five rows and +0.7 MiB heap.
Evidence
node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfooxfmt --check, andgit diff --checkpassed.Upstream: #127162