Python: Strip tools from FoundryAgent request when agent_reference is present#5101
Merged
moonbox3 merged 2 commits intomicrosoft:mainfrom Apr 8, 2026
Merged
Conversation
… present _prepare_options() now removes tools, tool_choice, and parallel_tool_calls from run_options after injecting agent_reference. The Foundry API rejects requests containing both fields. FunctionTools are still invoked client-side by the function invocation layer. Fixes microsoft#5087 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
eavanvalkenburg
approved these changes
Apr 7, 2026
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
chetantoshniwal
approved these changes
Apr 7, 2026
This was referenced Apr 13, 2026
This was referenced Apr 20, 2026
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
FoundryAgentreturns HTTP 400 when bothagent_referenceandtoolsare present in the serialized request body. The parent classRawOpenAIChatClient._prepare_options()addstoolstorun_optionsat_chat_client.py:1193, but_prepare_options()in the Foundry subclass never strips it before returning. The Foundry API rejects requests containing both fields.Changes
RawFoundryAgentChatClient._prepare_options(), add.pop()calls to removetools,tool_choice, andparallel_tool_callsfromrun_optionsafter injectingagent_reference. FunctionTools are still invoked client-side by the function invocation layer.test_raw_foundry_agent_chat_client_prepare_options_strips_toolsverifying that tools are absent from the returned options whileagent_referenceis preserved.Testing
_prepare_optionsto return dict withtools/tool_choice/parallel_tool_calls, asserts all three are stripped andagent_referenceremains inextra_bodytest_raw_foundry_agent_chat_client_prepare_options_accepts_function_toolsstill passesFixes #5087
This contribution was developed with AI assistance (Claude Code).