fix(transports): dedupe OpenAI tool schemas before strict providers#18497
Open
fjlaowan1983 wants to merge 1 commit into
Open
fix(transports): dedupe OpenAI tool schemas before strict providers#18497fjlaowan1983 wants to merge 1 commit into
fjlaowan1983 wants to merge 1 commit into
Conversation
…quests Align outbound tools with providers that enforce unique function names (Anthropic, Vertex, Bedrock, Azure, etc.). Adds dedupe_openai_tool_definitions_for_api in transports base and applies it from chat completions, Anthropic, Bedrock, Codex transports and auxiliary chat.completions helpers. Fixes NousResearch#18478.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Several providers (Anthropic direct, Vertex AI, Azure OpenAI, Bedrock Converse, and other strict OpenAI-compatible routes) reject requests when the
toolsarray contains duplicatefunction.nameentries, typically with HTTP 400 and messages likeTool names must be unique. This change adds a shared guard that keeps the first schema for each name and drops later duplicates at the transport / auxiliary boundary, so bad lists cannot reach the wire.What changed
dedupe_openai_tool_definitions_for_apiinagent/transports/base.py.ChatCompletionsTransport.build_kwargsAnthropicTransport/BedrockTransport/CodexTransportbuild_kwargsagent/auxiliary_client(chat completions_build_call_kwargs, plus Codex auxiliary tool conversion path)This complements existing agent-side dedup (e.g. context-engine schema injection) by hardening the last mile for any caller that still assembled a duplicate list.
Testing
pytest tests/agent/transports/test_chat_completions.py::TestChatCompletionsBuildKwargs::test_tools_included \ tests/agent/transports/test_chat_completions.py::TestChatCompletionsBuildKwargs::test_tools_duplicate_names_keep_first \ tests/agent/test_auxiliary_client.py::TestAuxiliaryChatCompletionsToolDedup -q -o addopts=