Skip to content

perf(gateway): reuse prepared assistant identities and avatars - #158597

Merged
steipete merged 20 commits into
mainfrom
perf/l04-identity-avatar-preparation
Sep 26, 2026
Merged

steipete merged 20 commits into
mainfrom
perf/l04-identity-avatar-preparation

Conversation

@steipete

@steipete steipete commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Many browsers loading assistant identities and avatars can repeatedly block the Gateway thread on file admission, large identity parsing, and duplicate image work.

User Impact

Control UI bootstrap, agent rosters, and avatar responses reuse prepared content while file edits, atomic replacements, config changes, authentication, and native inline-avatar responses retain their existing behavior. There are no Gateway protocol, configuration, or database schema changes. The shipped synchronous avatar SDK contract remains synchronous.

Why This Change Was Made

The identity-file and local-avatar owners now acquire files in workers and retain bounded snapshots after fresh admission. URL projection and thumbnail delivery carry the same prepared revision. Descriptor custody, containment, hardlink rejection, size bounds, and cleanup stay with the file owner. Internal Gateway, CLI, search, and export callers use the asynchronous acquisition path.

Channel-avatar cold misses share one load, and an older completion cannot replace the current image. Thumbnail jobs remain coalesced while pending, independently of the four-entry completed-image cache. A deferred eviction test also protects the local avatar cache's byte accounting.

Evidence

Three paired runs of 100 warm conditional requests through the avatar handler, using the same 2,787,170-byte synthetic identity file, 2,090,343-byte PNG, and 27,773-byte thumbnail:

Median measurement Baseline Candidate
Main-thread CPU 649.04 ms 55.22 ms
Total handler time 1,074.22 ms 135.44 ms
Per-request p95 18.84 ms 2.97 ms
Maximum immediate-callback gap 1,074.96 ms 4.26 ms
Main-thread open/realpath calls 100 / 100 0 / 0

The CPU reduction is 91.5%. These are warmed synthetic handler measurements on a contended shared host, comparing the built baseline with the candidate source. Worker startup and network transport are excluded. Six overlapping thumbnail requests for five sources performed six decodes before and five after; the duplicate now reuses the same result. The channel HTTP regression verifies ten overlapping GET/HEAD requests share one media read.

  • Focused identity/avatar/search/CLI proof: 119 tests in seven files passed; node scripts/run-vitest.mjs src/agents/identity-file.test.ts src/gateway/assistant-identity.test.ts src/gateway/assistant-avatar.test.ts src/gateway/assistant-avatar-http.test.ts src/gateway/channel-avatar-http.test.ts src/gateway/session-utils.search.test.ts src/commands/agents.test.ts --maxWorkers=1, 1,180.68 seconds wall. Transformation and worker preparation dominated this host's runtime.
  • Avatar file owner: all ten cases passed in 22.08 seconds wall, including growth after descriptor admission, atomic replacement, restored mtime, symlink retargeting, hardlink rejection, metadata-to-body acquisition, and pending-cache eviction. The earlier combined cold run timed out six identity cases while the harness prepared 13,418 worker inputs in 570.27 seconds; the warmed replay passed without changing timeouts.
  • Focused caller proof: 97 cases passed in 1,210.96 seconds wall (control-ui.http.test.ts, server-methods/agent.test.ts, and claws/export.test.ts, filtered to avatar/identity/bootstrap/export behavior). The unrelated 453 Gateway cases were intentionally excluded. Final channel-avatar and chat-reply-context proof: 31 tests passed in 263.07 seconds wall, including the shared-ETag assertion and assistant reply labels.
  • pnpm build passed on Blacksmith Testbox in 534.12 seconds after a frozen-lockfile install (provider blacksmith-testbox, lease tbx_01m3dnfaxz1z7kn0q6bnb3s3xh, lease run). It emitted a non-blocking Control UI startup-JS budget warning (362.7 KiB versus 362.6 KiB); no UI source changed.
  • Changed-lane gate limitation: the exact-source remote run passed production types and the initial guards, then found two test-fixture type errors across two attempts; both were fixed. The last completed attempt took 287.21 seconds. The final replay could not execute because Blacksmith file sync exceeded its two-minute deadline (225.13 seconds end-to-end). The remaining changed-lane checks require hosted CI; no test assertions or timeouts were relaxed.
  • Deslop completed; isolated Codex review is scoped-clean through P2 at d76ba3ca38378c4fadfe53e0445ad7216b60726b.
  • Production growth funds the worker boundaries, bounded caches, and complete asynchronous caller migration while preserving the shipped synchronous SDK contract. Superseded Gateway descriptor plumbing and duplicate revision hashing were removed.

The open-PR overlap scan found shared files with #158567 (upload controls), #158548 (playback metadata), #158464 (static serving), #158443 (worker registry), #158378 (identity parser cleanup), and #158310 (Claw export). The identity parser cleanup was reconciled with the new acquisition kernel during landing, preserving its nullable parser result and the worker-backed read path.

Landing corrections and proof

Exact-head CI run 36213123921 found three redundant createDeferred<void>() type arguments in the avatar fixtures (typescript/no-unnecessary-type-arguments); these now use the helper's existing void default. The failed lint job caused the remaining run to be cancelled; it was not rerun to seek a green result.

The completed ClawSweeper review also found that worker admission or availability failures could escape optional workspace identity and avatar reads. Workspace presentation now treats failed identity preparation as absent; the shared local-avatar acquisition owner returns the existing unreadable result, preserving the Gateway, CLI, and export fallback behavior. Explicit identity-file reads continue to report errors. This resolves both reported review findings without changing the worker pool or adding caller-specific fallbacks.

The two authenticated bootstrap failure cases and the agent-list JSON failure case were each observed failing on the original implementation with the injected worker error, then passing after the repair. The bootstrap proof also exercised 29 existing cases (31 total, 53.44 seconds Vitest wall including cold worker compilation); the focused CLI regression took 4.43 seconds. The full CLI-list file passed 15 tests with its existing one skipped test in 16.36 seconds; identity/avatar owner coverage passed 26 tests across two files in 8.46 seconds. The latter combined wrapper command took 29.68 seconds wall. Focused lint passed in 32.96 seconds, formatting and git diff --check passed, and isolated Codex review of the corrections is scoped-clean through P2. Hosted CI remains the complete exact-head gate.

The next exact-head run, 36214689007 at 80c49b4ed12f0fae5ea4d1097c9f5b46b15d71a9, found two deterministic failures in session-utils.perf.test.ts. Its synthetic resident-row fixture did not supply the new identity-admission dependency, so intentional worker I/O triggered the fixture's no-yield assertion before row selection. Both failures reproduced locally. The test now supplies a completed missing-identity snapshot at that dependency, scoped and restored within the test; every existing no-yield, zero row-read, zero charged-work, and output assertion is retained. Production search still freshly admits the real workspace identity. The full performance and search suites passed together (37 tests; 69.11 seconds wrapper wall, 61.42 seconds Vitest wall), including atomic identity-file replacement between searches. Focused lint passed in 31.73 seconds; isolated Codex review is scoped-clean through P2. Source and fixture failures were not retried without corresponding verified corrections.

During CI for 674ff94775c32e2d99323941462063fae0742c56, main advanced with the Control UI static-file worker change and GitHub reported a content conflict. Current main was merged into the PR (no rebase). The sole conflict was a now-unused file-reader import block; both the prepared avatar path and main's static-file path are retained. Focused merged-source verification passed all 189 tests across control-ui.http.test.ts, assistant-avatar-http.test.ts, and assistant-avatar.test.ts (275.67 seconds wrapper wall; 234.70 seconds Vitest wall, dominated by transformation). Control UI lint and git diff --check passed, and independent review of the complete PR diff against merged main is scoped-clean through P2.

CI run 36216841560 exposed a missed main-side type consumer migration: control-ui-retained-assets.e2e.test.ts still imported ControlUiRootState from control-ui.ts after main moved the type to server-control-ui-root.ts. The same stale import was present on current main; main's latest recorded CI run 36217288599 was successful rather than evidence of a known red-main check. The test now imports the type from its owner, without a compatibility re-export or runtime/assertion changes. The focused core-test-ui-e2e graph reproduced TS2459 before the fix (30.41 seconds wall) and passed after it (10.17 seconds wall); formatting, whitespace validation, and independent P2 review passed.

CI run 36217992246 found an explicit-file CLI diagnostic regression: the worker snapshot retained the oversized-file classification but the caller discarded the nested filesystem error, removing the File exceeds ... diagnostic and too-large code from both human and JSON errors. The caller now reconstructs the typed FsSafeError cause from the known overflow result while preserving the outer identity-file message and optional workspace fallback. The existing CLI regression failed locally before the repair without assertion changes. The full identity-command suite (23 tests, 66.57 seconds Vitest wall) and identity-file suite (16 tests, 10.64 seconds) then passed; combined wrapper wall was 100.60 seconds, dominated by worker preparation. Focused lint, formatting, whitespace validation, and independent P2 review passed.

CI run 36219089079 exposed one HTTP test still observing workspace identity reads via main-thread realpathSync. Bootstrap already returned the correct real identity; the assertion contradicted the intentional worker migration. The failure reproduced locally. The test now observes the actual prepareIdentityFile call without stubbing it, verifies static routes skip that work, and requires zero main-thread identity filesystem calls for bootstrap as well as static routes. All HTTP and identity response assertions remain. The complete file passed 10 tests (26.93 seconds wrapper wall, 18.99 seconds Vitest wall), with focused lint and independent P2 review clean. A bounded review of other identity/avatar test callers found no additional concrete missed async migrations.

CI run 36220112920 failed the filesystem import-boundary guard on a newer main-side ACPX migration (ccaeab168629, #158551), which was absent from the PR head but included in its test merge. The defect reproduced on isolated main 63f1dec2b57e6883b65eaa108cd287bd29d6d551. Main repair 9d5ab59b5af88ccfac7af258a5a872caee5eeaf5 switches that one import to the existing public SDK export; no allowlist, baseline, test assertion, or migration logic changes. It passed 23 boundary tests, 14 ACPX migration tests, formatting, whitespace validation, and independent review before direct main publication. The repair was merged into this PR. Combined-tree proof passed 49 boundary/HTTP/identity tests in 59.27 seconds wrapper wall, and fresh review of the complete PR diff against merged main is scoped-clean through P2.

CI run 36221832093 then found a newer main-side chained assertion in progress snapshot coercion. Clean main reproduced the guard failure. Main fix 66b812f26e725cd709e08860d2cb46ba496cd308 (published through merge 007822d8693cb8d9474e7df773610123e1da1e02 after a concurrent-main push rejection) uses a native Reflect invocation without asserting a boxed value is already primitive. It preserves JSON ToNumber semantics, including custom hooks and BigInt rejection, and passed both lint guards, core types, 47 existing progress/history-budget tests, and independent review. The repair was merged into this PR without conflicts; all 207 HTTP/progress tests passed in 54.75 seconds wrapper wall. The PR delta's stable patch ID is unchanged from the preceding reviewed candidate, so its completed P2 review remains valid across this mechanical merge.

CI run 36223037178 passed the Node counterpart (1,056 tests) before the pinned Bun 1.4.3 canary build segfaulted during worker startup, before its tests ran (SIGSEGV at address 0x2, 514 ms elapsed, 0.44 GiB peak RSS with ample free memory). A single exact-job diagnostic replay on the same head and runtime passed as attempt 2 on the workflow-selected GitHub Ubuntu fallback runner (21 minutes). This demonstrates that the startup crash did not repeat; it is not a claim that the native runtime bug was fixed. The 82 jobs cancelled after the original crash were resumed through the failed/cancelled-jobs recovery path, with source and runtime pins unchanged.

Attempt 3's sole underlying failure was a stale response-authority fixture: avatar and thumbnail cases waited for the retired descriptor reader and timed out, cancelling the remaining jobs. The avatar timeout reproduced locally. The fixture now wraps real local-avatar preparation, asserts that the expected PNG bytes were successfully prepared before pausing, and preserves every 401/no-bytes/no-image-header/no-cookie assertion after authority changes. It also detects an early completed response and always releases and joins the pending handler, so a missing pause fails promptly rather than hanging. All four authority cases passed in 51.53 seconds wrapper wall (44.84 seconds Vitest wall; 6% test execution), with unchanged timeouts, clean lint/formatting, and independent review clean through P2 after closing the prepared-bytes proof gap.

While CI run 36227074145 was pending, main #158378 introduced the anticipated identity-parser conflict. Main was merged without rebasing. Its nullable parser and writer simplifications remain; the worker snapshot now stores the parser result directly instead of restoring the retired identityHasValues helper. Prepared reads, descriptor custody, overflow diagnostics, and the synchronous SDK contract remain intact. After reconciling current main's frozen dependencies, all 79 focused identity/avatar/CLI/search tests passed in 141.60 seconds wrapper wall, lint and whitespace checks passed, and fresh review of the full candidate is scoped-clean through P2.

CI run 36228419186 hit the already-observed main fixture race in server.sessions.archive-failed-worker.test.ts: synchronous fixture close starts asynchronous worker retirement, and reopening can hit the correct closing-admission guard. The original 22-file shard replay passed 273 tests in 250.26 seconds; that passing replay is not evidence of a fix. Main owner fix 6c7544adc9826fa637425a2fa967389e0507a800 explicitly awaits retirement before the scoped reset/reopen and also repairs cleanup teardown. It was merged here without changing the PR patch ID. The combined archive/cleanup proof passed all 11 tests in 324.13 seconds wrapper wall (cold worker preparation and host contention dominated); no production guard, schema, timeout, or assertion was weakened. The owner's reviewed main repair and its wider evidence are recorded in that commit.

CI run 36230423580 found three newly introduced main-side Codex filesystem imports outside the approved dependency surface. Existing main fix f2532a051f7a2c73731f7725184bff33b3b14f1f routes those error checks through the public error-runtime SDK while preserving ENOENT/ENOTDIR handling; it changes no allowlist. Its commit records Linux reproduction, 243 focused checks, build/changed gates, and P2 review. The patch and SDK equivalence were inspected, including maintained Codex marketplace source. After merging it, the PR patch ID remains unchanged and the exact import-boundary test independently passes all 23 cases (132.28 seconds wrapper wall on the contended host).

CI run 36232223693 found a filesystem-timing assumption in the avatar fixture: it rewrote equal-length bytes and restored mtime without ensuring ctime changed. Holding the admitted descriptor's ctime constant reproduced the exact stale-byte assertion locally; the CI log itself did not print the stat tuple, so a coarse timestamp tick is the supported diagnosis rather than directly captured runner telemetry. The fixture now controls only ctime for the original device/inode, forwards all fstat options unchanged, and retains real writes, reads, and the modified-body assertion. It also verifies unchanged device, inode, mtime, and size. No timers, retries, relaxed assertions, or production changes were added. All 18 avatar-owner and sibling tests passed in 10.30 seconds wrapper wall (6.86 seconds Vitest wall); the failed CI case took 0.005 seconds, and the cache-budget sibling accounted for 3.672 seconds. Independent review is scoped-clean through P2.

Freshness limitation: the shipped Gateway avatar cache already used path/device/inode/size/mtime/ctime as its revision. A rewrite preserving that entire tuple is not detected; this PR shares that existing metadata contract with CLI readers. The repaired test proves ctime invalidation, not content-hash freshness.

The focused check-changed run for this fixture passed, including the affected core-test type graph, lint, formatting, guards, and all three unused-export scans. The rest of the PR retains its previously recorded hosted/build proof; the new pushed head is gated again by hosted CI.

CI run 36234168110 at head 7e0caf57204c57f2bc56c41824458a5906801804 failed the conventional state-directory reuse assertion in server.sessions.store-paths.test.ts: automatic-runtime search made 56 state-root existence checks while the pinned-runtime path made zero. Final job metadata identifies checks-node-compact-small-15 as the underlying failed shard; the extension shard was cancelled. The dependency-review status briefly said security review was incomplete, then succeeded four seconds later in the same workflow; no retry was requested.

This failure remains unexplained after bounded investigation. The standalone case, complete owning file, and original 22-file/two-worker shared Gateway-server group passed locally. The first attempted broad replay used the aggregate local selector and was stopped after 445.47 seconds; it was replaced with the exact group recovered from CI's recorded plan. The exact group passed all 273 tests in 387.66 seconds. CI tested merge 1f9e5a48c15191e93643400cc7a28e07a4441f63, incorporating main 90869ccd9cfb36461a85a87f2cfd04a2714c320b. That immutable main parent was merged here without rebasing; the combined tree matched CI's source exactly, and its original group again passed all 273 tests in 251.77 seconds. No matching state-root probes were observed during these local runs. The automatic-auth path preserves its prepared state environment; background catalog or startup work remains a possible but unproven cause. Passing replays are not evidence of a fix.

The existing assertion now retains at most three exact state-root call stacks, labeled by search/runtime branch, in its failure message. Real filesystem calls, count comparisons, cleanup, and timeouts are unchanged; no production workaround or assertion relaxation was added. The final owning file passed all 10 tests in 34.77 seconds wrapper wall (32.47 seconds Vitest wall); CI's original failing case took 4.736 seconds. Independent review is scoped-clean through P2. This unresolved failure and the earlier native Bun startup crash remain explicit limitations, with landing still subject to the normal exact-head CI and native gates.

Targeted Gateway-server test types, lint, formatting, and whitespace validation passed for the diagnostic change. Hosted CI remains the full candidate gate.

Exact-head CI run 36236553886 completed successfully for cb4f9da10bc609a6d2526af5bec5a6de15ef42ae. Native preparation passed, but merge admission stopped before dispatch because main advanced with 2bdf8709fce5 and conflicted in control-ui.http.test.ts. The tool confirmed no merge request or outcome existed; its exact retained lock was recovered after verifying no child tools remained. Current main was merged without rebasing. The resolution preserves main's tracked temporary-directory helper and migrated callers, while preserving this PR's retirement of obsolete main-thread avatar-read fixtures; byte-free metadata admission, bounded growth and descriptor cleanup remain covered by the worker file-owner tests. All 153 focused HTTP/avatar tests passed in 132.90 seconds wrapper wall, targeted Gateway test types and lint passed, and fresh independent review of the full merged candidate is clean through P2. The new head requires fresh hosted CI before native landing is repeated.

CI run 36238633476 failed the QA scenario catalog after main's eaf8d916f7fa removed a private forwarding barrel. Two scenario YAML files still referenced extensions/qa-channel/src/protocol.ts instead of its existing SDK owner. The exact catalog assertion reproduced on isolated clean main (55 passed, 1 failed); main repair 18b0130a21b9b9aa6856b419ca0d22897f960c25 changes only those two references to src/plugin-sdk/qa-channel-protocol.ts. All 56 tests then passed, formatting and independent P2 review were clean, and the repair was published directly to main after reconciling a concurrent-main push rejection. No test assertion or scenario behavior changed. After merging the repair here without rebasing, all 56 catalog tests independently pass in 3.97 seconds wrapper wall. The PR delta's stable patch ID is unchanged from the preceding reviewed candidate, so that review remains valid. The failed run was not rerun; the corrected new head starts fresh CI.

@clawsweeper

clawsweeper Bot commented Sep 26, 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 app: web-ui App: web-ui gateway Gateway runtime commands Command implementations agents Agent runtime and tooling size: XL labels Sep 26, 2026
@steipete
steipete marked this pull request as ready for review September 26, 2026 02:54
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 26, 2026, 8:04 AM ET / 12:04 UTC (Revision 16).

ClawSweeper review

What this changes

The branch moves agent identity and avatar preparation into workers, reuses prepared results, and updates Gateway, CLI, search, and export callers.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open. The optimization is still absent from current main, but unscoped session search still prepares identities for configured agents that have no candidate sessions.

Priority: P2
Reviewed head: 41f442e984c694adab669ca92da1efe90dd9d674

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Handler-level performance evidence and focused validation are strong, but an unchanged search-scaling defect still blocks merge.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The changed Gateway avatar handler was exercised with synthetic identity and image files in paired baseline/candidate runs; the PR reports lower main-thread CPU and callback gaps after the change. Focused tests supplement that result. The prepared screenshots depict a separate upload-controls PR and do not support this performance claim. No stored-data contract changes.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The changed Gateway avatar handler was exercised with synthetic identity and image files in paired baseline/candidate runs; the PR reports lower main-thread CPU and callback gaps after the change. Focused tests supplement that result. The prepared screenshots depict a separate upload-controls PR and do not support this performance claim. No stored-data contract changes.
Evidence reviewed 10 items Introduced search work: Unscoped search seeds the identity set with every configured agent, then awaits identity resolution with concurrency four, including agents without candidate sessions.
Search entry points: Session listing and transcript search both await the preparation before selecting results.
Coverage gap: The added search test has one configured agent and one session; it proves name refresh after file replacement but cannot detect reads for unused configured agents.
Findings 1 actionable finding [P2] Limit identity preparation to candidate-session agents
Security None None.

How this fits together

The Gateway reads agent configuration and workspace identity files to serve names and avatars to Control UI and other clients. Session search uses those names when selecting session rows.

flowchart LR
  A[Agent config and workspace files] --> B[File workers]
  B --> C[Prepared identities and avatars]
  C --> D[Gateway responses]
  D --> E[Control UI and clients]
  F[Candidate sessions] --> G[Search selection]
  C --> G
  G --> D
Loading

Before merge

  • Limit identity preparation to candidate-session agents (P2) - For unscoped search, listAgentIds(prepared.cfg) adds every configured agent before either entry point selects candidate sessions. Each search then awaits worker reads for agents with no matching session, so a large roster can delay a small search result. Build this set from candidate session targets and cover an unused configured agent.
  • Resolve merge risk (P1) - On a large configured roster, an unscoped search can wait for identity-file work for agents with no candidate sessions, increasing search latency and worker queue pressure.
  • Complete next step (P2) - Bound unscoped identity preparation to candidate-session agents, cover an unused configured agent, and report changed-test costs before merge.

Findings

  • [P2] Limit identity preparation to candidate-session agents — src/gateway/session-utils-list.ts:310
Agent review details

Security

None.

PR surface

Source +442, Tests +446. Total +888 across 41 files.

View PR surface stats
Area Files Added Removed Net
Source 25 804 362 +442
Tests 16 746 300 +446
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 41 1550 662 +888

Review metrics

Metric Value Why it matters
Production versus test growth production net +413 lines; tests net +475 lines The PR attributes production growth to worker boundaries, bounded caches, and asynchronous caller migration; test cost still needs per-file reporting.

Merge-risk options

Maintainer options:

  1. Bound search preparation (recommended)
    Prepare identities only for agents represented by candidate sessions, then verify that an unused configured agent causes no file admission.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Restrict unscoped identity preparation to candidate-session agents in both list and transcript search. Preserve the explicitly scoped fallback and name-search results. Add an unused configured-agent regression that verifies its identity file is not admitted.

Technical review

Best possible solution:

Derive search identity preparation from candidate session targets while retaining scoped-agent behavior, current name matching, and the synchronous Plugin SDK contract.

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

Yes, by source inspection: configure agents with no sessions, run an unscoped session search, and observe identity preparation for those unused agents. I did not execute that scenario in this read-only review.

Is this the best way to solve the issue?

The worker-owned avatar preparation is a sound fit. The search addition needs candidate-based admission so a small result set does not wait on an unrelated roster.

Full review comments:

  • [P2] Limit identity preparation to candidate-session agents — src/gateway/session-utils-list.ts:310
    For unscoped search, listAgentIds(prepared.cfg) adds every configured agent before either entry point selects candidate sessions. Each search then awaits worker reads for agents with no matching session, so a large roster can delay a small search result. Build this set from candidate session targets and cover an unused configured agent.
    Confidence: 0.95

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The branch addresses a useful Gateway responsiveness problem, while the remaining defect has a limited search-performance blast radius.
  • merge-risk: 🚨 availability: The introduced unscoped search path waits on identity preparation for configured agents without candidate sessions.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The changed Gateway avatar handler was exercised with synthetic identity and image files in paired baseline/candidate runs; the PR reports lower main-thread CPU and callback gaps after the change. Focused tests supplement that result. The prepared screenshots depict a separate upload-controls PR and do not support this performance claim. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed Gateway avatar handler was exercised with synthetic identity and image files in paired baseline/candidate runs; the PR reports lower main-thread CPU and callback gaps after the change. Focused tests supplement that result. The prepared screenshots depict a separate upload-controls PR and do not support this performance claim. No stored-data contract changes.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/gateway/session-utils.search.test.ts src/gateway/session-utils.perf.test.ts --maxWorkers=1.
  • [P1] git diff --check.

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • cxbAsDev: 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.

  • Limit identity preparation to candidate-session agents and prove an unused configured agent is not read.
  • Add per-file wall time and available CI seconds for materially changed tests to the PR body, or explain which figures are unavailable.

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 (15 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-26T06:20:22.548Z sha b4d0c62 :: blocked before merge. :: none
  • reviewed 2026-09-26T07:00:29.228Z sha b4d0c62 :: blocked before merge. :: none
  • reviewed 2026-09-26T08:09:27.737Z sha 079f1e6 :: blocked before merge. :: [P2] Limit identity prefetch to agents with candidate sessions
  • reviewed 2026-09-26T08:48:36.015Z sha 0bd968e :: blocked before merge. :: [P2] Limit identity prefetch to agents with candidate sessions
  • reviewed 2026-09-26T09:23:25.300Z sha 82f8b67 :: blocked before merge. :: [P2] Restrict identity prefetch to candidate-session agents
  • reviewed 2026-09-26T10:01:08.673Z sha 7e0caf5 :: blocked before merge. :: [P2] Restrict identity preparation to candidate-session agents
  • reviewed 2026-09-26T10:48:29.725Z sha cb4f9da :: blocked before merge. :: [P2] Restrict identity preparation to candidate-session agents
  • reviewed 2026-09-26T11:30:19.468Z sha 7339407 :: blocked before merge. :: [P2] Prepare identities only for agents with candidate sessions

Keep Control UI bootstrap and agent listing available when optional identity or avatar worker preparation rejects. Preserve explicit identity-file errors, add entrypoint regressions, and remove redundant deferred generic arguments reported by CI.
Keep the resident-row no-yield fixture independent of intentional worker file admission. Preserve all selection, no-yield, and row-read assertions; real identity-file freshness remains covered by the search suite.
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 26, 2026
Resolve the Control UI import overlap after both branches retired the synchronous descriptor paths. Preserve the worker-backed avatar flow and current main static-file serving.
@clawsweeper clawsweeper Bot added the rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. label Sep 26, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 26, 2026
Keep the real equal-size rewrite and restored mtime while explicitly advancing the admitted descriptor ctime. This removes filesystem tick timing from the cache invalidation assertion without weakening body, identity, or replacement checks.
Incorporate the immutable main parent from CI run 36234168110 without rebasing. The merged source matches that CI checkout exactly; its original 22-file Gateway server group passes all 273 tests locally. This replay does not establish a fix for the unreproduced state-directory probe failure.
Retain at most three exact state-root probe stacks in the existing performance assertion. Preserve the real filesystem calls, count comparisons, and cleanup. CI observed 56 probes versus zero, but exact merged-source shard replay did not reproduce it; diagnostics preserve that uncertainty without adding a speculative workaround.
Keep main’s temporary-directory helper and migrated callers while retaining worker-kernel ownership of avatar descriptor and growth proof. Focused HTTP/avatar tests, targeted types and lint pass; fresh review of the merged candidate is clean through P2.
Include the verified main repair for scenario references to the retired QA channel forwarding barrel. The combined catalog suite passes all 56 tests. The PR delta retains the same stable patch ID as the previously reviewed candidate.
@steipete
steipete merged commit 4e4473b into main Sep 26, 2026
224 of 225 checks passed
@steipete
steipete deleted the perf/l04-identity-avatar-preparation branch September 26, 2026 12:22
@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 27, 2026
…law#158597)

* perf(gateway): prepare assistant identities and avatar responses

* test(agents): type avatar rejection cases as fixed pairs

* test(gateway): assert the shared avatar response ETag

* fix(agents): preserve optional identity reads on worker failure

Keep Control UI bootstrap and agent listing available when optional identity or avatar worker preparation rejects. Preserve explicit identity-file errors, add entrypoint regressions, and remove redundant deferred generic arguments reported by CI.

* test(gateway): prepare identity input for resident row proof

Keep the resident-row no-yield fixture independent of intentional worker file admission. Preserve all selection, no-yield, and row-read assertions; real identity-file freshness remains covered by the search suite.

* test(ui): import retained asset root state from its owner

* fix(agents): retain explicit identity overflow diagnostics

* test(gateway): observe worker-backed bootstrap identity reads

* test(gateway): pause prepared avatars for authority checks

* test(agents): control avatar cache ctime invalidation fixture

Keep the real equal-size rewrite and restored mtime while explicitly advancing the admitted descriptor ctime. This removes filesystem tick timing from the cache invalidation assertion without weakening body, identity, or replacement checks.

* test(gateway): capture state-directory probe failure provenance

Retain at most three exact state-root probe stacks in the existing performance assertion. Preserve the real filesystem calls, count comparisons, and cleanup. CI observed 56 probes versus zero, but exact merged-source shard replay did not reproduce it; diagnostics preserve that uncertainty without adding a speculative workaround.
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 commands Command implementations gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant