Repository navigation
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 shares bounded preview recovery across display, Talk, and incognito readers and adds a final 2,048-event window. Example: A session contains 64 visible assistant messages followed by 1,500 tool-result messages; sessions.preview requests 12 items.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep open: this PR repairs a current preview-recovery bug with credible shipped-entry-point evidence and no identified production correctness blocker; redundant tests should be trimmed, and current-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway preview and Talk requests select transcript history from SQLite workers or memory actors, project visible messages, and return bounded preview items. flowchart TD
A[Preview or Talk request] --> B[Shared widening policy]
B --> C[SQLite display reader]
B --> D[SessionManager hydration]
B --> E[Memory actor preview]
C --> F[Message projection]
D --> F
E --> F
F --> G[Bounded preview items]
Technical reviewBest possible solution: Retain the shared bounded recovery repair while leaving truthful scan-exhaustion reporting to the linked issue. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically excludes visible history behind 1,500 tool-result rows for ordinary preview limits; contributor Gateway traces establish the before/after behavior, and no target code was executed during this review. Is this the best way to solve the issue? The shared policy is a focused repair that preserves existing storage and projection owners, uses exact selected-row counts to stop byte-limited rereads, and avoids changing public callbacks or persisted formats. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 78f378c5e431. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +100, Tests +448, Other +4. Total +552 across 18 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. Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 (17 earlier review cycles; latest 8 shown)
Reviewed November 5, 2026, 7:56 AM ET / 12:56 UTC (Revision 18). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review — new head 301269dec carries the exact selected-row count through an internal bounded-selection record (no public callback change) and adds the byte-capped Talk regression. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review — current head 4bc64c13 is rebased onto fresh upstream/main and its CI is green (all check-runs success; the ci-gate aggregate is still reporting PENDING, no failures). It also adds the missing |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review — merge conflicts resolved: the branch is rebased onto current upstream/main, main's own filtered-tool-row test is kept as the baseline, and the hidden-tail recovery / scan-ceiling / Talk model-context cases are reattached on top sharing the harness helper (no duplicate |
|
🦞👀 Re-review progress:
|
Preview and Talk readers bounded their tail reads, but the recovery page stopped at 1,024 events. A visible history behind a longer tool-only tail therefore previewed as empty. Share one bounded widening policy with explicit 2,048-event / 8 MiB scan ceilings and a final ceiling-sized page, used by display previews, Talk model context, and incognito memory reads.
|
@clawsweeper re-review — conflicts resolved. The branch is now a single commit on current upstream/main (7ec1d3e) and GitHub reports MERGEABLE. Three files needed 3-way resolution because main changed underneath:
Verified on a clean Ubuntu box against main: the change applies cleanly, and the owning test file plus the |
|
🦞👀 Re-review progress:
|
The reload path still calls recordSessionManagerBoundedSelection, so the module import must stay; dropping it during the merge left the call undefined at runtime.
|
@clawsweeper re-review — CI caught a real regression from my conflict resolution: Locally re-ran all four test files the PR touches at this head: |
|
🦞👀 Re-review progress:
|
The recovery cases need real seeded transcripts (1,565 and 4,565 rows) to prove the bounded widening, which is more test text than the ratchet headroom allows.
|
@clawsweeper re-review — fixed the baseline-ratchet failure at head c612963. Two real issues found and addressed:
Verified on a clean Ubuntu checkout of current main with this exact patch staged, running the repo's own ratchets: All four touched test files pass locally at this head (57/57). |
|
🦞👀 Re-review progress:
|
Main's hydration wrapper owns truncation now; the local flag was dead and tripped the unused-variable check after the merge.
|
@clawsweeper re-review — head ee3ae3c fixes the remaining type/lint failure.
Verified on a clean Ubuntu checkout of current main with this patch applied:
|
|
🦞👀 Re-review progress:
|
once, fs, and path came from the previous helper block; the merge keeps main's harness helpers instead, so the imports are unused.
|
@clawsweeper re-review — head 7d59547 fixes the
Verified on the clean Ubuntu checkout with this patch applied: |
|
🦞👀 Re-review progress:
|
Removing the unused imports dropped three test lines, so the allocation must match exactly; an over-request fails the same ratchet.
The bounded active-context type now requires selectedEventCount; this perf script builds that type and must report the same count.
|
@clawsweeper re-review — head 4352f92 clears the last two ratchet/type failures.
Verified on the clean Ubuntu checkout with this exact patch staged: The remaining |
|
🦞👀 Re-review progress:
|
Place the bounded-selection import with its sibling module imports so the format check stays green.
|
@clawsweeper re-review — head f5a6a0f fixes the last The log showed
|
|
🦞👀 Re-review progress:
|
Part of #127630
AI-assisted: yes. Authored by an AI coding agent; every check below executed against this checkout.
What Problem This Solves
session.preview/Talk show an empty preview when a short visible history sits behind a long tool-only (non-projectable) transcript tail. On current main the readers already read bounded tail pages (64 events / 1 MiB, then 1024 / 8 MiB) instead of materializing the whole transcript — but the recovery page stopped at 1,024 events, so a visible history behind a longertoolResulttail exhausted the window, the projection produced no items, andsessions-readpublishedstatus: "empty". The same widening loop was duplicated in three places.This PR adds the final ceiling-sized window and stops widening when the previous page was limited by bytes rather than events, so a byte-capped recovery page no longer re-reads the same 8 MiB tail.
User Impact
Session previews and Talk model context recover the newest visible messages instead of showing an empty preview (or reading unbounded history) for sessions with long tool-only tails. Short histories and small limits behave exactly as before.
Why This Change Was Made
src/gateway/session-transcript-preview-bounds.tsowns one bounded widening policy with explicitSESSION_PREVIEW_SCAN_MAX_EVENTS = 2048andSESSION_PREVIEW_SCAN_MAX_BYTES = 8 MiBceilings: a small page, a recovery page, and a final ceiling-sized page, stopped early when the requested count is reached or no older events remain.selectedEventCount, excluding the session header and injected boundary events) and is carried to Talk through an internal bounded-selection record. Every bounded hydration producer reports it: SQLite, actor-backed incognito history, and the empty-memory snapshot.SessionManager.onTruncatedstays() => void, so this adds no public SDK callback surface. Display and incognito readers report their selected-event counts directly.buildSessionPreviewItems); output shape and ordering are unchanged; the sync reader handles display/incognito, the async reader handles Talk.scripts/pr-lib/wrapper-components.txt, so the trusted-anchor PR wrapper inventory stays closed over runtime imports.Evidence
Regression tests prove the base/fixed split (64 visible rows + 1,500
toolResultrows, limit 12):Local checks on head
f80d0b291:The removed helper-only
session-transcript-preview-bounds.test.tswindow-count cases are covered by the production reader regressions inserver.sessions.preview-resolve.test.ts(explicit tail scan ceiling, and Talk byte-cap stopping) andsession-transcript-readers.memory.test.ts/session-actor-memory-history.test.ts(incognito recovery).Real behavior proof
1. Display preview (
sessions.previewRPC)Isolated state dir, 64 visible assistant rows + 1,500
toolResultrows seeded through the session accessor, local Gateway started from the repo CLI entry withgateway.mode=localand authnone, then the public RPC:2. Shipped Talk entry point (
talk.client.createRPC)Tested through an isolated Gateway on an ephemeral port with an isolated voice provider registered (
createBrowserSession). Both scenarios executed end-to-end throughopenclaw gateway call talk.client.create:Scenario 1: Byte-capped stopping (durable session)
64 visible assistant rows behind a 5 MiB row and 1,023 ~4 KiB rows (exceeding the 8 MiB page budget before event limit). The 8 MiB recovery page is byte-limited below its 1,024-event cap, so the policy stops early instead of repeatedly re-reading the 8 MiB tail; 0 items produced for Talk context:
Scenario 2: Hidden-tail visible history recovery (durable session)
64 visible assistant rows behind 1,500
toolResultrows (exceeding the old 1,024-event cap). The recovery policy widens through the 2,048-event ceiling window and recovers the newest 16 visible items into Talk context:In-memory incognito recovery through
readTalkRealtimeInitialItemson the shipped session-actor storage binding (64 visible assistant rows + 1,500toolResultrows):CI note.
check-test-typespasses on this head (the typedBoundedfixture fix).checks-node-changedis red ontest/gateway-openai-compaction-replay.e2e.test.ts:102("Continue from the compacted transcript"split length 2 vs 3). The identical failure is present at every head that ran that job (301269dec,6005d42a9,89de4013f,f80d0b291), the failing test is not modified by this PR, and its retry path (src/agents/embedded-agent-runner/run/terminal-resolution.ts) is untouched by this diff; the last behavior change there is #178192, merged before this branch's base. Main pushes skip the node CI jobs (verified: node checks areskippedon recentmaincheck runs), so a same-job main comparison is not available; the repo's owntest:ci-failedclassifier reports[unknown] No matching job on mainfor this job. The failure is deterministic across heads, so a retrigger is not expected to change it. Treat this check as inherited/unattributed, not caused by this change.Residual risk / boundary. A tail longer than the 2,048-event / 8 MiB scan still yields
emptywith no truthful truncation field — surfacing truncation needs a preview result-shape change and is deliberately out of scope here. Byte-heavy tails can stop at the 8 MiB page budget below 2,048 events, and the policy now stops there rather than re-reading the same tail. Oversized single rows remain omitted by the existing SQLite reader; filters needing history older than the ceiling cannot recover. The linked issue's remaining truthful-truncation contract is why this PR isPart ofrather than closing it.