Repository navigation
fix(agents): use ChatGPT routes for isolated Codex completions - #168552
Conversation
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR lets isolated Codex completions plan authentication from all physical catalog routes instead of a single Platform route. Example: The catalog lists openai/gpt-test on Platform and ChatGPT, and only openai:allowed OAuth credentials are configured.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it fixes an isolated-completion routing defect still present on current main, and no actionable introduced bug was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherUtility and isolated requests enter the shared completion owner, which combines captured catalog routes with account policy and dispatches a scoped authorization plan to the selected harness. flowchart TD
A[Utility completion request] --> B[Prepared runtime admission]
B --> C[Captured physical catalog routes]
C --> D[Existing authentication planner]
D --> E[Scoped Codex authorization]
E --> F[App server login and inference]
F --> G[Completion text]
Technical reviewBest possible solution: Use captured physical routes through the existing authentication planner while retaining explicit account choices and final-effect authority checks. Do we have a high-confidence way to reproduce the issue? Yes: current-main source shows the single-route restriction, and the supplied baseline regression reports rejection through runIsolatedCompletion for both physical-route orders; no target code was executed during this review. Is this the best way to solve the issue? This addresses the routing owner directly using the established catalog view and auth planner, with no competing selector or persistent state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 65eb32679047. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +30, Tests +497, Docs +6. Total +533 across 8 files. Added test files: 4. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed October 10, 2026, 2:43 PM ET / 18:43 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 6fd3171. Isolated and utility Codex completions now plan sign-in from the admitted catalog route, the same one the picker uses, so ChatGPT-only accounts no longer fail with "No route-compatible authentication source is configured for openai". Proof: route-order regression red on main; the real Codex adapter against a recording app-server showed the allowed account reaching login and turn start, while a forbidden account and a revoked-during-preparation account sent zero messages. |
…th fixtures check-dependencies has been red on hourly main. Its three Knip scripts failed for separate reasons: - deadcode:full (production pass) reported canUseProfileAsProviderEntryApiKey. #168552 made src/plugin-sdk/plugin-test-runtime.ts, a production root, lazily load isolated-completion.adapter.test-support.ts. That fixture passes the model-auth and prepared-model-runtime namespaces to vi.spyOn. In Knip 6.32.2, any opaque import (here the lazy loaders in the media-understanding runner and config model validation) counts every export of a module as used, unless every namespace importer references only the bare namespace (is-referenced.js hasOnlyNsRefs). The spies flip that, so the facade's dead re-exports surfaced, and deadcode:exports reported nine "exports in used namespace" findings for test seams and the lazy-loaded isProviderAuthError. - deadcode:exports' script scan reported the default export of tools/solid-lint/index.mjs, which Oxlint loads by path through .oxlintrc.json jsPlugins (#168376). - deadcode:unused-files' full-tree scan reported six files that are only loaded by path: scripts/control-ui-parity/{vitest.config,capture-suite, fixtures,scenarios}.ts (`pnpm ui:parity`, #168597), src/proxy-capture/child-transport.process.test-support.ts (resolveRuntimeWorkerUrl in proxy-owner.test.ts, #168459) and test/e2e/qa-lab/runtime/codex-isolated-app-server.fixture.mjs (spawned by the Codex adapter test, #168552). Changes: - Make canUseProfileAsProviderEntryApiKey module-private and drop four other model-auth facade re-exports with no consumers anywhere (EnvApiKeyResult, ProviderEntryApiKeyBindingResolution, ProviderCredentialPrecedence, resolveAwsSdkEnvVarName). Their owners keep their real consumers. - Ignore only nsExports in the production scan for model-auth.ts, model-auth-runtime.ts, model-auth-runtime-shared.ts and prepared-model-runtime.ts. Each has a verified opaque lazy importer; plain unused exports stay reported, and the full-tree scan still audits every export against its test consumers. plugin-test-runtime stays a production root: un-rooting it surfaced 24 false positives, because extension tests import it through the openclaw/plugin-sdk alias. - Register the solid-lint default export as Oxlint-consumed, matching oxlint-boundary-guards.mjs. - Add full-tree entries for the six by-path files. No files are deleted. Proof: deadcode:full, deadcode:unused-files and deadcode:exports all exit 0 on the final tree; the model-auth focused tests pass.
…law#168552) ## What Problem This Solves Fixes: isolated and utility completions can require an OpenAI API key even when the selected model is available through the user's ChatGPT sign-in. Related: openclaw#168033. ## User Impact User impact: Codex utility completions can use the same subscription route as the model picker. Explicit auth profiles and utility-model overrides remain in force. A missing pinned profile fails instead of using another account. ## Why This Change Was Made The status path used the first logical catalog row. Dispatch used the resolved model's transport. Either row could describe the Platform API, while a separate physical row described the available ChatGPT route. Both paths now pass the catalog's physical routes to the existing auth planner through the same catalog view used by foreground runs. Dispatch reads the published catalog captured at admission. It keeps the existing model transport when no catalog route is available. No new route selector, config field, or stored state is added. The isolated-session contract in openclaw#159246 is unchanged; its changes in this file concern the documented isolation boundary, not auth route selection. ## Evidence - On baseline `b046f0c6532`, both route-order cases fail through `runIsolatedCompletion` with `No route-compatible authentication source is configured for openai.` - With this fix, both orders select the subscription route, display the Codex runtime, and dispatch to the isolated harness with the subscription profile. The harness returns text through the real completion entry point. A missing pinned profile does not dispatch. - The focused completion and plugin-scope suites pass: 56 tests. These include utility-model overrides, CLI profile selection, quota rotation, cancellation, and authority lifetime controls. - The final focused regression in `src/agents/isolated-completion-route.test.ts` passes both route orders. The agent-root TypeScript check and changed-source lint pass. The original route-order regression uses a synthetic catalog and mocked dispatch. The additional adapter-boundary regression below covers native login and inference serialization without contacting ChatGPT. ## Adapter boundary proof The permanent [plugin-owned adapter regression](https://github.com/openclaw/openclaw/blob/408cc759db6741b58063d348a765d0ff1a2c347f/extensions/codex/isolated-completion.adapter.e2e.test.ts) drives the real `runIsolatedCompletion` and auth planner through the existing test-only SDK barrel into the real Codex harness/client and a [stdio JSON-RPC executable](https://github.com/openclaw/openclaw/blob/408cc759db6741b58063d348a765d0ff1a2c347f/test/e2e/qa-lab/runtime/codex-isolated-app-server.fixture.mjs). The [core-only test fixture](https://github.com/openclaw/openclaw/blob/408cc759db6741b58063d348a765d0ff1a2c347f/src/agents/isolated-completion.adapter.test-support.ts) keeps bundled plugin implementation files out of core TypeScript graphs. - **Allowed:** ChatGPT route is second behind Platform. The scoped synthetic account reaches `account/login/start` exactly once, then `turn/start`; completion returns `Completed as synthetic-allowed-account`. [Redacted transcript](https://gist.github.com/obviyus/ba2dd960adfd458f96736bf39d459f12#file-allowed-json). - **Nearest forbidden:** a stored OAuth account explicitly pinned against config declaring that profile API-key-only is rejected by real eligibility policy; **zero RPC messages**. [Transcript](https://gist.github.com/obviyus/ba2dd960adfd458f96736bf39d459f12#file-forbidden-json). - **Revoked:** remove the allowed profile and revoke caller authority while the real model-materialization await is held; release it and observe rejection before any RPC, including login/inference. [Transcript](https://gist.github.com/obviyus/ba2dd960adfd458f96736bf39d459f12#file-revoked-json). All three moved cases pass (23.8 s test time; 78.8 s including cold transformation). Core-agent and extension-test TypeScript checks and targeted lint pass. `check-changed` passes extension/core-import and SDK boundary checks, then stops only at the known UI E2E root budget (722/720). Merged current `origin/main`, including its managed-cleanup lint fix. Synthetic principals and isolated state only; no live ChatGPT request, real credentials, user Gateway, or default login. Admission/catalog inputs and the deferred model resolver are fixture-controlled; auth planning, profile scoping, native serialization, process transport, and result handling are real. No production execution changes. No overlap with Pash/Sarah changes. Merge danger: two-way door. Reverting the patch fully restores the old behavior; it writes no state. The blast radius is auth planning for harness-owned isolated completions and their runtime labels when a model has multiple physical catalog routes. Co-authored-by: Ayaan Zaidi <[email protected]>
…th fixtures check-dependencies has been red on hourly main. Its three Knip scripts failed for separate reasons: - deadcode:full (production pass) reported canUseProfileAsProviderEntryApiKey. openclaw#168552 made src/plugin-sdk/plugin-test-runtime.ts, a production root, lazily load isolated-completion.adapter.test-support.ts. That fixture passes the model-auth and prepared-model-runtime namespaces to vi.spyOn. In Knip 6.32.2, any opaque import (here the lazy loaders in the media-understanding runner and config model validation) counts every export of a module as used, unless every namespace importer references only the bare namespace (is-referenced.js hasOnlyNsRefs). The spies flip that, so the facade's dead re-exports surfaced, and deadcode:exports reported nine "exports in used namespace" findings for test seams and the lazy-loaded isProviderAuthError. - deadcode:exports' script scan reported the default export of tools/solid-lint/index.mjs, which Oxlint loads by path through .oxlintrc.json jsPlugins (openclaw#168376). - deadcode:unused-files' full-tree scan reported six files that are only loaded by path: scripts/control-ui-parity/{vitest.config,capture-suite, fixtures,scenarios}.ts (`pnpm ui:parity`, openclaw#168597), src/proxy-capture/child-transport.process.test-support.ts (resolveRuntimeWorkerUrl in proxy-owner.test.ts, openclaw#168459) and test/e2e/qa-lab/runtime/codex-isolated-app-server.fixture.mjs (spawned by the Codex adapter test, openclaw#168552). Changes: - Make canUseProfileAsProviderEntryApiKey module-private and drop four other model-auth facade re-exports with no consumers anywhere (EnvApiKeyResult, ProviderEntryApiKeyBindingResolution, ProviderCredentialPrecedence, resolveAwsSdkEnvVarName). Their owners keep their real consumers. - Ignore only nsExports in the production scan for model-auth.ts, model-auth-runtime.ts, model-auth-runtime-shared.ts and prepared-model-runtime.ts. Each has a verified opaque lazy importer; plain unused exports stay reported, and the full-tree scan still audits every export against its test consumers. plugin-test-runtime stays a production root: un-rooting it surfaced 24 false positives, because extension tests import it through the openclaw/plugin-sdk alias. - Register the solid-lint default export as Oxlint-consumed, matching oxlint-boundary-guards.mjs. - Add full-tree entries for the six by-path files. No files are deleted. Proof: deadcode:full, deadcode:unused-files and deadcode:exports all exit 0 on the final tree; the model-auth focused tests pass.
|
Evidence: OpenClaw PR 168552: synthetic Codex adapter boundary proof Moved here from a one-off gist so the proof lives on this PR.
|
What Problem This Solves
Fixes: isolated and utility completions can require an OpenAI API key even when the selected model is available through the user's ChatGPT sign-in.
Related: #168033.
User Impact
User impact: Codex utility completions can use the same subscription route as the model picker. Explicit auth profiles and utility-model overrides remain in force. A missing pinned profile fails instead of using another account.
Why This Change Was Made
The status path used the first logical catalog row. Dispatch used the resolved model's transport. Either row could describe the Platform API, while a separate physical row described the available ChatGPT route.
Both paths now pass the catalog's physical routes to the existing auth planner through the same catalog view used by foreground runs. Dispatch reads the published catalog captured at admission. It keeps the existing model transport when no catalog route is available. No new route selector, config field, or stored state is added.
The isolated-session contract in #159246 is unchanged; its changes in this file concern the documented isolation boundary, not auth route selection.
Evidence
0a687e8e01d, both route-order cases fail throughrunIsolatedCompletionwithNo route-compatible authentication source is configured for openai.src/agents/isolated-completion-route.test.tspasses both route orders. The agent-root TypeScript check and changed-source lint pass.The original route-order regression uses a synthetic catalog and mocked dispatch. The additional adapter-boundary regression below covers native login and inference serialization without contacting ChatGPT.
Adapter boundary proof
The permanent plugin-owned adapter regression drives the real
runIsolatedCompletionand auth planner through the existing test-only SDK barrel into the real Codex harness/client and a stdio JSON-RPC executable. The core-only test fixture keeps bundled plugin implementation files out of core TypeScript graphs.account/login/startexactly once, thenturn/start; completion returnsCompleted as synthetic-allowed-account. Redacted transcript.All three moved cases pass (23.8 s test time; 78.8 s including cold transformation). Core-agent and extension-test TypeScript checks and targeted lint pass.
check-changedpasses extension/core-import and SDK boundary checks, then stops only at the known UI E2E root budget (722/720). Merged currentorigin/main, including its managed-cleanup lint fix. Synthetic principals and isolated state only; no live ChatGPT request, real credentials, user Gateway, or default login. Admission/catalog inputs and the deferred model resolver are fixture-controlled; auth planning, profile scoping, native serialization, process transport, and result handling are real. No production execution changes.Merge danger: two-way door. Reverting the patch fully restores the old behavior; it writes no state. The blast radius is auth planning for harness-owned isolated completions and their runtime labels when a model has multiple physical catalog routes.