Repository navigation
Python: Convert nested SDK models in hosted tool sanitization - #9789
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
Conversation
|
/review |
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): f2ebec8206d3
Model: gpt-5.6-sol
Overview
The change fixes the reported serialization failure by recursively converting nested Azure SDK models, and the new tests exercise both affected factories through the real preparation path and json.dumps(). Existing validation, field stripping, and explicit container preservation remain intact. However, checking for as_dict before handling mappings introduces a compatibility regression for otherwise valid mapping-based hosted tools.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
1 verified finding remained after source verification (1 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: python/packages/foundry/agent_framework_foundry/_tools.py
b41cee0 to
b49e292
Compare
|
Thanks for the fix, Dhruv Shaswat (@Dhruv-Sh-git). The Azure SDK tool model already provides the canonical recursive conversion through |
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.