Repository navigation
fix(gateway): prevent multi-agent startup stalls - #116261
fuller-stack-dev merged 1 commit into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 30, 2026, 3:21 AM ET / 07:21 UTC. ClawSweeper reviewWhat this changesThe PR changes gateway prepared-runtime startup to share immutable workspace discovery work across agents, preserve per-agent model and auth facts, and defer full model-catalog discovery until an explicit control-plane request. Merge readinessKeep this PR open for explicit maintainer handling. It is authored by a repository member and carries the protected Priority: P1 Review scores
Verification
How this fits togetherGateway startup publishes prepared model-runtime snapshots used by agent turns, onboarding, and model-aware services. Configuration, plugin metadata, workspace facts, and auth inputs enter this layer; it emits isolated per-agent snapshots and can later materialize a full catalog for listing, selection, and diagnostics. flowchart LR
A[Gateway configuration] --> B[Prepared runtime startup]
C[Plugin and workspace facts] --> B
D[Agent auth and configured models] --> B
B --> E[Isolated agent snapshots]
E --> F[Agent turns and onboarding]
E --> G[Lazy full catalog request]
G --> H[Model selection and diagnostics]
Decision needed
Why: The patch crosses gateway publication, agent auth, plugin catalog ownership, provider request metadata, and control-plane model discovery; deciding the permanent boundary is a maintainer responsibility rather than a mechanical repair. Before merge
Agent review detailsSecurityNone. PR surfaceSource +1948, Tests +1780, Other +161. Total +3889 across 56 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land only after a current-main owner review confirms that configured-model startup stays lightweight while explicit full-catalog consumers, plugin static catalogs, auth isolation, provider request policy, model selection, and diagnostics retain their established behavior. Do we have a high-confidence way to reproduce the issue? No: the PR provides benchmark and Testbox claims for the multi-agent shape, but this read-only review could not independently execute or inspect the current checkout after the local inspection sandbox failed. Is this the best way to solve the issue? Unclear: sharing workspace-scoped immutable facts and deferring non-critical catalog work is a plausible solution, but maintainers must confirm it is the best permanent provider/plugin lifecycle boundary rather than only a performance improvement. AGENTS.md: unclear because the file could not be read completely. Codex review notes: model internal, reasoning high; reviewed against 81d165c612c8. LabelsLabel justifications:
EvidenceWhat 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 (2 earlier review cycles)
|
321c0dd to
8974785
Compare
8974785 to
922f701
Compare
|
@clawsweeper re-review Current-head closeout for
This also satisfies the prior review’s optional rank-up moves: rebased to current main, prior required-lane failures resolved, and concise current-main lifecycle proof provided. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…n-dedupe * origin/main: (25 commits) fix(qqbot): use Gateway timezone for reminders (#116294) test(openai): cover out-of-order named mark acks docs(openai): clarify cumulative playback marks test(openai): cover sustained unnamed mark acknowledgements fix(openai): preserve playback acknowledgement order test(openai): verify bounded playback acknowledgements fix(openai): bound realtime playback marks test(agents): mock incremental registry persistence (#116307) fix(memory-core): MEMORY.md compaction deletes user notes written under a promotion-style heading (#116180) feat(reply): annotate recent history images (#100866) chore(ios): refresh native i18n inventory fix(ios): isolate capability router handlers docs(ios): cut 2026.7.22 release notes docs(hooks): document validation responses test(qa): assert hook account rejection reasons fix(gateway): validate hook delivery accounts perf(gateway): bound prepared runtime startup work (#116261) fix(agents): prevent registry stalls during large fan-outs (#116286) fix(sqlite): preserve replaced snapshot targets on Windows (#116284) fix(ci): load frozen shard runner without repository fetch (#116273) ...
…n-dedupe * origin/main: (25 commits) fix(qqbot): use Gateway timezone for reminders (openclaw#116294) test(openai): cover out-of-order named mark acks docs(openai): clarify cumulative playback marks test(openai): cover sustained unnamed mark acknowledgements fix(openai): preserve playback acknowledgement order test(openai): verify bounded playback acknowledgements fix(openai): bound realtime playback marks test(agents): mock incremental registry persistence (openclaw#116307) fix(memory-core): MEMORY.md compaction deletes user notes written under a promotion-style heading (openclaw#116180) feat(reply): annotate recent history images (openclaw#100866) chore(ios): refresh native i18n inventory fix(ios): isolate capability router handlers docs(ios): cut 2026.7.22 release notes docs(hooks): document validation responses test(qa): assert hook account rejection reasons fix(gateway): validate hook delivery accounts perf(gateway): bound prepared runtime startup work (openclaw#116261) fix(agents): prevent registry stalls during large fan-outs (openclaw#116286) fix(sqlite): preserve replaced snapshot targets on Windows (openclaw#116284) fix(ci): load frozen shard runner without repository fetch (openclaw#116273) ...
Upstream openclaw#116261 bounded prepared-runtime startup work, deferring model catalog preparation to first use — measured cost on an agent's first message: ~16s inside loadResolvedPublishedModelCatalogOwner (live provider discovery with 5s/provider timeouts plus a manifest-model scan) before the reply pipeline's first traced phase, with no typing indicator. Warm each agent's catalog owner from the post-ready prewarm scheduler, after the runtime plugin registries it depends on: boot stays bounded (off the startup critical path) and first messages hit a warm catalog.
Related: #116039
What Problem This Solves
Fixes an issue where users with several configured agents could wait minutes for a fresh gateway or onboarding TUI to become ready because gateway startup eagerly rebuilt broad model-discovery state once per agent.
On the affected 12-agent shape (11 agents sharing one workspace and one agent using another workspace), the old path consumed one CPU core, reached roughly 1.2-1.5 GiB RSS, delayed the event loop during local discovery work, and could exceed the prepared-runtime publication deadline.
Why This Change Was Made
Gateway admission now prepares only turn-critical configured-model facts. Process/config facts are captured once per generation, workspace/plugin facts are built once per distinct workspace, and the resulting immutable facts are projected into isolated per-agent runtime snapshots.
The full model catalog is no longer built during static gateway startup. Explicit catalog consumers load it lazily through a generation-bound single-flight path with concurrency 1, while live/full runtime refresh remains bounded. Publication stays atomic, stale generations cannot publish, auth/config/plugin invalidation remains owner-scoped, and a failed or timed-out build cannot overlap its successor.
This deliberately does not include Wilfred's temporary 300-second publication-deadline mitigation.
User Impact
Fresh onboarding and gateway startup no longer scale pathologically with configured agent count. Agents that share a workspace reuse immutable preparation facts without sharing agent auth or configured-model state, and lower-resource hosts avoid the previous CPU, filesystem, memory, and GC fanout.
The complete model catalog remains available for explicit control-plane operations such as model listing, selection, and diagnostics; it is simply not correctness-critical for admitting the gateway or starting an agent turn.
Evidence
Representative startup benchmark:
For the 12-agent fixture, prepared-runtime time fell by about 97.3%, end-to-end completion by 79.8%, CPU by 68.8%, and peak RSS by 42.8%. Deterministic discovery counts changed from repeated agent-scale work (
static calls=9,plugin loader calls=70in the baseline run) to workspace-scale work (static calls=2,plugin loader calls=2) for the two-workspace fixture.Focused regression proof covers:
Validation:
pnpm tsgo:core,pnpm tsgo:core:test,pnpm tsgo:scripts, andpnpm tsgo:test:rootpassedgit diff --checkpassedDesign Notes
Alternatives considered and rejected:
#116039 reduced repeated resolver creation inside static catalog preparation, but did not remove the per-agent owner duplication addressed here. Searches for open PRs/issues covering prepared-runtime workspace grouping and lazy full-catalog publication found no duplicate implementation.
Remaining uncertainty: general plugin bootstrap still dominates part of end-to-end startup in the many-agent benchmark and is outside this prepared-runtime owner-boundary fix. Wall-clock values vary by host; the workspace-scaled call-count and concurrency assertions are deterministic regression guards.
AI-assisted implementation and review; no agent transcript is included.