Skip to content

fix(pi): preserve image metadata for legacy DeepSeek selections - #225

Merged
Lucas1479 merged 3 commits into
mainfrom
codex/fix-pi-legacy-model-metadata
Oct 17, 2026
Merged

Lucas1479 merged 3 commits into
mainfrom
codex/fix-pi-legacy-model-metadata

Conversation

@Desolate-Jix

@Desolate-Jix Desolate-Jix commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Pi 1.2.0 can resolve the documented legacy DeepSeek Flash selection with text-only metadata, causing MCP images to be removed before the provider request. The Host extension uses the public session/turn hooks to select a copy of the native canonical model with the original alias ID, before image conversion. Explicit alias declarations and native/extension Provider registrations retain precedence; the selected endpoint, authentication and model ID remain native.

The compatibility repair is optional. A registry error can belong to an unrelated Provider rather than to models.json parsing. Such errors, unreadable/malformed declarations, an unavailable canonical model or a rejected/failed setModel now retain Pi's native selection, skip the repair for that Work and emit one fixed, sanitized warning. They do not become a fatal extension_error. The Host's normal extension-error handling is unchanged.

Validation of the review revision:

  • Native SDK metadata suite: 24 passed, retaining the previous 17 cases and adding error-boundary/multi-turn coverage.
  • Provider regression suite: 21 passed. Main's combined run: 45 passed; these counts overlap and are not additive.
  • Native TypeScript typecheck and git diff --check passed.
  • Regression RED on the unchanged production revision: 9 failed / 15 passed. The corrected revision covers unrelated malformed Provider configuration, declaration read/parse failures before and after native loading, setModel rejection/exception, explicit configuration precedence, repeated startup binding and two image-bearing turns. Failure cases preserve selection, emit no fatal extension_error, notify once and make no network requests.

These checks use the actual Pi 1.2.0 SDK and a deterministic completion stream. They do not claim a new desktop run, external model accuracy or raw provider HTTP capture. Remote CI on review commit 5b3a434 completed successfully: all 15 reported check runs passed. Earlier CI records remain associated with their original heads.

@Desolate-Jix
Desolate-Jix marked this pull request as ready for review October 15, 2026 11:40
@Lucas1479

Copy link
Copy Markdown
Member

复核结论:核心元数据修复方向正确,但下面这处 P2 请先修改,完成后再请求重新审查;当前版本暂不建议合并。

[P2] 不要把无关 provider 的错误升级成整个 Pi Work 的失败

核验提交:12da7e85c2d1ad61b4ce888e24acc2cb72c56265。model-metadata.ts:39–45 将任意 registry.getError() 转成声明读取失败,并缓存这个 Error;启动和以后每轮都会再次抛出。

Pi 1.2.0 的 getError() 不仅包含 models.json 读取/解析错误,还汇总 provider composition errors 和 availability refresh errors。使用本 PR 的离线 SDK 框架,加入缺少 baseUrl 的无关 provider 即可复现:

{"providers":{"local-llm":{"api":"openai-completions","models":[{"id":"fixture"}]}}}

实测:deepseek-flash 仍可解析;registry 报 Provider local-llm: "baseUrl" is required when defining custom models.;扩展在启动和下一轮各报一次声明读取失败;图片转换数量为 0,网络请求次数为 0。

影响超出了图片兼容:pi.py:337–338 将 extension_error 转成 PiTransportError,已提交运行随后进入 orphaned。默认旧别名路径因此会被一个无关 provider 的错误打断。

请在这段可选兼容逻辑的边界修复:不要把全局 registry 错误等同于声明读取失败;无法可靠判断声明或完成修补时,保留 Pi 原生选择、跳过修补,并通过 ctx.ui.notify 给出一次不含配置内容的提示。真正相关的声明读取/解析失败也不应由这项可选修补升级成致命扩展错误。不要为此全局吞掉 Host 的 extension_error。

请补回归用例,覆盖无关 provider 配错、声明读取/解析失败及多轮行为,验证没有致命 extension_error、提示不重复,并继续保留显式别名/Provider 配置的优先权。现有 17 项 SDK 测试和 typecheck 通过,但未覆盖这一错误边界。

@Lucas1479
Lucas1479 merged commit 7b97e21 into main Oct 17, 2026
15 checks passed
@Lucas1479
Lucas1479 deleted the codex/fix-pi-legacy-model-metadata branch October 17, 2026 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants