Python: Update FHA with toolbox sample with more auth methods#6713
Python: Update FHA with toolbox sample with more auth methods#6713TaoChenOSU wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the Python Foundry Hosted Agents (Responses) “Foundry Toolbox” sample to match the newer toolbox deployment flow (standalone toolbox.yaml) and to demonstrate additional toolbox/MCP authentication modes via project connections.
Changes:
- Added a
toolbox.yamldefinition (plus helper scripts) to drive toolbox creation viaazd ai toolbox create. - Switched the sample to use
TOOLBOX_ENDPOINT(and updated manifest/agent yaml + env example accordingly). - Updated the sample README with end-to-end setup guidance for toolbox + multiple auth modes.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| python/samples/04-hosting/foundry-hosted-agents/responses/04_foundry_toolbox/toolbox.yaml | New toolbox definition containing multiple tool sources behind one MCP endpoint. |
| python/samples/04-hosting/foundry-hosted-agents/responses/04_foundry_toolbox/scripts/list-foundry-connectors.sh | New bash helper to list connectors / fetch connector details from the Foundry tools catalog. |
| python/samples/04-hosting/foundry-hosted-agents/responses/04_foundry_toolbox/scripts/list-foundry-connectors.ps1 | New PowerShell helper to list connectors / fetch connector details from the Foundry tools catalog. |
| python/samples/04-hosting/foundry-hosted-agents/responses/04_foundry_toolbox/requirements.txt | Updates dependencies to the Foundry-specific package set for this sample. |
| python/samples/04-hosting/foundry-hosted-agents/responses/04_foundry_toolbox/README.md | Expanded setup/run/deploy docs aligned to the new toolbox flow and auth modes. |
| python/samples/04-hosting/foundry-hosted-agents/responses/04_foundry_toolbox/main.py | Uses TOOLBOX_ENDPOINT and improves toolbox name derivation from endpoint URLs. |
| python/samples/04-hosting/foundry-hosted-agents/responses/04_foundry_toolbox/agent.yaml | Updates hosted-agent env var wiring to pass TOOLBOX_ENDPOINT. |
| python/samples/04-hosting/foundry-hosted-agents/responses/04_foundry_toolbox/agent.manifest.yaml | Updates manifest to accept TOOLBOX_ENDPOINT and removes embedded toolbox/connection provisioning. |
| python/samples/04-hosting/foundry-hosted-agents/responses/04_foundry_toolbox/.env.example | Renames env var to TOOLBOX_ENDPOINT. |
There was a problem hiding this comment.
Automated Code Review
Reviewers: 4 | Confidence: 89%
✓ Correctness
The PR is largely well-structured with good error handling improvements. Two correctness issues found: (1) the bash helper script uses
set -ewhich causes the script to exit before reaching the user-friendly error message whenazfails, and (2) a comment inagent.manifest.yamlusesmy-toolboxwhile the rest of the sample consistently usesagent-tools.
✓ Security Reliability
The PR is clean from a security and reliability standpoint. The shell script properly uses
jq --argfor safe JSON construction (avoiding the injection risk from the earlier review). The Python code properly validates environment variables and wraps KeyError in a descriptive ValueError. URL parsing usesurlsplitsafely. The PowerShell script usesConvertTo-Jsonfor proper serialization. No secrets are hardcoded, no unsafe deserialization, and resource management (httpx AsyncClient) uses async context managers correctly.
✓ Test Coverage
The PR renames the environment variable from FOUNDRY_TOOLBOX_ENDPOINT to TOOLBOX_ENDPOINT and changes the fallback error from KeyError to ValueError, but the existing test file (python/tests/samples/hosting/test_toolbox_endpoint.py) was not updated to match. Additionally, the new _toolbox_name_from_endpoint() helper has non-trivial URL parsing logic but no test coverage.
✓ Failure Modes
The Python code changes are well-structured with proper error handling (KeyError wrapped in ValueError with a clear message, safe URL parsing fallback). The shell script has one failure-mode issue where
set -ecauses the script to abort before reaching the user-friendly error message whenaztoken acquisition fails. The rest of the changes are config/documentation updates with no operational failure concerns.
Automated review by TaoChenOSU's agents
Motivation & Context
Addresses #5684
Toolbox deployment flow has changed significantly. This PR brings the latest to the FHA + Toolbox sample.
Description & Review Guide
Related Issue
Addressed part of #5684
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.