Skip to content

fix(sessions): propagate compaction transcript read errors - #125741

Merged
steipete merged 1 commit into
mainfrom
codex/autoqa-session-compaction-read-errors
Aug 18, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/autoqa-session-compaction-read-errors

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Session compaction had three .catch(() => []) paths around authoritative transcript SQLite reads: the initial compaction read, the model-compaction re-read, and the --max-lines preflight. Storage open/read/decode failures therefore became successful {compacted:false, reason:"no transcript"} outcomes. Operators and automation were told nothing was wrong while the transcript store was unavailable or corrupt.

Why This Change Was Made

Remove the failure-erasing catches at the storage boundary. Existing Gateway error translation now returns UNAVAILABLE with the actionable storage error. A successful read containing zero rows remains the only source of the ordinary no transcript no-op. No protocol, schema, persistence format, or threshold changes.

User Impact

openclaw sessions compact and Gateway callers now fail visibly on transcript storage errors instead of reporting success. Truly empty sessions behave exactly as before.

Evidence

  • Pre-fix order-faithful regressions: 3 read-failure cases each received ok:true; 2 genuine-empty cases passed.
  • Post-fix: 39 focused Gateway/CLI tests pass on current rebased head.
  • Core tsgo and diff check pass.
  • Production LOC +3/-3; tests +179.
  • Final Codex autoreview clean 0.99, no actionable findings.

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 18, 2026 08:47
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 18, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 18, 2026, 4:53 AM ET / 08:53 UTC.

ClawSweeper review

What this changes

This PR makes session compaction surface SQLite transcript-read errors through Gateway instead of treating them as empty transcripts, with focused regressions.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: current main still converts three transcript-read failures into successful “no transcript” results; this PR removes those conversions and covers the Gateway-visible error outcome. No correctness finding was identified, but exact-head CI is not yet green.

Priority: P2
Reviewed head: f2b3169c912c0bcdfee9d989c137ae8b2e317c11

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-neutral repair with owner-boundary regressions and no identified correctness defect.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a maintainer-authored PR, so the external-contributor real-behavior-proof gate does not apply; the added Gateway harness remains useful regression coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a maintainer-authored PR, so the external-contributor real-behavior-proof gate does not apply; the added Gateway harness remains useful regression coverage.
Evidence reviewed 5 items Current-main failure path: Current main converts the manual-trim transcript read failure to an empty event list, then returns the normal no-transcript result.
All affected Gateway reads: Current main also catches both model-compaction transcript reads as empty lists; the PR head directly awaits all three reads.
Existing error boundary: The compaction handler translates thrown errors inside its lifecycle operation to an UNAVAILABLE Gateway response, so removing the catch-to-empty conversion uses the existing caller-visible error boundary.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw sessions compact --help

Result: PASS (completed)

pnpm openclaw sessions compact --help
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-125741-1bwtQR/target$ pnpm openclaw sessions compact --help
$ node scripts/run-node.mjs sessions compact --help
pnpm openclaw sessions compact --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.88 kB
[log]
[success] rolldown v1.2.0 Finished in 41.16 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 14.1s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 4322ms (slowest: built plugin control-plane loads 3538ms)
│
◇

OpenClaw 2026.8.1 (f2b3169) — All your chats, one OpenClaw.

Usage: openclaw sessions compact [options] ‹key›

Compact a stored session transcript via the running gateway

Options:
  --agent ‹id›           Agent id that owns the session (required for global keys)
  -h, --help             Display help for command
  --json                 Output JSON (default: false)
  --max-lines ‹count›    Truncate to the last N transcript lines instead of LLM summarization
  --passwor
… output truncated …

Assertions:

  • PASS expect_output: Truncate to the last N transcript lines instead of LLM summarization

How this fits together

Session compaction reads persisted SQLite transcript events before either trimming them or asking an embedded runtime to compact them. Gateway and the CLI then return a no-op for a successful empty read or an actionable error for a storage failure.

flowchart LR
  A[CLI or Gateway request] --> B[Session compaction]
  B --> C[SQLite transcript read]
  C --> D{Read succeeds?}
  D -->|empty| E[Successful no-op]
  D -->|events| F[Trim or model compaction]
  D -->|error| G[Gateway unavailable error]
  E --> H[Caller result]
  F --> H
  G --> H
Loading

Before merge

  • Resolve merge risk (P1) - The supplied check rollup is incomplete and includes one failed job, so exact-head green CI has not yet been established.
  • Complete next step (P2) - No repair finding was identified; this protected maintainer PR should remain open for exact-head CI and normal maintainer handling.
Agent review details

Security

None.

PR surface

Source 0, Tests +179. Total +179 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 3 3 0
Tests 1 179 0 +179
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 182 3 +179

Review metrics

Metric Value Why it matters
Production versus regression-test delta production +3/-3 (net 0); tests +179/-0 The repair removes three error-erasing branches without production growth and adds Gateway-boundary coverage.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the direct error propagation and Gateway boundary regressions, then land once the exact PR head has a satisfactory CI result.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the direct error propagation and Gateway boundary regressions, then land once the exact PR head has a satisfactory CI result.

Do we have a high-confidence way to reproduce the issue?

Yes in source: rejecting any of the three current-main transcript reads enters a catch-to-empty path and returns the ordinary no-transcript outcome; the PR’s Gateway harness targets those paths.

Is this the best way to solve the issue?

Yes: removing the failure-erasing conversions lets the existing Gateway UNAVAILABLE translation handle storage errors while successful empty reads remain no-ops.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f99a0c638ac5.

Labels

Label changes:

  • add P2: A transcript-storage failure currently produces a misleading successful compaction no-op, with bounded session-compaction impact.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a maintainer-authored PR, so the external-contributor real-behavior-proof gate does not apply; the added Gateway harness remains useful regression coverage.

Label justifications:

  • P2: A transcript-storage failure currently produces a misleading successful compaction no-op, with bounded session-compaction impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a maintainer-authored PR, so the external-contributor real-behavior-proof gate does not apply; the added Gateway harness remains useful regression coverage.

Evidence

What I checked:

Likely related people:

  • steipete: Introduced the current-main transcript-read behavior and authored the focused repair. (role: recent session-compaction feature contributor; confidence: high; commits: ac7dbe4f838f, f2b3169c912c; files: src/config/sessions/session-accessor.transcript.ts, src/gateway/server-methods/sessions-compact.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Resolve or rerun the failed exact-head CI job and wait for the remaining checks before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit a80ffd0 into main Aug 18, 2026
440 of 444 checks passed
@steipete
steipete deleted the codex/autoqa-session-compaction-read-errors branch August 18, 2026 09:09
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant