Repository navigation
perf(sessions): reduce stalls when saving large chat messages - #158402
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. Reviewed September 26, 2026, 1:10 AM ET / 05:10 UTC (Revision 3). ClawSweeper reviewWhat this changesThe branch changes how SQLite prepares navigation metadata for large saved chat messages, extends transcript parity coverage, and steadies a Watch HTTP test fixture. Merge readiness✅ Ready for maintainer review Current main still materializes the large transcript input, so this PR addresses a remaining performance problem. The source review found no introduced correctness defect. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw prepares chat messages for per-agent SQLite transcript storage. It saves the original message bytes or a compressed representation with bounded navigation metadata, which session history and model-context reads later consume. flowchart LR
A[Chat message] --> B[Transcript preparation]
B --> C{Compression eligible?}
C -->|Yes| D[Compressed event and navigation metadata]
C -->|No| E[Original JSON event]
D --> F[Session history and model context]
E --> F
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource 0, Tests +7. Total +7 across 3 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep transcript bytes exact and navigation metadata bounded while avoiding the large temporary SQLite source; investigate remaining Gateway turn stalls separately if users still observe them. Do we have a high-confidence way to reproduce the issue? Yes, at the component boundary: current main materializes the large JSON source, and the PR reports a before/after benchmark with large payloads and the same SQLite temporary-storage policy. No full Gateway turn-latency reproduction was supplied. Is this the best way to solve the issue? Yes. Changing this query plan targets the measured SQLite bottleneck without adding a storage format, setting, or parallel implementation, and the extended parity case checks the resulting data. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8279835741d0. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
Keep pairing-worker latency from exhausting the reconnect fixture's invoke budget. Preserve the two-second timeout and all transport and authority assertions, and verify that the HTTP result was accepted. A controlled clock advance reproduced TIMEOUT through the real result path. Validation: 20 full Watch runs, three original 15-file CI cohorts, selected registry deadline/policy tests, core-test types, lint, and P2 review.
|
Merged via squash.
|
* commit '66b812f26e725cd709e08860d2cb46ba496cd308': (70 commits) fix(gateway): preserve typed boxed-number coercion chore(ui): refresh control ui locales (#158689) fix(gateway): reset staged headers on authority errors (#158669) fix(workers): keep inbound staging stable during quota scans fix: preserve Telegram delivery after bot identity changes (#158612) fix(ui): keep automation starter prompts out of startup (#158482) fix(cli): distinguish configuration read failures from invalid input (#158671) test: remove retired progress coercion suppression allowance refactor(gateway): schedule worker placement maintenance (#158662) fix(daemon): keep native service checks within their timeout (#154565) fix(test): restore gateway steering fixture contracts (#158478) fix(acpx): use SDK filesystem publication boundary fix(agentsapi): load OpenClaw persona and workspace context (#158328) fix(gateway): drop progress snapshot coercion suppression fix(qa): accept native Codex truncation in cache evidence (#158454) fix(gateway): keep chat subscriptions stable during unrelated approvals (#158633) perf(gateway): release event payloads from live text guards (#158643) perf(sessions): reduce stalls when saving large chat messages (#158402) fix(qa): reject history-bearing utility requests without session affinity (#158496) test: allow intentional progress snapshot coercion ...
* fix(test): verify followup completion ordering Exercise the real presentation settlement helper with asynchronous cleanup, preserve continuation and admission semantics, and unconditionally release and join the held work. Remote proof covers the strengthened ordering contract and both missing-await faults. * fix(test): verify followup completion ordering * chore: retain followup test branch ancestry The current-main reconstruction preserves the original reviewed scope and supersedes its stale base. Keep the remotely qualified candidate tree unchanged while retaining the original PR ancestry for a non-force branch update. * commit 'ff35145de21cf6296bec05e86bee37b5ed53bcb8': fix(test): verify followup completion ordering * test(auto-reply): signal queued presentation entry * chore: refresh followup test on boundary fix * commit '66b812f26e725cd709e08860d2cb46ba496cd308': (70 commits) fix(gateway): preserve typed boxed-number coercion chore(ui): refresh control ui locales (#158689) fix(gateway): reset staged headers on authority errors (#158669) fix(workers): keep inbound staging stable during quota scans fix: preserve Telegram delivery after bot identity changes (#158612) fix(ui): keep automation starter prompts out of startup (#158482) fix(cli): distinguish configuration read failures from invalid input (#158671) test: remove retired progress coercion suppression allowance refactor(gateway): schedule worker placement maintenance (#158662) fix(daemon): keep native service checks within their timeout (#154565) fix(test): restore gateway steering fixture contracts (#158478) fix(acpx): use SDK filesystem publication boundary fix(agentsapi): load OpenClaw persona and workspace context (#158328) fix(gateway): drop progress snapshot coercion suppression fix(qa): accept native Codex truncation in cache evidence (#158454) fix(gateway): keep chat subscriptions stable during unrelated approvals (#158633) perf(gateway): release event payloads from live text guards (#158643) perf(sessions): reduce stalls when saving large chat messages (#158402) fix(qa): reject history-bearing utility requests without session affinity (#158496) test: allow intentional progress snapshot coercion ... Co-authored-by: Vincent Koc <[email protected]>
…aw#158402) * perf(sessions): avoid spilling transcript navigation inputs * test(gateway): control the Watch invoke fixture clock Keep pairing-worker latency from exhausting the reconnect fixture's invoke budget. Preserve the two-second timeout and all transport and authority assertions, and verify that the HTTP result was accepted. A controlled clock advance reproduced TIMEOUT through the real result path. Validation: 20 full Watch runs, three original 15-file CI cohorts, selected registry deadline/policy tests, core-test types, lint, and P2 review.
* fix(test): verify followup completion ordering Exercise the real presentation settlement helper with asynchronous cleanup, preserve continuation and admission semantics, and unconditionally release and join the held work. Remote proof covers the strengthened ordering contract and both missing-await faults. * fix(test): verify followup completion ordering * chore: retain followup test branch ancestry The current-main reconstruction preserves the original reviewed scope and supersedes its stale base. Keep the remotely qualified candidate tree unchanged while retaining the original PR ancestry for a non-force branch update. * commit 'ff35145de21cf6296bec05e86bee37b5ed53bcb8': fix(test): verify followup completion ordering * test(auto-reply): signal queued presentation entry * chore: refresh followup test on boundary fix * commit '622be54be3ffe0fce27d6a4b147c76d4b19c528c': (70 commits) fix(gateway): preserve typed boxed-number coercion chore(ui): refresh control ui locales (openclaw#158689) fix(gateway): reset staged headers on authority errors (openclaw#158669) fix(workers): keep inbound staging stable during quota scans fix: preserve Telegram delivery after bot identity changes (openclaw#158612) fix(ui): keep automation starter prompts out of startup (openclaw#158482) fix(cli): distinguish configuration read failures from invalid input (openclaw#158671) test: remove retired progress coercion suppression allowance refactor(gateway): schedule worker placement maintenance (openclaw#158662) fix(daemon): keep native service checks within their timeout (openclaw#154565) fix(test): restore gateway steering fixture contracts (openclaw#158478) fix(acpx): use SDK filesystem publication boundary fix(agentsapi): load OpenClaw persona and workspace context (openclaw#158328) fix(gateway): drop progress snapshot coercion suppression fix(qa): accept native Codex truncation in cache evidence (openclaw#158454) fix(gateway): keep chat subscriptions stable during unrelated approvals (openclaw#158633) perf(gateway): release event payloads from live text guards (openclaw#158643) perf(sessions): reduce stalls when saving large chat messages (openclaw#158402) fix(qa): reject history-bearing utility requests without session affinity (openclaw#158496) test: allow intentional progress snapshot coercion ... Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
Fixes long Gateway stalls when saving large chat messages that compress into transcript storage.
User Impact
Large messages spend substantially less time in synchronous transcript preparation. Canonical transcript bytes, navigation, schemas, and update behavior stay unchanged. This removes the measured SQLite temporary-storage cliff; it does not move the remaining user-turn persistence off the Gateway thread.
Why This Change Was Made
The source CTE carried both full JSON and JSONB into temporary storage. Inline that source while keeping the bounded metadata result materialized. Extend the existing native-JSON parity fixture to a large payload instead of adding a separate test harness.
Evidence
Source microbenchmark on Node 26.9.0/macOS arm64, five warm samples per size, identical FILE TEMP policy. Median milliseconds:
The small-input tradeoff is visible above; the large-input cliff disappears. The shared host was busy, so these are component measurements rather than end-to-end latency predictions. The 2 MiB median process CPU time fell from 119.84 ms to 10.83 ms.
node scripts/run-vitest.mjs src/config/sessions/transcript-payload.test.ts --maxWorkers=1passed all 23 tests, including large-payload canonical-byte and duplicate-key/native-projection parity. Wall: 11.69 s; Vitest: 3.80 s. Baseline: 22 tests passed, 35.91 s cold wall.node scripts/check-changed.mjspassed, including core production and all 25 selected core-test typecheck graphs, lint, export scans, and storage/runtime guards.CI fixture repair
The original CI job failed the Watch reconnect/invoke test. Full main CI passed on the same main commit, and the Watch owners are byte-identical between the reviewed head and that CI merge tree. A controlled 2,001 ms clock advance after command delivery reproduced a real
TIMEOUTresponse. The original log omitted the error code, so this establishes the fixture's timing failure mechanism without claiming to recover that missing field.The functional transport fixture now holds its monotonic clock steady and checks that the HTTP result was accepted. The two-second invoke budget, real HTTP/pairing work, authorization checks, and production code stay unchanged.
Linux Node 24.19.0 validation through the task-owned Testbox:
TIMEOUT; the same probe passed with the fixture repair.pnpm test src/gateway/watch-node-http.test.ts --maxWorkers=1: 20 clean runs, 420 test executions. Median warm wall time 19.40 s (18.59–21.61 s); the initial unchanged-file run was 38.49 s.d033b983f3e39416c6570445b0215189a732964cplus the same repair: three clean runs, 226 tests each, with the original eight-worker policy. Wall times: 215.98 s, 182.17 s, and 188.21 s.Local shard and standalone attempts did not complete test execution on the busy host. Remote preparation also needed recovery from an interrupted capture, an idle lease expiry, and incomplete workspace dependency links; normal frozen installs resolved the dependency issue. These are setup failures, not passing test evidence. No hosted CI run was blindly retried.
Prior-head CI run 36216113165 failed for fixture commit
e54df72d19c3073771fb16525698bb16458a9fff, blocking that head inopenclaw/ci-gate.The single actual test failure was in compact-small-5:
update-runner-git-candidate.test.ts, Doctor outcomedoctor-error. Its first target-inspectiongit rev-parse HEADhit the fixture's 5,000 ms command deadline (exit 124), before the Doctor callback. Other reported failures were cancellation fallout. The tested merge was975ed433570a9e56d327deec2497cf7e9c46ca61; the relevant test, inspection, and process-runner files match this PR's head. Searches found no matching owning fix. The latest completed full-main run checked, 36215230884, passed.Bounded reproduction on macOS/Node 26.9.0, rather than CI's Linux/Node 24.19.0:
These passing replays do not prove a fix. The reason for the original Git stall remains unknown, and no safe repair was established. No updater source, command deadline, or assertion was changed, and no hosted CI rerun was requested. That run remained failed and was not rerun.
Required main refresh
Merged current main
ceac53a0feaf75eb599e4c310fbd7e35923ba9cfinto the stale branch without rebasing or changing the reviewed PR delta. Merge head:82d5b9af62a9b9b3c0258ee44262d98ee19cfb67.The requested local rerun passed: 23 transcript-payload tests and 21 Watch fixture tests, using
node scripts/run-vitest.mjs src/config/sessions/transcript-payload.test.ts src/gateway/watch-node-http.test.ts --maxWorkers=1(184.90 s including worker preparation). Fresh exact-head CI run 36219424661 passed on82d5b9af62a9b9b3c0258ee44262d98ee19cfb67. The Doctor failure did not recur. The prior Doctor timeout remains historical evidence, not a claimed repair.