Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(codex): enable CodeModeOnly for gateway models (#2435)

klac511f5d31df
diff --git a/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts b/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts
index e9068b29ee..390a0e1cc0 100644
--- a/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/codexProxyHost.test.ts
@@ -310,6 +310,15 @@ describe('withCodexUpstreamRecording', () => {
});
describe('codex gateway config', () => {
+ it('所有认证模式都让缺少 model metadata 的 Codex 模型使用 CodeModeOnly', async () => {
+ const { buildCodexProxySpawnArgs } = await import('../codex-gateway-config.js');
+
+ for (const mode of ['oauth-bearer', 'env-key', 'provider-oauth'] as const) {
+ const args = buildCodexProxySpawnArgs('http://127.0.0.1:12345', mode);
+ expect(args).toContain('features.code_mode_only=true');
+ }
+ });
+
it('oauth-bearer 模式: requires_openai_auth, 不带 env_key', async () => {
const { buildCodexProxySpawnArgs } = await import('../codex-gateway-config.js');
diff --git a/apps/desktop/src/main/maker-host/codex-gateway-config.ts b/apps/desktop/src/main/maker-host/codex-gateway-config.ts
index 6c40c37130..bd20a589bf 100644
--- a/apps/desktop/src/main/maker-host/codex-gateway-config.ts
+++ b/apps/desktop/src/main/maker-host/codex-gateway-config.ts
@@ -80,6 +80,8 @@ export function buildCodexProxySpawnArgs(baseUrl: string, authMode: CodexProxySp
? `model_providers.${p}.requires_openai_auth=true`
: `model_providers.${p}.env_key="${CODEX_GATEWAY_ENV_KEY}"`;
const args = [
+ // 统一使用 CodeModeOnly,解决 Codex namespace tools 发现不及时的问题。
+ '-c', 'features.code_mode_only=true',
'-c', `model_provider="${p}"`,
'-c', `model_providers.${p}.name="Cindy Gateway"`,
'-c', `model_providers.${p}.base_url="${baseUrl}"`,