Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
Fix Codex subagent HTTP fallback routing (#3411)
Dash94c9a166a0e0
diff --git a/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts b/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.tsindex 5547ed9d5d..76e8f9e4e1 100644--- a/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts@@ -2532,6 +2532,7 @@ describe('codex proxy host', () => {});await host.ensureCodexProxyReady();host.setCodexProxyAuthInjection('oauth-bearer');+ host.setCodexProxyGatewayKeyReader(() => 'gateway-subagent-key');host.registerComposed('session-ws-parent','thread-ws-parent',@@ -2580,6 +2581,20 @@ describe('codex proxy host', () => {'session-ws-child-2','thread-ws-parent',))).toBeNull();+ // Codex's HTTP fallback may only carry the child thread id. The WS+ // handshake must have bound the child route before returning 426, or this+ // request falls through as a normal ChatGPT OAuth request.+ await expect(Promise.resolve(host.createModelRoutingTransform()(+ { model: 'gpt-5.6-sol', input: [] },+ {+ reqId: 1,+ method: 'POST',+ url: '/responses',+ headers: { 'thread-id': 'thread-ws-child-2' },+ },+ ))).resolves.toEqual({+ headerOverride: { authorization: 'Bearer gateway-subagent-key' },+ });// 未配置独立 route 的 collab child 不应被全局降级。expect(proxyOpts.resolveWebSocketUpstream(ctxForCodex145ChildPrewarm('thread-openai-child',@@ -2590,6 +2605,7 @@ describe('codex proxy host', () => {);} finally {host.unregister('session-ws-parent');+ host.setCodexProxyGatewayKeyReader(() => null);host.clearCodexProxyAuthInjection();}});diff --git a/apps/desktop/src/main/maker-host/codex-proxy-host.ts b/apps/desktop/src/main/maker-host/codex-proxy-host.tsindex f8a0a5c876..a169678d38 100644--- a/apps/desktop/src/main/maker-host/codex-proxy-host.ts+++ b/apps/desktop/src/main/maker-host/codex-proxy-host.ts@@ -322,8 +322,9 @@ function subagentRouteFromHeaders(* Resolve only the independent Subagent route carried by this WS upgrade.** A registered child already owns a frozen route snapshot. Its first- * collab_spawn upgrade can race thread/started, so fall back to the explicit- * parent header without mutating thread ownership from the handshake path.+ * collab_spawn upgrade can race thread/started; when the handshake already+ * carries a real child thread id, bind it before returning 426 so Codex's HTTP+ * fallback can still resolve the frozen route if it omits parent metadata.*/function subagentRouteForWebSocketUpgrade(headers: Readonly<Record<string, string>>,@@ -334,8 +335,16 @@ function subagentRouteForWebSocketUpgrade(const parentThreadId = headerValue(headers, 'x-codex-parent-thread-id');if (!parentThreadId) return undefined;- return subagentRouteByThread.get(parentThreadId)+ const inheritedRoute = subagentRouteByThread.get(parentThreadId)?? subagentRouteByParentThread.get(parentThreadId);+ if (!inheritedRoute) return undefined;++ const childThreadId = headerValue(headers, 'thread-id');+ if (childThreadId) {+ registerChildThread(parentThreadId, childThreadId);+ return subagentRouteByThread.get(childThreadId) ?? inheritedRoute;+ }+ return inheritedRoute;}interface ProviderRequestContext {