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): openai-codex 前缀补齐图像守卫与 gpt-5.4 剥离

kl90ed40bee2a7
diff --git a/apps/desktop/src/main/maker-host/__tests__/xdToolResultImageNotice.test.ts b/apps/desktop/src/main/maker-host/__tests__/xdToolResultImageNotice.test.ts
index 90c7633b07..ca7cc4d180 100644
--- a/apps/desktop/src/main/maker-host/__tests__/xdToolResultImageNotice.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/xdToolResultImageNotice.test.ts
@@ -42,7 +42,13 @@ describe('XD tool-result image notice', () => {
() => 'https://gateway.example.com/anthropic/',
);
- it.each(['codex/gpt-5.6-sol', 'gpt-5.6-sol', 'gpt-5.6-sol[1m]'])(
+ it.each([
+ 'codex/gpt-5.6-sol',
+ 'openai-codex/gpt-5.6-sol',
+ 'openai-codex/gpt-5.6-sol[1m]',
+ 'gpt-5.6-sol',
+ 'gpt-5.6-sol[1m]',
+ ])(
'replaces XD-routed %s tool-result images without exposing image bytes',
(model) => {
const output = transform(
diff --git a/apps/desktop/src/main/maker-host/xd-tool-result-image-notice.ts b/apps/desktop/src/main/maker-host/xd-tool-result-image-notice.ts
index 026e1d85ae..790468d0ad 100644
--- a/apps/desktop/src/main/maker-host/xd-tool-result-image-notice.ts
+++ b/apps/desktop/src/main/maker-host/xd-tool-result-image-notice.ts
@@ -2,8 +2,9 @@ import {
replaceToolResultImagesWithNotice,
type RequestTransform,
} from '@cindy/anthropic-compat-proxy';
+import { stripCodexGatewayWirePrefix } from '@cindy/model-providers';
-const XD_TOOL_RESULT_IMAGE_MODELS = new Set(['codex/gpt-5.6-sol', 'gpt-5.6-sol']);
+const XD_TOOL_RESULT_IMAGE_MODEL = 'gpt-5.6-sol';
const XD_TOOL_RESULT_IMAGE_NOTICE =
'[image omitted: this tool returned an image, but the current route cannot deliver ' +
'images inside tool results. Do NOT guess or fabricate what the image contains. ' +
@@ -35,7 +36,7 @@ export function createXdToolResultImageNoticeTransform(
return (body, ctx) => {
if (!isPlainObject(body) || typeof body.model !== 'string') return null;
const model = body.model.endsWith('[1m]') ? body.model.slice(0, -4) : body.model;
- if (!XD_TOOL_RESULT_IMAGE_MODELS.has(model)) return null;
+ if (stripCodexGatewayWirePrefix(model) !== XD_TOOL_RESULT_IMAGE_MODEL) return null;
const actualUpstream = ctx.upstreamBase ? normalizeUpstreamBase(ctx.upstreamBase) : null;
const xdUpstream = normalizeUpstreamBase(readXdUpstream());
if (!actualUpstream || actualUpstream !== xdUpstream) return null;
diff --git a/packages/anthropic-compat-proxy/src/transform.test.ts b/packages/anthropic-compat-proxy/src/transform.test.ts
index 655ada73d8..ebd81d0051 100644
--- a/packages/anthropic-compat-proxy/src/transform.test.ts
+++ b/packages/anthropic-compat-proxy/src/transform.test.ts
@@ -1234,6 +1234,30 @@ describe('recovery rule factories', () => {
});
});
+describe('stripNonAnthropicFields · gpt-5.4 output_config', () => {
+ it.each(['gpt-5.4', 'codex/gpt-5.4', 'openai-codex/gpt-5.4'])(
+ '%s 去掉 Azure 不接受的 output_config',
+ (model) => {
+ const out = stripNonAnthropicFields(
+ { model, output_config: { effort: 'high' }, messages: [] },
+ ctx,
+ ) as Record<string, unknown> | null;
+ expect(out).not.toBeNull();
+ expect(out).not.toHaveProperty('output_config');
+ expect(out?.model).toBe(model);
+ },
+ );
+
+ it('openai-codex/gpt-5.5 不剥 output_config,与 gpt-5.5 一致', () => {
+ expect(
+ stripNonAnthropicFields(
+ { model: 'openai-codex/gpt-5.5', output_config: { effort: 'high' } },
+ ctx,
+ ),
+ ).toBeNull();
+ });
+});
+
describe('stripNonAnthropicFields · glm-5.2 tool_result 图像降级 (#794)', () => {
const imageBlock = {
type: 'image',
diff --git a/packages/model-compat/src/cindy/proxy/transform.ts b/packages/model-compat/src/cindy/proxy/transform.ts
index a00cf00318..f198563b0f 100644
--- a/packages/model-compat/src/cindy/proxy/transform.ts
+++ b/packages/model-compat/src/cindy/proxy/transform.ts
@@ -1498,8 +1498,10 @@ const STRIP_HANDLERS: Readonly<Record<string, ModelStripHandler>> = {
'gpt-5.4': stripGpt54,
'gpt-5.4-mini': stripGpt54Mini,
// 「折扣GPT」低价路由 —— 与 gpt-5.4 打同一个 Azure 后端, 同样会因 output_config 报 400,
- // 镜像 gpt-5.4 的 strip 行为 (复用同一 handler)。codex/gpt-5.5 暂不加, 与 gpt-5.5 一致。
+ // 镜像 gpt-5.4 的 strip 行为 (复用同一 handler)。openai-codex/ 与 codex/ 是同一条
+ // wire,查表是精确 id,所以两条都要登记。codex/gpt-5.5 暂不加, 与 gpt-5.5 一致。
'codex/gpt-5.4': stripGpt54,
+ 'openai-codex/gpt-5.4': stripGpt54,
// 纯文本模型 tool_result 图像会被上游静默吞掉 (#794) —— 带/不带命名空间前缀,
// 以及 claude-code SDK 按目录 1M 窗口追加 [1m] 后缀 (toSdkModelString) 的形态
// 都登记 (直通路由 body.model 可能保留 z-ai/ 前缀与 [1m] 后缀)。