Skip to content

Python: Add support for Foundry Toolboxes#5346

Merged
moonbox3 merged 10 commits into
microsoft:mainfrom
moonbox3:py-foundry-toolbox
Apr 21, 2026
Merged

Python: Add support for Foundry Toolboxes#5346
moonbox3 merged 10 commits into
microsoft:mainfrom
moonbox3:py-foundry-toolbox

Conversation

@moonbox3

Copy link
Copy Markdown
Contributor

Motivation and Context

Introduces a Foundry Toolbox integration: FoundryChatClient gains a get_toolbox() helper plus select_toolbox_tools(), normalize_tools in the core package flattens tool-collection wrappers (ToolboxVersionObject and generic iterables, while leaving Pydantic BaseModel instances alone), and the new agent_framework.foundry namespace re-exports the toolbox helpers. Ships with unit tests, a sample, and a design doc.

azure-ai-projects is pinned to the public >=2.0.0,<3.0 range and the lockfile resolves from public PyPI. The toolbox test module skips when Toolbox* types are unavailable so CI stays green until the public 2.1.0 SDK lands.

Description

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? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings April 18, 2026 00:51
@moonbox3 moonbox3 self-assigned this Apr 18, 2026
@moonbox3 moonbox3 added python Usage: [Issues, PRs], Target: Python agents Usage: [Issues, PRs], Target: Single agent documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs labels Apr 18, 2026
@moonbox3

moonbox3 commented Apr 18, 2026

Copy link
Copy Markdown
Contributor Author

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _feature_stage.py1151289%97, 154, 161, 163–165, 172, 174, 179, 186, 205, 233
   _tools.py9588691%192–193, 366, 368, 381, 406–408, 416, 434, 448, 455, 462, 485, 487, 494, 502, 541, 585, 589, 621–623, 631, 676–678, 680, 703, 729, 733, 771–773, 777, 799, 941–947, 983, 995, 997, 999, 1002–1005, 1026, 1030, 1034, 1048–1050, 1391, 1413, 1500–1506, 1635, 1639, 1685, 1746–1747, 1862, 1882, 1884, 1940, 2003, 2175–2176, 2196, 2252–2253, 2391–2392, 2459, 2464, 2471
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.py1461986%84, 86–88, 92–93, 97, 191, 222, 315, 376, 378, 466, 470–471, 473–476
   _tools.py72494%72, 80, 127, 166
TOTAL28466330488% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
5687 30 💤 0 ❌ 0 🔥 1m 31s ⏱️

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds an experimental Azure AI Foundry Toolboxes integration to the Python Agent Framework, enabling FoundryChatClient to fetch toolboxes and allowing Agent(tools=...) to accept toolbox wrappers by flattening them into tool lists.

Changes:

  • Add FoundryChatClient.get_toolbox() plus toolbox selection/sanitization helpers in the Foundry package.
  • Extend core normalize_tools() to flatten toolbox-like wrappers (iterables and objects with a .tools collection).
  • Add unit/integration tests, a new Foundry sample, and an ADR documenting the design.

Reviewed changes

Copilot reviewed 14 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
python/uv.lock Updates Python dependency resolution (includes azure-ai-projects constraint and resolved version).
python/samples/02-agents/providers/foundry/foundry_chat_client_with_toolbox.py New sample demonstrating fetching and using toolboxes, combining toolboxes, and selecting tools.
python/samples/02-agents/providers/foundry/README.md Registers the new toolbox sample in the Foundry samples index.
python/packages/foundry/tests/test_toolbox.py New tests for toolbox fetch + selection behavior (includes an opt-in integration test).
python/packages/foundry/tests/foundry/test_foundry_chat_client.py Adds tests ensuring toolbox-returned hosted tool payloads are sanitized for Foundry Responses API.
python/packages/foundry/agent_framework_foundry/_tools.py Implements toolbox fetch helpers, tool selection helpers, and hosted-tool payload sanitization.
python/packages/foundry/agent_framework_foundry/_chat_client.py Adds get_toolbox() and sanitizes prepared tools before Foundry Responses calls.
python/packages/foundry/agent_framework_foundry/_agent.py Mirrors tool sanitization in the Foundry agent path.
python/packages/foundry/agent_framework_foundry/init.py Re-exports toolbox helper types/functions from the Foundry package.
python/packages/core/tests/core/test_tools.py Adds tests covering new normalize_tools() flattening behavior for tool-collection wrappers.
python/packages/core/agent_framework/foundry/init.pyi Re-exports toolbox helper types/functions via the core agent_framework.foundry namespace (stubs).
python/packages/core/agent_framework/foundry/init.py Re-exports toolbox helper types/functions via lazy-import mapping.
python/packages/core/agent_framework/_tools.py Extends normalize_tools() to flatten .tools collections and generic iterables (excluding BaseModel).
python/packages/core/agent_framework/_feature_stage.py Adds ExperimentalFeature.TOOLBOXES.
docs/decisions/0024-foundry-toolbox-support.md New ADR describing the toolbox feature design, API, and testing approach.
.gitignore Ignores additional AI-related local folders (.omc/, .omx/).

Comment thread docs/decisions/0024-foundry-toolbox-support.md Outdated
Comment thread docs/decisions/0025-foundry-toolbox-support.md
Comment thread python/packages/foundry/agent_framework_foundry/_tools.py
Comment thread python/samples/02-agents/providers/foundry/foundry_chat_client_with_toolbox.py Outdated
@moonbox3 moonbox3 force-pushed the py-foundry-toolbox branch 2 times, most recently from 1eb0a5b to 5b24285 Compare April 18, 2026 01:12
Introduces a Foundry Toolbox integration: FoundryChatClient gains a
get_toolbox() helper plus select_toolbox_tools(), normalize_tools in
the core package flattens tool-collection wrappers (ToolboxVersionObject
and generic iterables, while leaving Pydantic BaseModel instances
alone), and the new agent_framework.foundry namespace re-exports the
toolbox helpers. Ships with unit tests, a sample, and a design doc.

azure-ai-projects is pinned to the public >=2.0.0,<3.0 range and the
lockfile resolves from public PyPI. The toolbox test module skips when
Toolbox* types are unavailable so CI stays green until the public 2.1.0
SDK lands. OMC tooling directories (.omc/, .omx/) are gitignored.
@moonbox3 moonbox3 force-pushed the py-foundry-toolbox branch from 5b24285 to 6716549 Compare April 20, 2026 01:09
Comment thread docs/decisions/0025-foundry-toolbox-support.md
Comment thread docs/decisions/0025-foundry-toolbox-support.md Outdated
Comment thread docs/decisions/0025-foundry-toolbox-support.md
Comment thread docs/decisions/0025-foundry-toolbox-support.md
Comment thread docs/decisions/0025-foundry-toolbox-support.md
Comment thread docs/decisions/0025-foundry-toolbox-support.md Outdated
Comment thread docs/decisions/0025-foundry-toolbox-support.md
Comment thread docs/decisions/0025-foundry-toolbox-support.md
Comment thread python/samples/02-agents/context_providers/foundry_toolbox_context_provider.py Outdated
@moonbox3 moonbox3 enabled auto-merge April 20, 2026 23:50
@moonbox3 moonbox3 added this pull request to the merge queue Apr 20, 2026
Merged via the queue into microsoft:main with commit 04aaf0c Apr 21, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Usage: [Issues, PRs], Target: Single agent documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants