Repository navigation
fix(gateway): reduce cold model-runtime request stalls - #139911
Merged
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
This was referenced Nov 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
52644b7af6fb5a43d76329c2c152b8e44fd32e6f, already containing the Talk catalog discovery repair. Runrun_84dbe23e7254failed 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.run_5d04c7ea19e6: prepared refresh 17.198443 s; browser response 20,887.894 ms. Historical evidence, not a final-head rerun.Protected source and compiled proof
The full protected run used commit
2d1b868b2a0820a4649d42b3fdad1d81e50218e4, treebb3bcaf022f80bd4ca5aefbce6d55bf111125e56, frozen patch SHA-256624e736290f9f567cfb6d7369d1ae968b98052eb0ae8c5693310261f297f06fc. 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.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 head820c56b7a3ec4c490baae9e5b6be56c15a3453afon85d5022fad7f3c422865e702856acba7d1ee50dc; the latest commit changes only the cold-memory startup fixture. The integrated source freeze is SHA-25643f22be9988fdf95fa26d1d56bac5b1f60ee308113861a7fe730b30cdd8c5229.git range-diff.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.aed8aaebfb3ce14c2e9936532ff3074f382a49743e28f571153b412b700aa3f7.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-capabilitiespath 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; final5253aabadiffers 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.186382547256650052e4f7c9a52eb9395084b8a7c773f737b72edbb6c7995d56d79dec1c89e075c32cf8656a4ce0c1b8a2d59b1cdf06802726cee6ce476e55ddaeed8b8dc82c402f05830801e001c49246e01defbb5f1e79aea0689ddb52226425c97b262572d79412f2d2fed37e43f01b01019819b7c34569a237ec2d80c6dada8987e536e69d7a98eb290b3a76b1c91196e0ee1ecd4539abff12985b30275eScope 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–174andprotocol/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 independent source recording (synthetic fixture; intentional response outcome and timing explained above):
attachment-2409203477.webm