-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(responses): execute code-mode view_image through unified exec #4475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,16 +47,17 @@ export function dottedToolName(namespace: string | undefined, name: string): str | |
| * | ||
| * Codex's code-mode shell tool is declared as `exec` (a freeform custom tool whose own | ||
| * description mentions the nested `await tools.exec_command(...)` helper). Some routed providers | ||
| * echo that helper name as the tool-call name, emitting `exec_command`, `write_stdin`, or | ||
| * `apply_patch` instead of the declared `exec`. Accept these nested helper names only when the | ||
| * request catalog actually declares `exec` and does not itself declare the emitted name (an MCP | ||
| * server may legitimately advertise one under its own namespace). | ||
| * echo that helper name as the tool-call name, emitting `exec_command`, `write_stdin`, | ||
| * `apply_patch`, or `view_image` instead of the declared `exec`. Accept these nested helper names | ||
| * only when the request catalog actually declares `exec` and does not itself declare the emitted | ||
| * name (an MCP server may legitimately advertise one under its own namespace). | ||
| */ | ||
| const LEGACY_SHELL_BRIDGE_TOOL_NAMES = ["exec_command", "shell_command"] as const; | ||
| const CODE_MODE_HELPER_TOOL_NAMES = [ | ||
| ...LEGACY_SHELL_BRIDGE_TOOL_NAMES, | ||
| "write_stdin", | ||
| "apply_patch", | ||
| "view_image", | ||
| ] as const; | ||
|
|
||
| /** | ||
|
|
@@ -71,7 +72,7 @@ export const CODE_MODE_EXEC_TOOL_NAME = "exec"; | |
| * | ||
| * Rewrites invented `default.<name>` prefixes back to a declared bare tool when that bare tool | ||
| * is declared and neither `default.<name>` nor `default__<name>` was explicitly declared (#4176). | ||
| * Also normalizes legacy helper names (`exec_command`, `shell_command`, `apply_patch`) to | ||
| * Also normalizes legacy helper names (`exec_command`, `shell_command`, `apply_patch`, `view_image`) to | ||
| * `exec` when code-mode `exec` is declared in the request catalog. | ||
| * | ||
| * @param name - The tool name emitted on the wire by the provider. | ||
|
|
@@ -98,6 +99,17 @@ export function normalizeDeclaredToolName( | |
| && !declared.has("default__" + bare) | ||
| ) { | ||
| candidate = bare; | ||
| } else if ( | ||
| // Code mode never declares bare helper names; a provider that invents `default.` | ||
| // for one still means the nested helper. Strip the prefix so the helper list | ||
| // below can rewrite it to `exec` (#4412). | ||
| bare.length > 0 | ||
| && declared.has(CODE_MODE_EXEC_TOOL_NAME) | ||
| && (CODE_MODE_HELPER_TOOL_NAMES as readonly string[]).includes(bare) | ||
|
Comment on lines
+107
to
+108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the catalog declares Useful? React with 👍 / 👎. |
||
| && !declared.has("default." + bare) | ||
| && !declared.has("default__" + bare) | ||
| ) { | ||
| candidate = bare; | ||
| } | ||
| } | ||
| if (!declared.has(CODE_MODE_EXEC_TOOL_NAME)) return candidate; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit message explicitly says this carries #4455 by @jeongjin0 and part of #4171 by @rrmlima, but the commit contains no
Co-authored-bytrailers despite claiming that both authors were credited that way. The prose attribution does not register either contributor; add proper trailers to the PR description or a follow-up branch commit so they survive the squash.AGENTS.md reference: AGENTS.md:L288-L292
Useful? React with 👍 / 👎.