Skip to content

improve(gateway): skip unconfigured model catalog startup work - #127117

Merged
steipete merged 1 commit into
mainfrom
codex/perf-gateway-startup-model-planning
Aug 21, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-gateway-startup-model-planning

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gateway startup planned and normalized the complete plugin-owned model catalog before checking whether any agent model was configured. An empty configuration therefore traversed every manifest model and pulled remote-refresh networking into the startup import graph without using those results.

Why This Change Was Made

The startup collector now gathers configured default and per-agent model references first, returns immediately when none exist, and scopes the canonical catalog planner by normalized provider and merge key. Provider and model filtering happens before normalization, and remote overlay access is provider-scoped. Pure refresh enablement/URL configuration moved to a network-free module so startup planning no longer imports remote refresh machinery.

Aliases and overrides, trusted transport fields, remote overlay identity, pricing, and full unscoped catalog behavior remain unchanged. No provider-specific branch, cache, configuration option, protocol, or public API was added.

User Impact

Gateways with few or no configured agent models avoid unrelated plugin catalog normalization during startup. In the synthetic current-main workload, 2,000 empty-config calls improved from 2,042.56 ms total to a 2.82 ms median total (723×, 99.86%). The broad startup suite also reduced max RSS from 536,256 KB to 390,300 KB, though the focused benchmark is the primary evidence.

Evidence

  • Current-main regression first failed 0/2: empty config inspected a throwing unconfigured catalog, and one selected model read 20,000 unrelated normalization properties. It passes 2/2 after the owner-boundary fix.
  • Three post-fix 2,000-call runs: 3.784 / 2.724 / 2.824 ms total; unscoped planning still returns exactly 40 entries, 254 rows, and zero conflicts.
  • Startup collector import graph excludes remote-refresh.ts; overlay graph shrank from 185 to 156 modules and excludes both remote-refresh.ts and fetch-guard.ts.
  • Focused startup/planner/alias/overlay/pricing/import-boundary coverage: 56/56 passed locally on the published commit.
  • Broad startup coverage: 171/171 passed.
  • node scripts/check-changed.mjs -- <12 changed paths> passed all routed checks, typechecks, lint, import-cycle and architecture guards.
  • Full pnpm build passed, including postbuild and SDK/UI checks.
  • git diff --check passed.
  • Fresh autoreview and TruffleHog were clean; no actionable findings, correctness confidence 0.99.

AI-assisted implementation and verification. The change and its owner boundaries were reviewed; no agent transcript is attached because transcript publication was not authorized.

@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations size: M maintainer Maintainer-authored PR labels Aug 21, 2026
@steipete
steipete marked this pull request as ready for review August 21, 2026 08:46
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 4:51 AM ET / 08:51 UTC.

ClawSweeper review

What this changes

The PR avoids unneeded Gateway startup catalog work by collecting configured agent model references first, filtering catalog planning to those providers and models, and separating refresh configuration from network-refresh code.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer review: current main still performs full catalog planning before discovering that no agent model is configured, while this branch moves the decision to the startup owner and scopes the resulting planner work. No blocking correctness finding was identified; the protected maintainer label and incomplete exact-head checks keep the merge disposition human-owned.

Priority: P3
Reviewed head: b0b73a82cfc34ff0f8f4e5400688592b0b9bd0ed

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-supported startup optimization with meaningful boundary coverage and no identified correctness defect.
Proof confidence 🌊 off-meta tidepool Not applicable: This is maintainer-authored work, so the external-contributor proof gate does not apply; the PR body nevertheless reports focused before/after owner-boundary checks and broader local validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is maintainer-authored work, so the external-contributor proof gate does not apply; the PR body nevertheless reports focused before/after owner-boundary checks and broader local validation.
Evidence reviewed 6 items Current-main eager path: Current main invokes the full effective catalog planner before it collects configured model references, so an empty model configuration still traverses manifest catalog data.
Branch fixes the owner boundary: The branch gathers configured provider/model pairs, returns when none exist, and passes exact provider and merge-key filters into the canonical catalog planner.
Alias and overlay preservation: The planner filters requested providers before resolving their overlay and filters manifest and remote models by the normalized merge key; the added test covers an alias with a remote overlay.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/plugins/gateway-startup-plugin-providers.test.ts

Result: FAIL (partial) — step 2 expect_output does not inspect model catalogs when no agent model refs are configured: expected terminal output was not visible within 30 seconds: "does not inspect model catalogs when no agent model refs are configured"

node scripts/run-vitest.mjs src/plugins/gateway-startup-plugin-providers.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127117-BRYk1B/target$ node scripts/run-vitest.mjs src/plugins/gateway-startup-plugin-providers.test.ts
node scripts/run-vitest.mjs src/plugins/gateway-startup-plugin-providers.test.ts
[test] starting test/vitest/vitest.unit-fast.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-127117-BRYk1B/target

 ✓  unit-fast  src/plugins/gateway-startup-plugin-providers.test.ts (2 tests) 18ms

 Test Files  1 passed (1)
      Tests  2 passed (2)
   Start at  08:52:53
   Duration  2.44s (transform 1.71s, setup 105ms, import 2.16s, tests 18ms, environment 0ms)

[test] passed 1 Vitest shard in 13.93s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127117-BRYk1B/target$ node scripts/run-vitest.mjs src/plugins/gateway-startup-plugin-providers.test.ts
[test] starting test/vitest/vitest.unit-fast.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-127117-BRYk1B/target

 ✓  unit-fast  src/plugins/gateway-startup-plugin-providers.test.ts (2 tests) 18ms

 Test Files  1 passed (1)
      Tests  2 passed (2)
   Start at  08:53:08
   Duration  1.21s (transform 512ms, setup 32ms, import 997ms, tests 18ms, environment 0ms)

[test] passed 1 Vitest shard in 12.64s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127117-BRYk1B/target$






















Assertions:

  • FAIL expect_output: does not inspect model catalogs when no agent model refs are configured

How this fits together

Gateway startup chooses which plugin providers must load from configured agent model references. It consults plugin manifest catalog metadata and optional stored remote overlays to resolve provider APIs before activating the corresponding plugin runtimes.

flowchart LR
  A[Gateway configuration] --> B[Configured agent model references]
  B --> C[Startup provider collector]
  C --> D[Scoped catalog planner]
  E[Stored remote catalog overlay] --> D
  D --> F[Provider API ownership]
  F --> G[Plugin activation plan]
Loading

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch as clean but behind main, and exact-head checks are still in progress; final merge review should use the resulting merge state and completed checks.
  • Complete next step (P2) - The maintainer label requires human merge handling; wait for exact-head checks and confirm the clean merge state rather than opening an automated repair.
Agent review details

Security

None.

PR surface

Source +47, Tests +172. Total +219 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 6 83 36 +47
Tests 6 196 24 +172
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 279 60 +219

Review metrics

Metric Value Why it matters
Production versus test LOC production +83/-36 (net +47); tests +196/-24 (net +172) The production growth is concentrated in canonical provider/model filtering and the network-free refresh-config seam; the larger test delta protects empty-config, alias-overlay, and import-boundary behavior.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the canonical planner filters and network-free refresh-config seam, then land only after maintainer review confirms the clean merge result and exact-head checks.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the canonical planner filters and network-free refresh-config seam, then land only after maintainer review confirms the clean merge result and exact-head checks.

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

Yes, from source: current main calls full catalog planning before scanning configured model references, and the branch's focused test makes that unnecessary inspection observable with a throwing getter.

Is this the best way to solve the issue?

Yes. Filtering at the canonical catalog planner preserves the unscoped callers while allowing the Gateway startup owner to avoid catalog normalization it cannot use.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a focused Gateway startup performance improvement without a reported user-facing failure or security impact.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is maintainer-authored work, so the external-contributor proof gate does not apply; the PR body nevertheless reports focused before/after owner-boundary checks and broader local validation.

Label justifications:

  • P3: This is a focused Gateway startup performance improvement without a reported user-facing failure or security impact.
  • 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: This is maintainer-authored work, so the external-contributor proof gate does not apply; the PR body nevertheless reports focused before/after owner-boundary checks and broader local validation.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Current-main blame attributes the startup provider lookup and catalog-planning surface to this recent commit. (role: feature introducer and recent area contributor; confidence: high; commits: e7cfff216735; files: src/plugins/gateway-startup-plugin-providers.ts, src/model-catalog/manifest-planner.ts, src/model-catalog/index.ts)

Rank-up moves

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

  • Allow the exact-head CI run to complete and review the clean merge result before landing.

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.

@steipete
steipete force-pushed the codex/perf-gateway-startup-model-planning branch from b0b73a8 to 6572c41 Compare August 21, 2026 09:21

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 6572c41b7c56586c62f7a491e61f73ca6b3b9aab:

  • Exact-head CI run 32467538530 completed green (openclaw/ci-gate success; 0 pending).
  • Native review artifacts validate with READY FOR /prepare-pr, 0 findings. Fresh branch autoreview is clean (patch is correct, confidence 0.98).
  • Repository-native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 127117 passed at 2026-08-21T09:32:46Z in hosted_exact_or_recent_parent mode and verified the remote PR head exactly matches the prepared head.
  • Latest-head local proof is 219/219 tests across the startup regression, planner aliases/remote overlays/trusted transport, refresh, import boundary, model list, and broad startup coverage. Exact baseline red was 0/2; the 2,000-call empty-config benchmark improved from 2,042.56 ms to a 2.824 ms median while full unscoped catalog output remained identical.

ClawSweeper disposition: the completed patch-equivalent review reported no actionable findings. Its before-merge moves are satisfied: exact-head CI is now complete, the clean native prepare gate passed, and this maintainer-owned landing is using the required native workflow. Its optional rank-up move (complete exact-head CI) is also satisfied. A newer exact-head ClawSweeper run currently has only an in-progress placeholder and has published no additional findings; under the late-publisher policy that does not block the otherwise complete exact-head proof.

@steipete
steipete merged commit e17c858 into main Aug 21, 2026
227 checks passed
@steipete
steipete deleted the codex/perf-gateway-startup-model-planning branch August 21, 2026 09:34

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

2 participants