Skip to content

fix(runtime): keep tool_search's runtime name in the Code Mode catalog - #5666

Merged
liugddx merged 1 commit into
apache:mainfrom
liugddx:fix/code-mode-tool-search-alias
Sep 24, 2026
Merged

liugddx merged 1 commit into
apache:mainfrom
liugddx:fix/code-mode-tool-search-alias

Conversation

@liugddx

@liugddx liugddx commented Sep 24, 2026

Copy link
Copy Markdown
Member

Summary

In Code Mode on the OpenAI Responses adapter, the catalog prompt told the model to call tools.maka_tool_search, but exec binds nested tools under their runtime names, so the call failed with not a function and no deferred tool could load.

The adapter now rewrites tool_search in prose (system prompt and tool-result text) only when tool_search is itself a provider-visible tool. Tool-call names in history keep the existing #3958 remap, so the reserved name still never reaches OpenAI as a function name.

Fixes #5664

Verification

  • New responses-wire-contract test: Code Mode shape (exec only) on an openai-codex connection keeps tool_search in the developer message and in exec output, and exposes only exec. It fails without the fix (# fail 1) and passes with it.
  • The existing alias test (direct mode, tool_search as a provider tool) still gets maka_tool_search.
  • node --test over responses-wire-contract, code-mode-backend, code-mode, ai-sdk-backend: 326 pass, 0 fail.
  • biome check, ASF header check, protocol epoch guard, git diff --check: clean. I ran these by hand because the husky pre-commit hook cannot start on Windows (spawnSync biome.cmd → EINVAL), so the commit used --no-verify.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Claude Code diagnosed the failure from the source, and wrote the fix and the test. I reviewed the change. The commit carries a Generated-by: Claude Code trailer.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

🤖 Generated with Claude Code

OpenAI Responses reserves `tool_search`, so the adapter renames the
provider-bound tool to `maka_tool_search` and rewrote every `tool_search`
in the system prompt to match. In Code Mode the provider only sees `exec`;
tool_search is nested inside it and bound as `tools.tool_search`. The
rewrite still renamed it in the catalog prompt, so models called
`tools.maka_tool_search` and got "not a function" before any deferred
tool (e.g. ScheduledTask) could load.

Rewrite prose only when tool_search is itself a provider tool. Tool-call
names in history keep their existing remap.

Generated-by: Claude Code
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions github-actions Bot added the effort/M Under 500 readable lines label Sep 24, 2026
@liugddx

liugddx commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

The first test run failed on one Code Mode timing test, code-mode.test.ts › "excludes host waiting from the execution budget and preserves dependent Promise.race progress" (result.ok false at line 64). That test calls only executeCodeCell with a 200 ms guest budget next to a 500 ms host wait. It does not touch model-adapter.ts. It passes locally and on #5667 from the same base. A rerun of the failed job passed (job 107477861509). I'm noting it here as a likely load-sensitive flake, not a regression from this change.

(Posted by Claude Code on behalf of @liugddx.)

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relayed review of exact head d303b95fd34ccbeb7af38da5b5a9403e67690feb. COMMENT only — not an approval.

This is not my conclusion. It was reached by the Muse-Qronos review lane, which has no GitHub publishing access, and I am posting it at their request so it is visible on the pull request rather than only in a chat thread. I did not verify it myself, so please weigh it as that lane's result, not as a second opinion confirming it.

Their conclusion, verbatim in substance: no P0–P3 found. The change surfaces the provider alias as the tool name only in the Responses direct-call path, while preserving the Code Mode exec naming and the mapping for older conversations, with test coverage in place. They considered it technically mergeable, with the merge decision left to a human.

A companion note on #5667 carries that PR's review, including one P3 I did reproduce independently.

简体中文

代发的评审,绑定 exact head d303b95fd34ccbeb7af38da5b5a9403e67690feb。仅 COMMENT,不构成批准。

这不是我的结论。 它来自 Muse-Qronos 评审线;该席位没有 GitHub 发布权限,我受其委托代发,目的是让结论出现在 PR 上,而不是只留在聊天线程里。我本人没有核验过这一单,所以请把它当作那条线的结果,而不是「又一个人确认了它」。

他们的结论:未发现 P0–P3。 该改动只在 Responses 直调路径上把工具名显示为提供方别名,同时保留 Code Mode 的 exec 命名以及旧对话的映射,测试覆盖到位。他们认为技术上可合,合并与否交由人类决定。

#5667 上另有一条评审,含一条我独立复现过的 P3。


Automated review notice: This comment was posted by an automated review agent operated by jackwener. It is not an independent human review and does not replace one. Conclusion by the Muse-Qronos lane; published on their behalf and explicitly not verified by the publishing seat.

@me2seeks me2seeks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the exact head d303b95fd3 against the reported failure in #5664.

Scope of this review: I verified the alias now reaches prose only when tool_search is itself a provider-visible tool (sdkTools[TOOL_SEARCH_NAME] !== undefined), while tool-call names in history keep the #3958 remap. The Code Mode regression test fails without the fix and the direct-mode alias test (ai-sdk-backend.test.ts) is unaffected because that lane genuinely exposes the provider function. Tool-call input and exec code are untouched, so the fix is confined to the system text and tool-result text channels.

Remaining nit, non-blocking: providerTextToolName degenerates to the identity when the alias is not exposed, so the remapProviderToolNamesInText pass becomes a no-op replace. Correct as written; a guard would be marginally simpler.

Approving on the evidence above. This is a functional fix for a shipped configuration (Code Mode + OpenAI Responses).

@liugddx
liugddx merged commit 6adda8c into apache:main Sep 24, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(runtime): Code Mode on OpenAI Responses advertises maka_tool_search, which exec does not bind

3 participants