Skip to content

Drop empty-name tools before forwarding to upstream#60

Open
anmho wants to merge 1 commit into
ZhiYi-R:mainfrom
anmho:fix/drop-empty-name-tools
Open

Drop empty-name tools before forwarding to upstream#60
anmho wants to merge 1 commit into
ZhiYi-R:mainfrom
anmho:fix/drop-empty-name-tools

Conversation

@anmho

@anmho anmho commented May 26, 2026

Copy link
Copy Markdown

Summary

  • Codex's Responses API includes OpenAI-only typed tools (e.g. image_generation, web_search, file_search, computer_use) that have no function.name field — they are identified by type instead.
  • Moon Bridge's converter has no special-case for these typed tools, so they flow into flattenToolsWithNamespace with Name == "" and Extensions like {"source_type":"image_generation"}.
  • Upstream Anthropic-compatible endpoints (verified against DeepSeek /anthropic) then reject the request with Invalid 'tools[N].function.name': empty string, returning a 400 that Moon Bridge surfaces as 502 to Codex.
  • This makes Codex unusable against DeepSeek (and likely other strict upstreams) whenever the user has Codex's built-in image generation enabled.

Fix

Skip empty-name tools in flattenToolsWithNamespace (alongside the existing dedup pass). These hosted tool types cannot run on non-OpenAI upstreams anyway, so dropping them is the correct semantic — not a hack.

Test plan

  • Reproduce 502 with Codex + DeepSeek via Moon Bridge
  • Confirm tool at index 389 in failing request has Name="", Extensions={"source_type":"image_generation"}
  • Apply patch, rebuild, restart; confirm Codex turn completes successfully
  • Verify normal function tools still pass through (tool count drops by 1, the rest unchanged)

Codex's Responses API includes structured/typed tools (e.g. image_generation,
web_search, file_search, computer_use) that have no `function.name` field
because they are identified by `type` instead. The converter preserves the
type info via Extensions but leaves Name empty, which causes upstream
Anthropic-compatible endpoints like DeepSeek to reject the entire request
with `tools[N].function.name: empty string`.

These hosted tool types are OpenAI-specific and not executable on other
providers anyway, so skip them in flattenToolsWithNamespace alongside the
existing dedup pass.
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