新版 Claude 模型导致 Pi 工具调用异常

Simon Willison 博客·2026-07-05 06:53·58天前·Simon Willison
AI 导读

Armin 在开发编码工具 Pi 时发现,新版 Claude 模型(Opus 4.8 和 Sonnet 5)调用 Pi 的 edit 工具时,会在嵌套的 edits[] 数组中凭空增加不存在的键,导致工具调用因 schema 不匹配被 Pi 拒绝。旧模型(包括 Haiku)均无此问题。Armin 推测 Anthropic 通过强化学习让新模型更善于使用 Claude Code 内置的编辑工具,却导致第三方工具 Pi 的自定义编辑工具更易被误用。OpenAI 的 Codex 采用 apply_patch 机制,也面临类似问题。这引发思考:第三方编码工具是否应为不同底层模型分别实现多个编辑工具以保障兼容性。

Simon Willison 博客
60AI 编辑部评分,满分 100

新版 Claude 模型导致 Pi 工具调用异常

2026-07-05 06:53· 58天前· Simon Willison
AI 导读

Armin 在开发编码工具 Pi 时发现,新版 Claude 模型(Opus 4.8 和 Sonnet 5)调用 Pi 的 edit 工具时,会在嵌套的 edits[] 数组中凭空增加不存在的键,导致工具调用因 schema 不匹配被 Pi 拒绝。旧模型(包括 Haiku)均无此问题。Armin 推测 Anthropic 通过强化学习让新模型更善于使用 Claude Code 内置的编辑工具,却导致第三方工具 Pi 的自定义编辑工具更易被误用。OpenAI 的 Codex 采用 apply_patch 机制,也面临类似问题。这引发思考:第三方编码工具是否应为不同底层模型分别实现多个编辑工具以保障兼容性。

Simon Willison’s Weblog

4th July 2026 - Link Blog

Better Models: Worse Tools. Armin reports on a weird problem he ran into while hacking on Pi:

The short version is that newer Claude models sometimes call Pi’s edit tool with extra, invented fields in the nested edits[] array. And not Haiku or some small model: Opus 4.8. The edit itself is usually correct but the arguments do not match the schema as the model invents made-up keys and Pi thus rejects the tool call and asks to try again.

That alone is not too surprising as models emit malformed tool calls sometimes. Particularly small ones. What surprised me is that this is getting worse with newer Anthropic models as both Opus 4.8 and Sonnet 5 show it but none of the older models. In other words, the SOTA models of the family are worse at this specific tool schema than their older siblings.

Armin theorizes that this is because more recent Anthropic models have been specifically trained (presumably via Reinforcement Learning) to better use the edit tools that are baked into Claude Code. This has the unfortunate effect that other coding harnesses, such as Pi, may find that their own custom edit tools are more likely to be used incorrectly.

Claude's edit tool uses search and replace. OpenAI's Codex uses an apply_patch mechanism instead, and OpenAI have talked in the past about how their models are trained to use that tool effectively.

Does this mean third-party coding harnesses like Pi should implement multiple edit tools just so they can use the one with the best performance for the underlying model the user has selected?

4th July 2026

来源:Simon Willison 博客· simonwillison.net