Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(pi): default unknown image capabilities to supported (#4854)
Dash721bc12c6ece
diff --git a/apps/desktop/src/main/maker-host/__tests__/piNativeProviders.test.ts b/apps/desktop/src/main/maker-host/__tests__/piNativeProviders.test.tsindex 44e38b9382..b432f12c35 100644--- a/apps/desktop/src/main/maker-host/__tests__/piNativeProviders.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/piNativeProviders.test.ts@@ -144,6 +144,17 @@ afterEach(() => {});describe('ChatGPT image capability authority (#2674)', () => {+ it.each([true, false, undefined])('defaults new subscription models to images while preserving %s', (supportsImageInput) => {+ const catalog = structuredClone(BUNDLED_CATALOG);+ catalog.providers.find((provider) => provider.id === 'openai')!.models.pi = [{+ id: 'chatgpt/new-model-without-metadata', name: 'New model', contextWindow: 128_000,+ efforts: [], defaultEffort: null, supportsImageInput,+ }];+ const model = buildPiSubscriptionNativeProviders(catalog, 'http://127.0.0.1:4567/', new Map())+ .providers.find((provider) => provider.id === 'openai-codex')?.models[0];+ expect(model?.input).toEqual(supportsImageInput === false ? ['text'] : ['text', 'image']);+ });+it.each(['gpt-5.6-luna', 'gpt-5.6-sol', 'gpt-5.6-terra'])('keeps %s visual through the independent Pi catalog despite text-only Codex discovery',(id) => {diff --git a/apps/desktop/src/main/maker-host/pi-host.ts b/apps/desktop/src/main/maker-host/pi-host.tsindex d6db358d2f..033e9ed51e 100644--- a/apps/desktop/src/main/maker-host/pi-host.ts+++ b/apps/desktop/src/main/maker-host/pi-host.ts@@ -279,7 +279,7 @@ function parsePiBundledModel(value: unknown): PiBundledModelInfo | null {name: typeof value.name === 'string' ? value.name : value.id,reasoning: value.reasoning === true,...(thinkingLevelMap && Object.keys(thinkingLevelMap).length > 0 ? { thinkingLevelMap } : {}),- input: input.length > 0 ? input : ['text'],+ input: Array.isArray(value.input) ? input : ['text', 'image'],contextWindow:typeof value.contextWindow === 'number' && value.contextWindow > 0? value.contextWindow@@ -692,7 +692,7 @@ export function buildPiSubscriptionNativeProviders(? { maxTokens: model.maxOutput ?? template?.maxTokens } : {}),reasoning: model.efforts.length > 0,input: model.supportsImageInput === undefined- ? [...(template?.input ?? ['text'])]+ ? [...(template?.input ?? ['text', 'image'])]: model.supportsImageInput ? ['text', 'image'] : ['text'],thinkingLevelMap: catalogThinkingLevelMap(model.efforts, thinking),...(cost ? { cost: { ...cost } } : {}),diff --git a/docs/dev-rules/pi-harness.md b/docs/dev-rules/pi-harness.mdindex 787437940e..498b50c075 100644--- a/docs/dev-rules/pi-harness.md+++ b/docs/dev-rules/pi-harness.md@@ -70,6 +70,11 @@ Cindy 以 `pi --mode rpc` spawn pi 二进制(JSONL/stdio),`translator.ts` 把 pi## 2. 配置面:Cindy 显式设置 vs 放任 pi 默认+图片能力未声明时,Pi 的模型配置与发送校验默认允许图片输入,不因新型号缺少能力资料而+提前拦截。目录、原生模型资料或用户配置明确声明 `supportsImageInput: false` / `input: ['text']`+时仍保持仅文本;此默认值不写回用户配置,也不代表上游接口保证支持图片。活动任务沿用启动时+能力快照。回归见 `pi-provider-routing.test.ts` 与 `piNativeProviders.test.ts`。+Cindy 显式设置:models.json、`settings.json` 的 `transport:sse` 与 `retry.maxRetries=6`(`retry.provider.maxRetries` 保持 0)、`--append-system-prompt`、`--session-dir`、启动时 RPC`set_auto_compaction{enabled:true}` / `set_thinking_level`。Pi 原生负责 threshold 与 overflow 压缩;diff --git a/packages/maker-core/src/agents/pi/__tests__/pi-provider-routing.test.ts b/packages/maker-core/src/agents/pi/__tests__/pi-provider-routing.test.tsindex 8a3adb245e..871af071c9 100644--- a/packages/maker-core/src/agents/pi/__tests__/pi-provider-routing.test.ts+++ b/packages/maker-core/src/agents/pi/__tests__/pi-provider-routing.test.ts@@ -3974,13 +3974,13 @@ describe("Pi provider-aware model routing", () => {it.each([{ input: ["text", "image"] as Array<"text" | "image">, supported: true },{ input: ["text"] as Array<"text" | "image">, supported: false },- { input: undefined, supported: false },- ])("uses the native ChatGPT image snapshot for models.json, send and steer: $input", async ({ input, supported }) => {+ { input: undefined, supported: true },+ ].flatMap((row) => [true, false].map((inheritModels) => ({ ...row, inheritModels }))))("uses the native image snapshot for models.json, send and steer: $input, inherit=$inheritModels", async ({ input, supported, inheritModels }) => {const modelId = "chatgpt/gpt-5.6-sol";const agent = new PiAgent(byomDeps(async () => ({providers: [{id: "openai-codex", sourceProviderId: "openai", name: "ChatGPT",- baseUrl: "http://127.0.0.1:9", inheritModels: true,+ baseUrl: "http://127.0.0.1:9", api: "openai-codex-responses", inheritModels,models: [{id: modelId, wireId: "gpt-5.6-sol", api: "openai-codex-responses", input,}],@@ -3999,7 +3999,7 @@ describe("Pi provider-aware model routing", () => {));expect(config.providers["openai-codex"].models).toEqual([expect.objectContaining({- id: "gpt-5.6-sol", api: "openai-codex-responses", input: input ?? ["text"],+ id: "gpt-5.6-sol", api: "openai-codex-responses", input: input ?? ["text", "image"],}),]);const data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=";@@ -4154,7 +4154,7 @@ describe("Pi provider-aware model routing", () => {id: "gateway-vision",input: ["text", "image"],}),- expect.objectContaining({ id: "gateway-unknown", input: ["text"] }),+ expect.objectContaining({ id: "gateway-unknown", input: ["text", "image"] }),]),);@@ -4227,11 +4227,17 @@ describe("Pi provider-aware model routing", () => {),).toBe(false);- // 能力未知同样 fail closed;活动会话只认启动时写入 models.json 的能力快照。+ // 未声明能力默认放行图片;活动会话仍只认启动时写入 models.json 的能力快照。await handle.setModel!("gateway-unknown", { providerId: null });- await expect(handle.send(imageMessage)).rejects.toMatchObject({- code: "PI_IMAGE_INPUT_UNSUPPORTED",- });+ captured.requests.length = 0;+ await handle.send(imageMessage);+ await handle.steer!(imageMessage);+ for (const type of ["prompt", "steer"]) {+ expect(captured.requests).toContainEqual(expect.objectContaining({+ type,+ images: [expect.objectContaining({ type: "image", mimeType: "image/png" })],+ }));+ }gatewayModels[0]!.supportsImageInput = true;await handle.setModel!("gateway-text", { providerId: null });await expect(handle.send(imageMessage)).rejects.toMatchObject({diff --git a/packages/maker-core/src/agents/pi/index.ts b/packages/maker-core/src/agents/pi/index.tsindex 45303d4edc..aa29a114f2 100644--- a/packages/maker-core/src/agents/pi/index.ts+++ b/packages/maker-core/src/agents/pi/index.ts@@ -2260,7 +2260,9 @@ export class PiAgent extends BaseAgent {}const modelBaseUrl = endpoint ? piGatewayModelBaseUrl(endpoint, api) : undefined;gatewayApiByModel.set(m.id, api);- const supportsImageInput = m.supportsImageInput === true;+ // Missing capability metadata must not disable newly discovered vision models.+ // Explicit text-only declarations still take precedence over this default.+ const supportsImageInput = m.supportsImageInput !== false;gatewayImageInputByModel.set(m.id, supportsImageInput);const thinkingLevelMap = gatewayThinkingLevelMap(m.efforts, resolvedSpec?.thinkingLevelMap);return [{@@ -2339,7 +2341,7 @@ export class PiAgent extends BaseAgent {...(m.api ? { api: m.api } : {}),reasoning: m.reasoning ?? false,...(m.thinkingLevelMap ? { thinkingLevelMap: { ...m.thinkingLevelMap } } : {}),- input: m.input ?? ['text'],+ input: m.input ?? ['text', 'image'],contextWindow,maxTokens: m.maxTokens && m.maxTokens > 0 ? m.maxTokens : piMaxTokensFallback(contextWindow),...(m.cost ? { cost: structuredClone(m.cost) } : {}),@@ -5985,13 +5987,13 @@ export class PiAgent extends BaseAgent {const assertImageInputSupported = (images: readonly PiPromptImage[]): void => {if (images.length === 0) return;+ const nativeModel = nativeProviderById+ .get(mutablePiProviderId)+ ?.models.find((candidate) => candidate.id === resolveNativeModelId(mutablePiProviderId, mutableModel));const supportsImageInput =mutablePiProviderId === PI_PROVIDER_ID? gatewayImageInputByModel.get(mutableModel) === true- : nativeProviderById- .get(mutablePiProviderId)- ?.models.find((candidate) => candidate.id === resolveNativeModelId(mutablePiProviderId, mutableModel))- ?.input?.includes('image') === true;+ : nativeModel !== undefined && (nativeModel.input ?? ['text', 'image']).includes('image');if (supportsImageInput) return;throw new PiImageInputUnsupportedError();};