Skip to content

improve(gateway): discover Claude history without blocking requests - #145684

Merged
steipete merged 2 commits into
mainfrom
codex/perf-claude-history-7006
Sep 12, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/perf-claude-history-7006

Conversation

@steipete

@steipete steipete commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Related: #145679

What Problem This Solves

Resolves a problem where opening Claude CLI conversation history blocks other Gateway requests while searching a large project directory.

Why This Change Was Made

Async history snapshots now discover transcripts using asynchronous directory reads and bounded batches of filesystem probes. Results preserve directory-order precedence. Synchronous readers retain their existing synchronous contract; snapshot freshness and cache ownership stay unchanged.

User Impact

Other requests remain responsive during transcript discovery, including warm history reads. The selected transcript and imported messages remain unchanged.

Evidence

  • Synthetic NTFS fixture with 1,001 projects, exact-source resolver, Node 24.19, seven-run medians: queued callback delay 46.725 -> 0.116 ms; lookup completion 46.665 -> 47.551 ms. This demonstrates reduced event-loop blocking, not faster overall lookup.
  • Existing snapshot coverage extended to guard async discovery for cold/concurrent/warm reads and refresh after relocation. Additional coverage checks directory precedence when probes complete out of order and rejects path-like IDs.
  • Linux/Node 24.19: baseline passed all 141 tests across three suites; final candidate passed all 142. The corrected regression test failed on original production with three synchronous reads of the Claude projects directory versus zero expected.
  • The initial candidate test overreached into an unrelated synchronous config read during redaction. The final assertion targets transcript discovery while retaining output/cache checks; fresh review and original-failure/candidate-success proof confirm that scope.
  • Fresh full-patch and test-correction reviews: no P0-P2 findings. Formatting, diff checks, and final-head CI passed. Native merge completed as 41c45d213063896073a08b98d3a4f22d9ca72950.

@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 12, 2026 06:13
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Sep 12, 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 Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 12, 2026, 2:42 AM ET / 06:42 UTC (Revision 2).

ClawSweeper review

What this changes

Claude CLI history snapshots search project directories asynchronously in bounded batches so discovery does not block other Gateway requests.

Merge readiness

✅ Ready for maintainer review

This remains useful: current main and v2026.9.4 still perform synchronous transcript discovery. The reviewed patch preserves selection and cache behavior, and no actionable correctness or security defect was found.

Priority: P2
Reviewed head: 546b938ec47eb8b18a5cf71e86b1e55bea06d4f1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant regression coverage and bounded performance evidence; no blocking patch defect was found.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies a maintainer-authored PR, so the external-contributor proof gate does not apply. Reported exact-source NTFS measurements support reduced discovery blocking, while snapshot tests cover integration semantics; neither is presented as a whole-Gateway live measurement.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies a maintainer-authored PR, so the external-contributor proof gate does not apply. Reported exact-source NTFS measurements support reduced discovery blocking, while snapshot tests cover integration semantics; neither is presented as a whole-Gateway live measurement.
Evidence reviewed 7 items Introduced production change: The complete host-pinned merge-base-to-head patch changes only Claude discovery, its snapshot caller, and focused tests. The resolver uses batches of 16 and selects results in directory order; it reuses existing session-ID and candidate-path validation.
Current-main necessity: Current main calls synchronous discovery before cache lookup, and its resolver uses readdirSync and existsSync. The requested improvement is still absent.
Latest-release check: The supplied latest release, v2026.9.4, also calls the synchronous resolver in resolveSource; this release does not already contain the improvement.
Findings None None.
Security None None.

How this fits together

The Gateway combines OpenClaw chat history with transcripts from a bound Claude CLI session. Transcript discovery feeds the existing redacted snapshot cache and history response.

flowchart LR
  A[Chat history request] --> B[Bound Claude session]
  B --> C[Async project discovery]
  C --> D[First matching transcript]
  D --> E[Fingerprint and snapshot cache]
  E --> F[Redacted merged history]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +47, Tests +81. Total +128 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 50 3 +47
Tests 1 82 1 +81
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 132 4 +128

Review metrics

None.

Technical review

Best possible solution:

Keep asynchronous discovery within the existing Claude history owner while preserving directory precedence, snapshot invalidation, and synchronous fallback contracts.

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

Yes, from source: opening bound Claude history on current main synchronously scans project directories before checking the snapshot cache. The PR reports a matching synthetic reproduction; this review did not execute it.

Is this the best way to solve the issue?

Yes. Moving filesystem discovery onto asynchronous operations repairs the remaining blocking stage without changing transcript selection, stored state, or the synchronous callers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9e44dba516e8.

Labels

Label justifications:

  • P2: This is a bounded Gateway responsiveness improvement for installations with many Claude project directories.
  • 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: The supplied repository state identifies a maintainer-authored PR, so the external-contributor proof gate does not apply. Reported exact-source NTFS measurements support reduced discovery blocking, while snapshot tests cover integration semantics; neither is presented as a whole-Gateway live measurement.

Evidence

What I checked:

  • Introduced production change: The complete host-pinned merge-base-to-head patch changes only Claude discovery, its snapshot caller, and focused tests. The resolver uses batches of 16 and selects results in directory order; it reuses existing session-ID and candidate-path validation. (src/gateway/cli-session-history.claude.ts:484, 546b938ec47e)
  • Current-main necessity: Current main calls synchronous discovery before cache lookup, and its resolver uses readdirSync and existsSync. The requested improvement is still absent. (src/gateway/cli-session-history.claude.ts:455, 9e44dba516e8)
  • Latest-release check: The supplied latest release, v2026.9.4, also calls the synchronous resolver in resolveSource; this release does not already contain the improvement. (src/gateway/cli-session-history.claude-snapshot.ts:135, 3a9d69db306c)
  • Actual history entry point: The history-page reader awaits the imported snapshot and carries it through subsequent merges. Discovery still precedes realpath/stat fingerprinting, preserving relocation and freshness behavior; synchronous fallback readers retain their existing contract. (src/gateway/server-methods/chat-history-pages.ts:442, 546b938ec47e)
  • Re-review continuity and regression coverage: The latest commit changes only the previously overbroad test assertions, restricting them to transcript discovery. Reviewed tests cover cold/concurrent/warm reads, relocation, deletion, out-of-order probe completion, and path-like IDs. The prior review retained no findings. Tests were inspected, not executed during this read-only review. (src/gateway/cli-session-history.test.ts:294, 546b938ec47e)
  • Captured performance evidence and related campaign: The supplied complete PR body reports seven-run Node 24.19 NTFS measurements over 1,001 projects: callback delay fell from 46.725 to 0.116 ms while lookup completion stayed approximately unchanged. It also reports original-failure/candidate-success regression evidence and 142 passing candidate tests. Reduce repeated work across Gateway startup, history, and streaming #145679 explicitly identifies this PR as the Claude-discovery portion of a broader open performance campaign; it is not a replacement implementation. (546b938ec47e)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • jalehman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-12T06:19:11.591Z sha 5738d00 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 41c45d2 into main Sep 12, 2026
186 checks passed
@steipete
steipete deleted the codex/perf-claude-history-7006 branch September 12, 2026 07:02
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 13, 2026
…penclaw#145684)

* improve(gateway): discover Claude history without blocking requests

* test(gateway): scope async history assertions to transcript discovery
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