Repository navigation
Python: Convert nested SDK models in hosted tool sanitization - #9789
Open
Dhruv Shaswat (Dhruv-Sh-git) wants to merge 1 commit into
Open
Dhruv Shaswat (Dhruv-Sh-git) wants to merge 1 commit into
Dhruv Shaswat (Dhruv-Sh-git) wants to merge 1 commit into
Conversation
Dhruv Shaswat (Dhruv-Sh-git)
temporarily deployed
to
github-app-auth
October 28, 2026 09:32 — with
GitHub Actions
Inactive
Dhruv Shaswat (Dhruv-Sh-git)
temporarily deployed
to
github-app-auth
October 28, 2026 09:32 — with
GitHub Actions
Inactive
Dhruv Shaswat (Dhruv-Sh-git)
temporarily deployed
to
github-app-auth
October 28, 2026 09:33 — with
GitHub Actions
Inactive
Dhruv Shaswat (Dhruv-Sh-git)
marked this pull request as ready for review
October 28, 2026 09:35
Dhruv Shaswat (Dhruv-Sh-git)
temporarily deployed
to
github-app-auth
October 28, 2026 09:36 — with
GitHub Actions
Inactive
This branch was previously deployed
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.
Fixes #9784.
Summary
Passing tools returned by
FoundryChatClient.get_bing_custom_search_tool()orFoundryChatClient.get_code_interpreter_tool()directly to an agent or_prepare_tools_for_openai()could fail during JSON serialization with aTypeError.The issue was that
_sanitize_foundry_response_tool()only made a shallow copy of the tool mapping. Nested Azure SDK models were left unchanged, so they couldn't be serialized as JSON.Changes
_tools.pyto recursively convert nested SDK models into plain Python data using their.as_dict()representation, including values inside mappings and sequences.test_foundry_chat_client.pyfor both Bing custom search and code interpreter tools, checking that they produce valid JSON payloads through_prepare_tools_for_openai().Testing
Validated locally with Ruff and pytest: 464 tests passed in
packages/foundry.