Repository navigation
improve: reduce repeated session startup scans - #99335
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 6, 2026, 8:15 AM ET / 12:15 UTC. Summary PR surface: Source +55, Tests +116. Total +171 across 2 files. Reproducibility: yes. Current main source reads the whole transcript in the reset guard, and the contributor posted a main-vs-branch benchmark for the same large generated transcript path. Review metrics: none identified. Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land the narrow streaming reset-guard change once the stale review state is resolved and the PR body accurately reflects that the AGENTS.md digest-cache change was dropped. Do we have a high-confidence way to reproduce the issue? Yes. Current main source reads the whole transcript in the reset guard, and the contributor posted a main-vs-branch benchmark for the same large generated transcript path. Is this the best way to solve the issue? Yes for the narrow reset guard. Streaming only the first non-empty header line preserves the old safety check while avoiding full-file materialization; the broader transcript tail-reader work remains with the linked canonical issue. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8b86645f5c9b. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +55, Tests +116. Total +171 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
|
@clawsweeper re-review Addressed the P1 session-state finding:
Validation run:
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review Addressed the new P1 capped-header finding:
Validation run:
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
3dfaa47 to
32edc68
Compare
|
🦞✅ Source: Why human review is needed: What the maintainer can do as a next step: I added |
|
One remaining concern on the AGENTS.md digest cache: please add before/after measurement for this part as well. The current one-entry cache is much easier to reason about than the previous 16-entry LRU, and I do not see a correctness blocker with the content-hash key. But the optimization still adds cache state and SHA-256 hashing to the bootstrap path, so it would be helpful to show that it actually wins for the intended case. Please include a small benchmark or timing comparison for a large AGENTS.md that exercises repeated |
|
Benchmark for the transcript reset-guard path requested by @hxy91819. Scope: only Input shape:
Result: median elapsed time drops from Additional process-level observation from
The RSS numbers include Node/tsx and benchmark script overhead, but they match the expected direction: the PR no longer materializes the full ~55 MiB transcript just to validate the first non-empty header. |
|
🦞✅ Source: Why human review is needed: What the maintainer can do as a next step: I added |
hxy91819
left a comment
There was a problem hiding this comment.
Approved. The requested changes have been addressed: the reset guard now streams to the first non-empty header without the 64 KiB compatibility cap, the AGENTS.md digest cache change was removed, and the transcript reset-guard benchmark shows the expected main-vs-branch improvement.
Please update the PR body before merge so it no longer mentions the removed AGENTS.md cache and so the Evidence section reflects the latest benchmark/current behavior.
|
@clawsweeper approve |
|
@clawsweeper automerge |
|
🦞👀 Command router queued. I will update this comment with the next step. |
Summary: - Merged improve: reduce repeated session startup scans after ClawSweeper review. Automerge notes: - PR branch already contained follow-up commit before automerge: fix: preserve blank-prefixed session header guard - PR branch already contained follow-up commit before automerge: fix: fail closed on capped transcript header scan - PR branch already contained follow-up commit before automerge: fix: stream transcript reset guard - PR branch already contained follow-up commit before automerge: chore: drop bootstrap digest cache change Validation: - ClawSweeper review passed for head baf54d8. - Required merge gates passed before the squash merge. Prepared head SHA: baf54d8 Review: openclaw#99335 (comment) Co-authored-by: momothemage <[email protected]> Approved-by: momothemage
Summary: - Merged improve: reduce repeated session startup scans after ClawSweeper review. Automerge notes: - PR branch already contained follow-up commit before automerge: fix: preserve blank-prefixed session header guard - PR branch already contained follow-up commit before automerge: fix: fail closed on capped transcript header scan - PR branch already contained follow-up commit before automerge: fix: stream transcript reset guard - PR branch already contained follow-up commit before automerge: chore: drop bootstrap digest cache change Validation: - ClawSweeper review passed for head baf54d8046217a1452182afbae93c69a113dc3f2. - Required merge gates passed before the squash merge. Prepared head SHA: baf54d8046217a1452182afbae93c69a113dc3f2 Review: openclaw/openclaw#99335 (comment) Co-authored-by: momothemage <[email protected]> Approved-by: momothemage
Summary: - Merged improve: reduce repeated session startup scans after ClawSweeper review. Automerge notes: - PR branch already contained follow-up commit before automerge: fix: preserve blank-prefixed session header guard - PR branch already contained follow-up commit before automerge: fix: fail closed on capped transcript header scan - PR branch already contained follow-up commit before automerge: fix: stream transcript reset guard - PR branch already contained follow-up commit before automerge: chore: drop bootstrap digest cache change Validation: - ClawSweeper review passed for head baf54d8046217a1452182afbae93c69a113dc3f2. - Required merge gates passed before the squash merge. Prepared head SHA: baf54d8046217a1452182afbae93c69a113dc3f2 Review: openclaw/openclaw#99335 (comment) Co-authored-by: momothemage <[email protected]> Approved-by: momothemage
Related: #99190
What Problem This Solves
Fixes an issue where long-lived session transcripts could still be touched with full-file scans on run startup paths even when only the first non-empty JSONL header line was needed.
Why This Change Was Made
The no-assistant session reset guard only needs to validate the first non-empty transcript header before deciding whether reset is safe. The previous implementation read the entire JSONL transcript into memory, which made startup work scale with full transcript size even when the header was at the beginning of the file.
This change replaces that full-file read with a small-chunk streaming first-non-empty-line reader. It returns as soon as the first non-empty header is found, keeps scanning until EOF for blank-prefixed transcripts, and preserves the existing fail-closed behavior for corrupt or invalid headers. That avoids introducing a new "header must appear within N bytes" compatibility constraint.
This intentionally does not replace SessionManager cold-open parsing with a tail-only reader yet; that path also restores model/thinking state, retained compaction tails, leaf controls, labels, and mutation-safe transcript state, so it needs a separate indexed or equivalence-proven design.
AI-assisted: yes.
User Impact
Users with long-running agent sessions should see less avoidable pre-LLM file work on reset-preparation startup paths. Behavior is unchanged for session reset safety, including blank-prefixed transcripts and corrupt-header preservation.
Evidence
node scripts/run-vitest.mjs src/agents/embedded-agent-runner/session-manager-init.test.tsnode_modules/.bin/oxfmt --check --threads=1 src/agents/embedded-agent-runner/session-manager-init.ts src/agents/embedded-agent-runner/session-manager-init.test.tsgit diff --checkBenchmark for the reset guard path only:
prepareSessionManagerForRunonly; transcript generation time is excluded.sessionJSONL header, followed by repeated user-message JSONL entries.57,752,670bytes (~55.1 MiB).0bytes after the guard passes.origin/main@8f2986290d32edc6865cResult: median elapsed time drops from
23.068 msto1.013 ms, about 22.8x faster / 95.6% less time for this path.Additional process-level observation from
/usr/bin/time -lfor the benchmark command:275,726,336bytes118,292,480bytesThe RSS numbers include Node/tsx and benchmark script overhead, but they match the expected direction: the PR no longer materializes the full ~55 MiB transcript just to validate the first non-empty header.