Skip to content

fix(gateway): reduce cold model-runtime request stalls - #139911

Merged
steipete merged 3 commits into
mainfrom
fix/prepared-runtime-registration-main
Sep 6, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/prepared-runtime-registration-main

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #139867 — cold prepared-runtime registration stalls Gateway requests for minutes.

What Problem This Solves

Reduces the multi-minute Gateway request stalls caused by cold background model-runtime registration. Selected-plugin registration occupied roughly 291 seconds of the event loop in the isolated source reproduction, even after the separate Talk catalog discovery repair landed. An ordinary cold capability factory also pulled in the broad runtime module and exceeded five minutes.

This is synchronous registration/module-evaluation work, not model inference or external API latency.

Why This Change Was Made

The host composes provider hooks, external-auth resolution, auth-store operations, model auth/config, and capability-catalog context at the native loader boundary. Native bindings remain separate from authored load options, preserving registry/cache identity and explicit override identity. Registration consumes prepared operations and lightweight descriptors; execution-only preparation, session mutation, transports, and diagnostics remain with their execution owners.

Codex, OpenAI, and sibling SDK consumers migrate together. Full registration still owns harnesses, hooks, services, and lifecycle; catalog-only records cannot establish runtime readiness. Synchronous auth hooks, exact logger/process semantics, mutable method views, getter-only policy facets, and existing persistence semantics remain intact. An invocation-bound latest-lineage reader protects physical-session ownership across awaited metadata work without caching predecessor state.

The cleanup removes obsolete provider wrappers, the unused eager conversation starter, duplicate forwarding paths, redundant type exports, and test scaffolding tied to retired internals. Main integrations retain strict catalog credential selection, OAuth-preparation failure handling, scoped lookup, registrar binding, shared embedding orchestration, and cleanup ownership. No configuration option, schema, dependency, version, SDK budget, timeout relaxation, source-loader trick, or dependency patch is introduced.

User Impact

Cold source registration no longer traverses the original multi-minute execution graph. Historical same-environment Linux x86-64 proof reduced prepared refresh from 291.246 seconds to 17.198 seconds. This does not eliminate every cold source stall. The latest ARM64 profile measured 15.225 seconds in selected registration, and the independent recorder observed about 19.052 seconds from request to response. These are not matched cross-platform benchmarks.

The compiled, separate-process Gateway/browser catalog flow completed in 557.7 ms, returning two providers in each speech/transcription/realtime family. Real Gateway execution and missing-profile recovery were also exercised against a synthetic app-server. No live OpenAI inference is claimed.

The new private host seams require coordinated host/plugin release. External consumers must not publish independently with an older host compatibility floor; release preparation owns version/floor stamping. This PR does not publish or bump versions.

Evidence

Reproduction and native boundary

  • Failing baseline: 52644b7af6fb5a43d76329c2c152b8e44fd32e6f, already containing the Talk catalog discovery repair. Run run_84dbe23e7254 failed the unchanged 120-second test: browser response 304,688 ms; prepared refresh 291.245915 s; selected registry 291.236367 s; Codex entry evaluation 288.072603 s; Talk handler 0.004214 s.
  • Historical repaired run run_5d04c7ea19e6: prepared refresh 17.198443 s; browser response 20,887.894 ms. Historical evidence, not a final-head rerun.
  • Ten native-loader cases failed before native composition. The 23-case factory suite passes with ordinary/restricted CJS and TypeScript registration, synchronous external auth, cache/in-flight identity, mutable views, getter-only facets, and factory rollback.
  • Latest-lineage paired proof failed before repair (Gateway 2 failed/2 passed; model setup 2 failed/11 passed), then passed all 17 cases: lineage mutation during an await, physical-session replacement, binding-hit avoidance, and retained-reader rejection.

Protected source and compiled proof

The full protected run used commit 2d1b868b2a0820a4649d42b3fdad1d81e50218e4, tree bb3bcaf022f80bd4ca5aefbce6d55bf111125e56, frozen patch SHA-256 624e736290f9f567cfb6d7369d1ae968b98052eb0ae8c5693310261f297f06fc. Cold diagnostic, unchanged stock browser scenario, normal build, compiled browser, and three synthetic auth/package E2Es all passed. The fresh secretless container had no host mounts, operator stores, credentials, or hydration; it was collected and removed. Later integrations are separately validated below.

The profile belongs to the actual Gateway/test worker (PID 2597): 18,792 samples over 43.627689 seconds; SHA-256 85d3e73b2c0c06ba35e10734d1b9995dc97ce5dd162a2183c1989165e20bd857. The tree, profile digest, and all eight attribution-source hashes were checked.

Weighted inclusive owner Time
Prepared refresh 15.246147 s
Selected registry 15.225114 s
Codex entry 12.768966 s
OpenAI entry 2.390973 s
Inbound registry 0.002117 s

These overlapping costs must not be summed. Source response time was 19,051.684 ms by CDP; its result was the fixture's intentional INVALID_REQUEST / AgentSelectionRequiredError, not successful catalog retrieval. The stock agent-qualified progress-card test passed independently. Compiled catalog retrieval succeeded in 557.717 ms.

The attached 21.04-second independent recording completed successfully, with 1,154 frames and matching encoded-duration checks. Maximum frame-arrival gap was 260 ms; worker-tick arrival gap was 16.435 seconds. Eleven PNGs (nine unique) and full-span source/compiled video contact sheets at 2/5 fps were inspected. These are sampled-frame inspections, not every encoded frame. Captures are synthetic-only; raw profiles, logs, and runtime-state archives are not attached. Earlier backward-frame-clock failures remain invalid; no clock clamp, frame drop, assertion relaxation, or browser patch was used.

Current source and validation

Current head: 5253aaba5a6d0a5523c38988368d3f8ff24bfdf5. Production/package source is identical to integrated head 820c56b7a3ec4c490baae9e5b6be56c15a3453af on 85d5022fad7f3c422865e702856acba7d1ee50dc; the latest commit changes only the cold-memory startup fixture. The integrated source freeze is SHA-256 43f22be9988fdf95fa26d1d56bac5b1f60ee308113861a7fe730b30cdd8c5229.

  • Connected CI repairs passed a fresh secretless replay: 386 cold plugin-contract cases across the original 24-file group, 71 descendant-lifecycle cases, the native Gateway catalog case, and 41 Gateway CLI cases. The original CLI selection passed 6,841 cases with 85 existing skips (271 passed files, two skipped). The complete changed gate passed selected typechecks, lint, SDK, cycle, dead-code, and storage guards. These precede the latest integration and are not mislabeled final-head CI.
  • The latest integration passed 300 focused cases with one skip, core/plugin typechecks, and canonical SDK metadata checks. The CI repair commit replayed unchanged by git range-diff.
  • The integrated build passed in 9m04.6s with no INEFFECTIVE_DYNAMIC_IMPORT; all 425 source paths were rechecked afterward. Fresh isolated Codex review completed three bounded full passes with no accepted/actionable P0 findings—not a lower-priority correctness certificate.
  • The final test-only correction supplies real native model-auth operations when the memory-startup fixture registers OpenAI. Both stored/missing SecretRef cases and all semantic-data, migration, warning, activation, and degraded-owner assertions remain unchanged. Both cases and the original 259-case/21-file CI group pass in a fresh secretless container; typed lint, source checks, and isolated review pass. Its frozen delta is SHA-256 aed8aaebfb3ce14c2e9936532ff3074f382a49743e28f571153b412b700aa3f7.
  • Earlier evidence includes 1,101 and 293 integration cases, 112 auth/provider cases after type-owner cleanup, and 5,898 lifecycle cases with ten skips. These separate, partly overlapping runs are not summed into a final-head full-suite claim.

Final-head CI and matching-package proof are green. CI run 34037295464 passed on 5253aaba5a6d0a5523c38988368d3f8ff24bfdf5. The preceding exact-head run failed only the now-corrected memory-startup test job plus its aggregate gate. Current PR checks must be green on the head above. Prior Android timing failures are tracked in the native payload-decoding cleanup; Android jobs passed in the preceding run, and this PR does not claim to repair that race. An earlier GitHub-429 Dependency Guard attempt passed on its targeted second attempt.

Matching-package proof — passed

The completed fresh secretless replay passed all 44 commands: normal build (4m18.3s), matching host pack/install, four package-local plugin packs and managed installs, runtime inspection/Doctor, and embedding/TTS enumeration. All 9,789 host-owned packed regular files outside dependency trees matched their installed bytes, including loader/core/SDK payloads; the lifecycle marker was consumed and the legacy install guard absent. Final source/tool identities and container removal were verified.

ACPX, Codex, Bedrock, and Voyage passed exact installed-root/compiled-entry checks, copied archive digests, matching host-peer links, install provenance, imported/loaded state, capability IDs, and Doctor checks. OpenAI, xAI, Google, MiniMax, ElevenLabs, and Deepgram also passed matching-host bundled factory inspection. Enumeration availability is not credential readiness; no provider credentials or inference were used.

The managed installs used the documented --force --accept-capabilities path only inside the isolated test installation. No official-registry provenance was fabricated or inferred, no safety gate was bypassed, and no package/version/floor was published or changed. The first failed attempt is retained: its controller omitted the separate consent step and two manifest-declared xAI voice aliases. The corrected replay kept exact alias equality and every root/byte/trust assertion.

This tests the production cohort at 820c56b; final 5253aaba differs only in a non-packaged test fixture. It proves installation and native registration/configuration, not every deferred operational hook or official-registry publication. Normal release preparation still owns coordinated compatibility-floor stamping.

Packed artifact SHA-256
Matching OpenClaw host 186382547256650052e4f7c9a52eb9395084b8a7c773f737b72edbb6c7995d56
acpx d79dec1c89e075c32cf8656a4ce0c1b8a2d59b1cdf06802726cee6ce476e55dd
codex aeed8b8dc82c402f05830801e001c49246e01defbb5f1e79aea0689ddb522264
amazon-bedrock 25c97b262572d79412f2d2fed37e43f01b01019819b7c34569a237ec2d80c6da
voyage da8987e536e69d7a98eb290b3a76b1c91196e0ee1ecd4539abff12985b30275e

Scope and contracts

Production: +7,748/−6,956 (net +792). Tests/support: +3,434/−1,548 (net +1,886). Total: 425 changed paths. Gross counts include owner-preserving moves. Growth buys native composition, descriptor boundaries, and invocation-bound lineage—not new product configuration or storage semantics.

No stored representation is introduced by the flagged reviewer/embedding files: reviewer policy is a read-only TOML/effective-config extraction; Bedrock retains the same provider/region/model/dimensions/endpoint cache-key fields. The existing config-read contract was directly checked in Codex config_manager_service.rs:115–174 and protocol/v2/config.rs:382–403.

Pinned Codex rust-v0.153.4 (3d2ee51ca2d5db578f328aa75e20aa22c0197c9a) was also personally inspected for unsubscribe/removal, resume/fork fences, turn completion, CLI resume/stdin/output, and model/usage contracts. Exact synchronous process execution and the embedded logger were retained rather than substituted to reduce imports.

Inspected stock-browser screenshots:

Successful isolated source-browser test showing the synthetic native catalog row

Successful isolated source-browser test showing the agent-qualified progress card

Successful independent source recording (synthetic fixture; intentional response outcome and timing explained above):

attachment-2409203477.webm

@clawsweeper

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

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 6, 2026
This was referenced Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes commands Command implementations docs Improvements or additions to documentation extensions: acpx extensions: alibaba extensions: amazon-bedrock extensions: codex extensions: deepgram extensions: elevenlabs extensions: fal extensions: google extensions: litellm extensions: lmstudio extensions: minimax extensions: ollama extensions: openai extensions: runway extensions: voyage extensions: xai gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. plugin: file-transfer proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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.

[Bug]: Cold prepared-runtime registration stalls Gateway requests for minutes

1 participant