Skip to content

feat: filter unsupported tools from Responses API requests#9

Open
bob733870-cloud wants to merge 1 commit into
Jer-y:mainfrom
bob733870-cloud:filter-unsupported-tools
Open

feat: filter unsupported tools from Responses API requests#9
bob733870-cloud wants to merge 1 commit into
Jer-y:mainfrom
bob733870-cloud:filter-unsupported-tools

Conversation

@bob733870-cloud

Copy link
Copy Markdown

Summary

  • Filters out unsupported tool types (e.g. image_generation) from Responses API requests before forwarding upstream
  • Prevents unsupported_value errors when Codex Desktop includes tools that the Copilot backend doesn't support

Problem

When using Codex Desktop with requires_openai_auth = true and a Copilot proxy, the client automatically includes image_generation in the tools array. Since the Copilot backend does not support this tool type, every request fails with:

{"error":{"message":"The requested tool image_generation is not supported.","code":"unsupported_value","param":"tools","type":"invalid_request_error"}}

This is a known issue (openai/codex#21952) where [features].image_generation = false in config.toml is ignored by Codex Desktop.

Solution

Added a FILTERED_TOOL_TYPES set in handleResponses() that strips unsupported tools before forwarding. Currently filters image_generation; additional types can be added to the set as needed.

Test plan

  • Tested with Codex Desktop + Copilot proxy with requires_openai_auth = true
  • Verified image_generation is stripped from requests
  • Verified normal conversation flow works without errors
  • Claude Code (Anthropic Messages API path) unaffected

🤖 Generated with Claude Code

When using Codex Desktop with `requires_openai_auth = true` and a
third-party proxy (e.g. Copilot proxy), the client automatically
includes `image_generation` in the tools array. Since the Copilot
backend does not support this tool type, requests fail with
"unsupported_value" errors.

This adds a configurable filter in `handleResponses()` that strips
unsupported tool types before forwarding upstream. Currently filters
`image_generation`; additional types can be added to the
`FILTERED_TOOL_TYPES` set.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>

@Jer-y Jer-y left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for the PR. This needs changes before it is safe to merge.

The current implementation strips hosted Responses tools before routing, which can produce false-success responses and bypass the existing translatability guard for non-Responses backends. That is a behavior change in a high-risk area and should either remain upstream-aligned or be implemented as a narrowly scoped, tested compatibility path.

const FILTERED_TOOL_TYPES = new Set(['image_generation'])
if (payload.tools?.length) {
const before = payload.tools.length
payload.tools = payload.tools.filter(t => !FILTERED_TOOL_TYPES.has(t.type))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Silently dropping image_generation here changes the request semantics before routing. For direct Responses-backed models, a request that explicitly provided this hosted tool now succeeds without the tool instead of surfacing Copilot's unsupported result; for Anthropic-routed models this also removes a hosted tool before assertResponsesPayloadTranslatable, so a request that should be rejected as not translatable can be forwarded as tool-less. That conflicts with the proxy capability policy to keep upstream behavior as the source of truth and avoid false-success compatibility shims. Please either keep forwarding and let upstream reject, or gate a client-specific fallback with regression tests that preserve the existing hosted-tool rejection semantics.

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