Repository navigation
perf(agents): keep turn-path model catalog reads off the full live build - #120834
Conversation
|
Codex review: needs changes before merge. Reviewed August 9, 2026, 1:44 AM ET / 05:44 UTC. ClawSweeper reviewWhat this changesThis PR replaces full live model-catalog construction during embedded and cron thinking selection with manifest-first, provider-scoped reads and memoizes plugin skill-directory publication. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open: the model-catalog repair is well-targeted, but the new plugin-skill memo can retain ACPX skills across a mutable ACP availability change, hiding available tools or exposing unavailable ones. Priority: P1 Review scores
Verification
How this fits togetherAgent and cron turns consult model metadata to validate thinking levels before starting a run. Separately, skills refresh publishes eligible plugin skill directories so the agent sees only tools supported by the current runtime. flowchart TD
A[Agent or cron turn] --> B[Thinking capability lookup]
B --> C[Manifest and scoped model catalog]
C --> D[Provider discovery]
D --> E[Selected model run]
F[Skills refresh] --> G[Plugin skill directories]
G --> H[Agent tool availability]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +133, Tests +220. Total +353 across 50 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep the scoped catalog repair, but make skill-directory caching depend on current ACP availability and prove both unavailable-to-available and available-to-unavailable transitions with one stable config and metadata snapshot. Do we have a high-confidence way to reproduce the issue? Yes. With one stable config and metadata snapshot, call the skill resolver, change ACP backend availability, and call it again; the memo returns the prior ACPX directory set without reevaluating the gate. Is this the best way to solve the issue? No. The provider-scoped catalog design is the best fix for the turn-path stall, but the memo must also reflect the ACP state that controls whether ACPX skills are eligible. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 562129d5df37. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Addressing the ClawSweeper review (reviewed head
Measured impact recap (isolated dist gateway, live OpenAI |
First agent turns (embedded and cron) resolved thinking capability through loadPreparedModelCatalogSnapshot without readOnly, which materialized the full live model-runtime catalog: ambient synthetic-auth discovery fanned out to every registered provider and loaded plugin discovery modules through jiti source transform (3,172 TS modules, 36s event-loop block, +600MB heap, 58.7s model-selection on a cold gateway). - add loadProviderScopedThinkingCatalog: manifest metadata first, then a provider-scoped read-only static catalog, then scoped live discovery only for runtime-discovery providers (preserves #116584 Ollama semantics) - route scopedLiveProviderDiscovery through the scoped read-only loader - scope live-mode ambient synthetic-auth refs to the requested providers - bound the last-resort synthetic-auth sweep to discovery entry modules - memoize per-turn plugin skill dir resolution/republish (single-slot, lifecycle-cleared; was a full walk + symlink republish every turn) Cold first turn 72.7s -> ~22s wall (remaining cost is provider prefill of the ~19.5k-token default prompt); model-selection 58,726ms -> 124ms.
…catalog seam Explicit vi.mock factories must export every binding prod touches; the new loadProviderScopedThinkingCatalog export is now mocked everywhere the module is stubbed, and the live-model-switch Ollama hydration test asserts the new provider-scoped seam instead of the retired unscoped snapshot call shape.
…log mock; split synthetic-auth helpers - add loadProviderScopedThinkingCatalog to all explicit prepared-model-catalog and model-catalog.runtime mock factories (vi.mock factories must export every binding prod touches) - move synthetic-auth ref scoping/resolution into prepared-model-runtime.synthetic-auth.ts; keeps facts under the max-lines cap
Boundary proof for the ClawSweeper review gap: the three-tier helper stops at manifest or scoped-static when they resolve, and runs provider-scoped live discovery (no broad fanout) only for runtime-only models; cron selection hydrates through the same scoped helper and skips it entirely for thinking=off.
b80c1e9 to
59992e5
Compare
…ild (openclaw#120834) * perf(agents): keep turn-path model catalog reads off the full live build First agent turns (embedded and cron) resolved thinking capability through loadPreparedModelCatalogSnapshot without readOnly, which materialized the full live model-runtime catalog: ambient synthetic-auth discovery fanned out to every registered provider and loaded plugin discovery modules through jiti source transform (3,172 TS modules, 36s event-loop block, +600MB heap, 58.7s model-selection on a cold gateway). - add loadProviderScopedThinkingCatalog: manifest metadata first, then a provider-scoped read-only static catalog, then scoped live discovery only for runtime-discovery providers (preserves openclaw#116584 Ollama semantics) - route scopedLiveProviderDiscovery through the scoped read-only loader - scope live-mode ambient synthetic-auth refs to the requested providers - bound the last-resort synthetic-auth sweep to discovery entry modules - memoize per-turn plugin skill dir resolution/republish (single-slot, lifecycle-cleared; was a full walk + symlink republish every turn) Cold first turn 72.7s -> ~22s wall (remaining cost is provider prefill of the ~19.5k-token default prompt); model-selection 58,726ms -> 124ms. * test(agents): align model-catalog.runtime mocks with scoped thinking catalog seam Explicit vi.mock factories must export every binding prod touches; the new loadProviderScopedThinkingCatalog export is now mocked everywhere the module is stubbed, and the live-model-switch Ollama hydration test asserts the new provider-scoped seam instead of the retired unscoped snapshot call shape. * test(agents): export scoped thinking catalog from every prepared-catalog mock; split synthetic-auth helpers - add loadProviderScopedThinkingCatalog to all explicit prepared-model-catalog and model-catalog.runtime mock factories (vi.mock factories must export every binding prod touches) - move synthetic-auth ref scoping/resolution into prepared-model-runtime.synthetic-auth.ts; keeps facts under the max-lines cap * test(agents): prove scoped thinking hydration for runtime-only models Boundary proof for the ClawSweeper review gap: the three-tier helper stops at manifest or scoped-static when they resolve, and runs provider-scoped live discovery (no broad fanout) only for runtime-only models; cron selection hydrates through the same scoped helper and skips it entirely for thinking=off. * test(agents): accept rest args in scoped thinking catalog mocks
What Problem This Solves
A fresh gateway's first agent turn took 65-73 seconds with a 36.6s event-loop block and ~+600MB heap — on a default config with a manifest-backed model (
openai/gpt-5.6-luna). During the stall the gateway is unresponsive (healthz timeouts, WS closes), which on production source checkouts also manifests as slow post-update recovery and degraded event-loop health.Root cause: embedded (and cron isolated-agent) model selection could not resolve a model's thinking capability from any cheap catalog —
configuredThinkingCatalogis empty withoutmodels.providers, and the manifest catalog is only consulted when an allowlist or configured models exist — so it fell back toloadPreparedModelCatalogSnapshotwithoutreadOnly, which materializes the full live prepared-model-runtime catalog. That live build runs ambient synthetic-auth discovery across every registered provider ref, andresolveProviderSyntheticAuthWithPlugin's last-resort branch loads all provider plugins unfiltered. On source checkouts these loads go through jiti source transform: 3,172 TS modules transpiled inside the first turn (CPU profile: ~50s under jiti/babel stacks + 11s GC).The answer it was looking for (Luna
reasoning: true) sits in the openai plugin manifest, loadable in ~7ms.Why This Change Was Made
Per the repo architecture rules: hot paths must carry prepared facts forward instead of broad request-time plugin/provider discovery, and full catalog materialization belongs to explicit control-plane reads.
loadProviderScopedThinkingCatalog(inprepared-model-catalog.ts, exported via themodel-catalog.runtimebarrel): manifest metadata → provider-scoped read-only static catalog → provider-scoped live discovery only when the entry is still unresolved (preserves the fix(agents): preserve thinking for runtime-selected Ollama models #116584 runtime-selected-Ollama-model semantics). Used by both the embedded and cron thinking fallbacks (previously two copies of the unscoped pattern).scopedLiveProviderDiscoveryparam routes scoped read-only loads toprepareScopedReadOnlyLiveModelCatalog.providerDiscoveryProviderIdswhen the build is provider-scoped.providerRefs.length === 1last-resort synthetic-auth sweep is bounded to discovery entry modules (discoveryEntriesOnly+includeSyntheticAuthProviders) instead of full plugin loads.Deliberately NOT changed: media-understanding catalog reads stay non-readOnly —
runner.vision-skip.test.tsasserts that contract from the lifecycle-owner refactor (#111173).User Impact
agent.startup stage=model-selection58,726ms → 124-508ms; no event-loop block, no memory spike. Remaining cold-turn latency is provider prefill of the ~19.5k-token default first-turn payload (cacheWrite 19,534, cacheRead 0) — follow-up below.Evidence
cacheRead: 0confirms).src/skills/runtime/refresh.test.ts(35),src/skills/loading/plugin-sandbox-sync.test.ts,src/media-understanding/runner.vision-skip.test.ts(18),src/cron/isolated-agent/run.cron-runtime-model-thinking.test.ts,src/plugins/provider-runtime.synthetic-auth-discovery.test.ts,src/plugins/provider-discovery.runtime.test.ts(30),src/agents/prepared-model-runtime.startup-static.test.ts,src/agents/model-selection-display.test.ts.pnpm buildgreen (no INEFFECTIVE_DYNAMIC_IMPORT; cli-bootstrap-imports check passed).Follow-ups (named, not in this PR):
providerDiscoverySourceto TS sources when no installed index exists; control-plane full reads still jiti-compile once per process. Mapping manifest records to built dist artifacts would remove that class.update.statusreportsinstall.git.status="unavailable" reason="no-upstream"on campaign-managed detached-HEAD checkouts (observed on production team host) — reporting gap, separate surface.