Skip to content

Python: (foundry): stop emitting [TOOLBOXES] warning for every FoundryChatClient call#5440

Merged
moonbox3 merged 2 commits intomicrosoft:mainfrom
moonbox3:fix/foundry-sanitize-internal
Apr 23, 2026
Merged

Python: (foundry): stop emitting [TOOLBOXES] warning for every FoundryChatClient call#5440
moonbox3 merged 2 commits intomicrosoft:mainfrom
moonbox3:fix/foundry-sanitize-internal

Conversation

@moonbox3
Copy link
Copy Markdown
Contributor

@moonbox3 moonbox3 commented Apr 23, 2026

Motivation and Context

FoundryChatClient emits a [TOOLBOXES] sanitize_foundry_response_tool is experimental ... warning on every call, even when the caller never touches a toolbox. sanitize_foundry_response_tool runs unconditionally inside _prepare_tools_for_openai for every tool payload, so its @experimental(TOOLBOXES) decorator fires for plain function tools too — misleading users into thinking they're using an experimental feature when they aren't.

Description

Rename sanitize_foundry_response_tool_sanitize_foundry_response_tool and drop the @experimental decorator. It's a pure internal Responses-API payload sanitizer — not in __all__, no external callers — so the toolbox feature gate doesn't belong on it. The genuinely toolbox-facing public helpers (fetch_toolbox, get_toolbox_tool_name, get_toolbox_tool_type, select_toolbox_tools) stay @experimental(TOOLBOXES).

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change?

…S warning

sanitize_foundry_response_tool runs on every tool passed to the Foundry
Responses API, so its @experimental(TOOLBOXES) decorator was emitting a
[TOOLBOXES] ExperimentalWarning for any FoundryChatClient call, even when
no toolbox was involved. The function isn't in __all__ and has no external
callers. Rename to _sanitize_foundry_response_tool and drop the decorator;
the actual toolbox-facing public helpers remain gated.
Copilot AI review requested due to automatic review settings April 23, 2026 10:27
@moonbox3 moonbox3 changed the title Python: Foundry: stop emitting [TOOLBOXES] warning for every FoundryChatClient call Python: (foundry): stop emitting [TOOLBOXES] warning for every FoundryChatClient call Apr 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes an experimental TOOLBOXES warning that was being emitted on every FoundryChatClient call by making the Foundry tool payload sanitizer explicitly internal and no longer @experimental.

Changes:

  • Renamed sanitize_foundry_response_tool to _sanitize_foundry_response_tool.
  • Removed the @experimental(feature_id=ExperimentalFeature.TOOLBOXES) decorator from the sanitizer.
  • Updated FoundryChatClient and Foundry agent tool-preparation paths to call the renamed sanitizer.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
python/packages/foundry/agent_framework_foundry/_tools.py Makes the tool payload sanitizer private and removes the experimental decorator to avoid per-call TOOLBOXES warnings.
python/packages/foundry/agent_framework_foundry/_chat_client.py Switches tool preparation to use _sanitize_foundry_response_tool.
python/packages/foundry/agent_framework_foundry/_agent.py Switches agent tool preparation to use _sanitize_foundry_response_tool.

@moonbox3 moonbox3 self-assigned this Apr 23, 2026
@moonbox3
Copy link
Copy Markdown
Contributor Author

moonbox3 commented Apr 23, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/foundry/agent_framework_foundry
   _agent.py1463675%183–184, 188–190, 195–198, 293, 323–324, 336–337, 349–351, 353–354, 356–362, 364–365, 367, 369, 373–374, 561–562, 565, 607
   _chat_client.py1511987%84, 86–88, 92–93, 97, 191, 222, 315, 376, 378, 476, 480–481, 483–486
   _tools.py81495%72, 80, 127, 197
TOTAL29069346788% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
5799 30 💤 0 ❌ 0 🔥 1m 38s ⏱️

@moonbox3 moonbox3 added the agents Issues related to single agents label Apr 23, 2026
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 4 | Confidence: 92%

✓ Correctness

This PR renames sanitize_foundry_response_tool to _sanitize_foundry_response_tool (adding underscore prefix to mark it as private) and removes the @experimental decorator from it. All internal import sites and call sites in _agent.py and _chat_client.py are updated consistently. The function was never exported from any __init__.py and no tests reference it by name. The ExperimentalFeature/experimental imports in _tools.py are still needed by other functions. No correctness issues found.

✓ Security Reliability

This PR renames sanitize_foundry_response_tool to _sanitize_foundry_response_tool (private convention) and removes the @experimental decorator. The function is only used internally within two files (_agent.py and _chat_client.py), is not exported from __init__.py, and has no test references under its old name. The rename is consistent across all call sites and imports. No security or reliability concerns.

✓ Test Coverage

This PR renames sanitize_foundry_response_tool to _sanitize_foundry_response_tool (making it private) and removes its @experimental decorator. The rename is consistent across all three files. The function's behavior is tested indirectly through FoundryChatClient._prepare_tools_for_openai tests in test_foundry_chat_client.py (10+ test cases covering stripping fields, container injection, validation errors, etc.). However, FoundryAgent._prepare_tools_for_openai has zero test coverage for the same sanitization logic — it could silently break without any test catching it. The function was never in __all__, so no public API break.

✗ Design Approach

The sanitization behavior itself still looks sound, but the chosen fix changes the toolbox API surface in a way that is broader than the problem being solved. By renaming sanitize_foundry_response_tool to a private helper and removing its @experimental marker, this PR turns a previously staged callable into an internal-only symbol instead of separating internal use from public compatibility. That is a design regression because users who sanitize toolbox-fetched tools directly lose the only supported entry point for that behavior, even though the underlying need remains.

Suggestions

  • FoundryAgent._prepare_tools_for_openai (line 324 of _agent.py) also calls _sanitize_foundry_response_tool but has no test coverage, unlike FoundryChatClient which has 10+ tests in test_foundry_chat_client.py (lines 620–770). Consider adding at least one test in test_foundry_agent.py to verify FoundryAgent applies the same sanitization.

Automated review by moonbox3's agents

@moonbox3 moonbox3 added this pull request to the merge queue Apr 23, 2026
Merged via the queue into microsoft:main with commit b084d04 Apr 23, 2026
32 checks passed
moonbox3 added a commit to moonbox3/agent-framework that referenced this pull request Apr 24, 2026
Previous commit incorrectly renamed the [1.1.1] header to [1.2.0], which
wiped the historical 1.1.1 entries and wrongly attributed them to 1.2.0.
This restores [1.1.1] to its origin/main content and adds a new [1.2.0]
section above containing only the commits in python-1.1.1..HEAD:

- microsoft#4238 functional workflow API
- microsoft#5142 GitHub Copilot OpenTelemetry
- microsoft#2403 A2A bridge support
- microsoft#5070 oauth_consent_request events in Foundry clients
- microsoft#5447 FoundryAgent hosted agent sessions
- microsoft#5459 hosting server dependency upgrade + types
- microsoft#5389 AG-UI reasoning/multimodal parsing fix
- microsoft#5440 stop [TOOLBOXES] warning spam
- microsoft#5455 user agent prefix fix

Also corrects the [1.2.0] compare base to python-1.1.1 (not 1.1.0) and
adds the missing [1.1.1] reference link.
moonbox3 added a commit that referenced this pull request Apr 24, 2026
* Bump Python package versions for 1.2.0 release

Released tier bumps 1.1.1 -> 1.2.0 (core, openai, foundry, root) to
reflect additive public APIs landed since 1.1.0: functional workflow API
(#4238) and FunctionTool SKIP_PARSING sentinel (#5424). All beta packages
stamped 1.0.0b260424, alpha packages 1.0.0a260424. All 26 non-core
agent-framework-core floors raised to >=1.2.0,<2. CHANGELOG consolidates
the never-tagged 1.1.1 entries with the post-merge additions into [1.2.0].

* Update CHANGELOG footer links for 1.2.0

Advance [Unreleased] comparison base from python-1.1.0 to python-1.2.0
and add a [1.2.0] reference link comparing python-1.1.0...python-1.2.0
so the heading links resolve correctly.

* Fix CHANGELOG: restore [1.1.1] section and add proper [1.2.0]

Previous commit incorrectly renamed the [1.1.1] header to [1.2.0], which
wiped the historical 1.1.1 entries and wrongly attributed them to 1.2.0.
This restores [1.1.1] to its origin/main content and adds a new [1.2.0]
section above containing only the commits in python-1.1.1..HEAD:

- #4238 functional workflow API
- #5142 GitHub Copilot OpenTelemetry
- #2403 A2A bridge support
- #5070 oauth_consent_request events in Foundry clients
- #5447 FoundryAgent hosted agent sessions
- #5459 hosting server dependency upgrade + types
- #5389 AG-UI reasoning/multimodal parsing fix
- #5440 stop [TOOLBOXES] warning spam
- #5455 user agent prefix fix

Also corrects the [1.2.0] compare base to python-1.1.1 (not 1.1.0) and
adds the missing [1.1.1] reference link.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Issues related to single agents python

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants