mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 21:30:17 +08:00
5968336364
When proxying Codex Responses requests through the Chat Completions format (api_format=openai_chat), the request transform only forwarded plain `function` tools and silently dropped `tool_search`, `namespace` (MCP), and `custom` tools, so third-party APIs never saw the official Codex plugins and could not call them. Introduce CodexToolContext, built from the original Responses request, which flattens all four tool kinds into Chat functions and keeps a chat_name -> CodexToolSpec map. The response path (streaming and non-streaming) looks names up in this map to restore the original tool_search_call / custom_tool_call / namespaced function_call items instead of reparsing the flattened name. Long namespaced names are truncated with a sha256 suffix to fit the 64-char Chat tool-name limit. Covered by new round-trip tests for all four tool kinds across both streaming and non-streaming paths.