Skip to content

fix: avoid repeated background reads while loading chat - #146953

Merged
steipete merged 4 commits into
mainfrom
codex/team-load-remaining-roots
Sep 13, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/team-load-remaining-roots

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Related: #146810

What Problem This Solves

Fixes redundant background reads that compete with opening and using a chat, especially during catalog updates or discovery of large native-session histories.

User Impact

Model controls keep their current choices while refreshes converge, hidden native catalogs make forward progress, and subagent announcements avoid loading unrelated retained runs.

Why This Change Was Made

The model catalog owner retains one active request and one queued demand per connection, projection, and timeout policy. Publication, caller cancellation, and explicit numeric deadlines no longer release an outstanding transport early. Callers still receive their own timeout; a same-scope retry waits for the outstanding read or connection retirement instead of duplicating server work. Stale results, pushed snapshots, and reentrant subscriptions retain their existing authority checks.

Hidden native catalogs now advance a finite discovery sweep separately from visible-page reconciliation, within the existing single refresh lifecycle. Each refresh still checks the first page, completed empty sweeps restart, and archive/adoption or connection changes clear progress. Single-child announcement lookups use the existing indexed child snapshot, preserving generation selection, live-memory precedence, and persistence semantics.

Evidence

Regressions failed before each repair. Actual Gateway request-correlation tests cover invalidation bursts, cancellation, explicit timeout/retry/late-response ordering, queued deadlines, pushed snapshots, reconnects, and reentrant subscribers. Hidden discovery reaches the same eighth page in 14 requests instead of 35, with fresh-head, membership, cursor-error, visibility, and scope cases retained. The announcement tests verify requester and completion facts without full registry hydration.

Focused suites passed: 260 model-catalog and caller tests, 167 catalog tests after current-main integration, and 41 registry tests. Independent P2 reviews are clean. Final integration typechecks, lint, styles, export, schema, and import-cycle guards passed. Combined P2 review caught and led to correction of cursor-cycle recovery; its regression failed before the correction and now passes. The corrected combined review is clean. CI exposed caller fixtures coupled to raw cancellation and overlapping replies. Those fixtures now use the real metadata observer and verify serialized/stale-result behavior. The complete UI unit suite passed 17,326 tests across 991 files, and all 56 real-Gateway tests across 28 files passed on the final head, including held-response, draft-preservation, command-palette publication, and selected-agent scope checks. The palette test now identifies its own exact request without depending on the last request from concurrent Chat callers. Exact-head CI is 34755573027; production performance verification follows the canonical deployment after landing. No schema, retention, permission, dependency, or protocol changes are included.

Separate model catalog transports from caller cancellation and explicit deadlines. Advance empty native catalogs without replaying every prior page, and retire cyclic sweeps so discovery can recover. Use indexed child snapshots for announcement facts.
@steipete steipete self-assigned this Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Sep 13, 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 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 13, 2026, 7:59 AM ET / 11:59 UTC (Revision 4).

ClawSweeper review

What this changes

The PR serializes model-catalog refreshes, advances empty native-session discovery without replaying earlier pages, and narrows subagent announcement reads to the relevant child session.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful, distinct follow-up to the earlier merged catalog repair; current main still contains the redundant-read paths. No blocking correctness findings were identified.

Priority: P2
Reviewed head: 85d8215b63806e4dcd9a16305577a8c87c52131e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The implementation and targeted regression coverage are solid, with one outstanding scoped performance-validation requirement.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied maintainer classification exempts this PR from the external-contributor proof gate. Reported real-Gateway held-response tests cover model-read serialization and retained editor drafts; the scoped agent benchmark requirement remains separate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied maintainer classification exempts this PR from the external-contributor proof gate. Reported real-Gateway held-response tests cover model-read serialization and retained editor drafts; the scoped agent benchmark requirement remains separate.
Evidence reviewed 9 items Current main still needs the repair: At fetched main, model requests remain attached to display-cache entries, and announcement requester/completion lookups still request the full registry snapshot. Hidden discovery still uses visible-page depth tracking.
Transport lifetime and publication remain separate: The request owner retains its active slot until transport settlement, gives queued requests numeric deadlines, and preserves cache-generation checks before publication. OpenClaw's own Gateway pending-request implementation confirms that abort and timeout discard correlation without cancelling server work.
Existing scoped registry owner: The child snapshot uses the existing child-session SQL filter and merges live memory with persisted records; requester and completion queries retain their existing generation-selection logic. This changes read scope, not persistence or authorization policy.
Findings None None.
Security None None.

How this fits together

The Control UI reads model choices and session catalogs from the Gateway to populate chat controls and the sidebar. Separately, subagent announcements read retained run facts to identify their requester and completion state.

flowchart LR
  A[Chat and catalog changes] --> B[Scoped model request queue]
  B --> C[Gateway catalog reads]
  C --> D[Model controls and sidebar]
  E[Empty session pages] --> F[Finite discovery progress]
  F --> C
  G[Subagent announcement] --> H[Child session registry snapshot]
Loading

Before merge

  • Resolve merge risk (P1) - The child-session optimization's elapsed-time and peak-RSS benefit remains unquantified; functional scoping tests do not establish its performance magnitude.
  • Complete next step (P2) - Add the before/after child-session announcement benchmark required by src/agents/AGENTS.md, recording elapsed seconds, peak RSS, workload, and runtime.
Agent review details

Security

None.

PR surface

Source +273, Tests +511, Docs +4. Total +788 across 26 files.

View PR surface stats
Area Files Added Removed Net
Source 7 365 92 +273
Tests 17 686 175 +511
Docs 2 6 2 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 26 1057 269 +788

Review metrics

Metric Value Why it matters
Production versus test growth Production net +273 lines; tests and test support net +511 lines The stated production growth separates transport lifetime from caller completion and retains finite discovery progress.
Empty-history discovery 35 → 14 requests to reach page eight in the regression scenario This measures reduced repeated reads, while leaving elapsed time and RSS as separate evidence.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Chat metadata and announcements should converge with bounded background work, preserved drafts, and measured resource use.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Chat metadata and announcements should converge with bounded background work, preserved drafts, and measured resource use.

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

Yes, from source: invalidation or caller cancellation can release a model request while server work remains outstanding, and empty discovery replays earlier pages. The focused regressions exercise these triggers; this review did not run them.

Is this the best way to solve the issue?

Yes. The patch extends the existing request, discovery, and registry owners while preserving scope fences and caller cancellation; the scoped agent performance measurements remain outstanding.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 970992db26c8.

Labels

Label justifications:

  • P2: This is a bounded reliability and performance improvement for chat metadata, sidebar discovery, and announcement reads.
  • 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 maintainer classification exempts this PR from the external-contributor proof gate. Reported real-Gateway held-response tests cover model-read serialization and retained editor drafts; the scoped agent benchmark requirement remains separate.

Evidence

What I checked:

  • Current main still needs the repair: At fetched main, model requests remain attached to display-cache entries, and announcement requester/completion lookups still request the full registry snapshot. Hidden discovery still uses visible-page depth tracking. (ui/src/lib/model-catalog-store.ts:114, 970992db26c8)
  • Transport lifetime and publication remain separate: The request owner retains its active slot until transport settlement, gives queued requests numeric deadlines, and preserves cache-generation checks before publication. OpenClaw's own Gateway pending-request implementation confirms that abort and timeout discard correlation without cancelling server work. (ui/src/lib/model-catalog-store.ts:125, 85d8215b6380)
  • Existing scoped registry owner: The child snapshot uses the existing child-session SQL filter and merges live memory with persisted records; requester and completion queries retain their existing generation-selection logic. This changes read scope, not persistence or authorization policy. (src/agents/subagents/registry/subagent-registry-state.ts:407, 85d8215b6380)
  • Real-Gateway scenario matches the model change: The inspected browser scenario forwards traffic to a real Gateway, holds catalog replies, checks that another invalidation sends no overlapping read, releases the old reply, and verifies one replacement plus preserved editor drafts. The captured PR body reports this scenario passed; this review did not execute it. (ui/src/e2e/agent-file-lifecycle.real-gateway.e2e.test.ts:313, 85d8215b6380)
  • Prior benchmark requirement remains applicable: The fully read scoped policy requires before/after seconds and RSS for agent performance changes. The captured body provides functional results and discovery request counts but defers production performance verification until after landing; it does not supply the previously requested child-session measurements. (src/agents/AGENTS.md:61, 85d8215b6380)
  • Re-review continuity: The only change since the preceding reviewed head makes the palette test assert the requested agent scope among concurrent catalog requests. The previous review contained no code findings; its benchmark follow-up remains unresolved. (ui/src/e2e/command-palette-catalog.real-gateway.e2e.test.ts:582, 85d8215b6380)

Likely related people:

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

Rank-up moves

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

  • Record comparable before/after elapsed seconds and peak RSS for child-session announcement reads, including workload and runtime details.

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 (3 earlier review cycles)
  • reviewed 2026-09-13T11:04:54.868Z sha d5dc44a :: blocked before merge. :: none
  • reviewed 2026-09-13T11:14:49.991Z sha a746b26 :: blocked before merge. :: none
  • reviewed 2026-09-13T11:41:13.049Z sha 6bc7932 :: blocked before merge. :: none

Keep main’s single queued-refresh owner while preserving finite hidden catalog discovery, cycle recovery, and typed Gateway test fixtures.
@steipete
steipete marked this pull request as ready for review September 13, 2026 11:08
Use the application metadata observer for connection retirement and retain cancellation, stale-state, and loading assertions with serialized catalog responses. Exercise held old and new replies through the real Gateway without losing editor drafts.
@steipete
steipete merged commit 8d37c8a into main Sep 13, 2026
194 checks passed
@steipete
steipete deleted the codex/team-load-remaining-roots branch September 13, 2026 12:07
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '4aff70f27016f9acf62d0acc19c8bd3592993e4c': (1537 commits)
  test: align plugin fixtures with current runtime contracts (#147000)
  refactor(browser): separate session tab tracking from cleanup (#146973)
  fix(tests): make systemd clock fixtures private (#146990)
  fix(linux): retire sleep guards when logind disconnects (#146046)
  refactor(matrix): share draft fallback delivery (#144840)
  fix(sessions): preserve cross-agent replies after reload (#146799)
  test(models): cover quota recovery during catalog discovery (#146708)
  fix(macos): recover browser sign-in when no browser opens (#146787)
  fix(process): prevent one-shot agents exiting while polling (#144268)
  fix(status): label the session inventory as stored (#146979)
  fix: avoid repeated background reads while loading chat (#146953)
  refactor(ui): narrow Skill Workshop proposal context (#146977)
  perf(sessions): keep cleanup responsive and reuse workers (#140897)
  fix(sessions): prevent stranded writers after abort and restart (#146792)
  refactor: reuse deferred owners in Gateway and infra fixtures (#146809)
  fix: prevent queued conversation replies from switching storage (#146984)
  test(ui): preserve nested failure summaries in CI logs (#146864)
  fix(test): respect process memory limits in local scheduling (#146298)
  fix: validate large media data URLs without regexp stack exhaustion (#146972)
  fix(ui): label model usage contributions as messages (#146735)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* temp/pr-145950: (101 commits)
  refactor(memory-wiki): share freshness result construction (#146935)
  improve(gateway): use metadata projection for presence (#146817)
  test(agents): reuse complete Responses model fixtures (#147015)
  fix(sessions): align the reclamation-memory test with the archive session owner (#147028)
  refactor(terminal): simplify copy-sensitive token checks (#146934)
  refactor(media): remove duplicate spaced path fallback (#146933)
  refactor(cli): reuse command-group names (#146893)
  improve(plugins): reduce JavaScript generation capture work (#146993)
  test: align plugin fixtures with current runtime contracts (#147000)
  refactor(browser): separate session tab tracking from cleanup (#146973)
  fix(tests): make systemd clock fixtures private (#146990)
  fix(linux): retire sleep guards when logind disconnects (#146046)
  refactor(matrix): share draft fallback delivery (#144840)
  fix(sessions): preserve cross-agent replies after reload (#146799)
  test(models): cover quota recovery during catalog discovery (#146708)
  fix(macos): recover browser sign-in when no browser opens (#146787)
  fix(process): prevent one-shot agents exiting while polling (#144268)
  fix(status): label the session inventory as stored (#146979)
  fix: avoid repeated background reads while loading chat (#146953)
  refactor(ui): narrow Skill Workshop proposal context (#146977)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '060e856e5f9df245d63c98990fcb47e18108c6b9': (97 commits)
  refactor(memory-wiki): share freshness result construction (#146935)
  improve(gateway): use metadata projection for presence (#146817)
  test(agents): reuse complete Responses model fixtures (#147015)
  fix(sessions): align the reclamation-memory test with the archive session owner (#147028)
  refactor(terminal): simplify copy-sensitive token checks (#146934)
  refactor(media): remove duplicate spaced path fallback (#146933)
  refactor(cli): reuse command-group names (#146893)
  improve(plugins): reduce JavaScript generation capture work (#146993)
  test: align plugin fixtures with current runtime contracts (#147000)
  refactor(browser): separate session tab tracking from cleanup (#146973)
  fix(tests): make systemd clock fixtures private (#146990)
  fix(linux): retire sleep guards when logind disconnects (#146046)
  refactor(matrix): share draft fallback delivery (#144840)
  fix(sessions): preserve cross-agent replies after reload (#146799)
  test(models): cover quota recovery during catalog discovery (#146708)
  fix(macos): recover browser sign-in when no browser opens (#146787)
  fix(process): prevent one-shot agents exiting while polling (#144268)
  fix(status): label the session inventory as stored (#146979)
  fix: avoid repeated background reads while loading chat (#146953)
  refactor(ui): narrow Skill Workshop proposal context (#146977)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '4aff70f27016f9acf62d0acc19c8bd3592993e4c': (30 commits)
  test: align plugin fixtures with current runtime contracts (#147000)
  refactor(browser): separate session tab tracking from cleanup (#146973)
  fix(tests): make systemd clock fixtures private (#146990)
  fix(linux): retire sleep guards when logind disconnects (#146046)
  refactor(matrix): share draft fallback delivery (#144840)
  fix(sessions): preserve cross-agent replies after reload (#146799)
  test(models): cover quota recovery during catalog discovery (#146708)
  fix(macos): recover browser sign-in when no browser opens (#146787)
  fix(process): prevent one-shot agents exiting while polling (#144268)
  fix(status): label the session inventory as stored (#146979)
  fix: avoid repeated background reads while loading chat (#146953)
  refactor(ui): narrow Skill Workshop proposal context (#146977)
  perf(sessions): keep cleanup responsive and reuse workers (#140897)
  fix(sessions): prevent stranded writers after abort and restart (#146792)
  refactor: reuse deferred owners in Gateway and infra fixtures (#146809)
  fix: prevent queued conversation replies from switching storage (#146984)
  test(ui): preserve nested failure summaries in CI logs (#146864)
  fix(test): respect process memory limits in local scheduling (#146298)
  fix: validate large media data URLs without regexp stack exhaustion (#146972)
  fix(ui): label model usage contributions as messages (#146735)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
)

* fix: avoid repeated background reads while loading chat

Separate model catalog transports from caller cancellation and explicit deadlines. Advance empty native catalogs without replaying every prior page, and retire cyclic sweeps so discovery can recover. Use indexed child snapshots for announcement facts.

* test(ui): verify catalog callers across queued reads

Use the application metadata observer for connection retirement and retain cancellation, stale-state, and loading assertions with serialized catalog responses. Exercise held old and new replies through the real Gateway without losing editor drafts.

* test(ui): isolate palette catalog request scope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation 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: XL 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