Python: Fix Foundry hosted session SDK calls - #6862
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes Python Foundry hosted-session creation against azure-ai-projects==2.2.0 by removing reliance on an SDK agent-name lookup API that no longer exists and by aligning the session creation kwargs with the SDK’s current parameter name.
Changes:
- Removed the preview-only SDK agent lookup from
get_agent_version()when no explicitagent_versionis configured (now returnsNoneunlessagent_versionis set). - Updated hosted session creation to pass
user_isolation_key(instead ofisolation_key) toproject_client.beta.agents.create_session(...). - Added/updated unit tests to validate the new behavior (no SDK lookup required; updated session creation kwargs assertion).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| python/packages/foundry/agent_framework_foundry/_agent.py | Stops SDK-based agent-name version resolution and updates hosted session creation to use user_isolation_key. |
| python/packages/foundry/tests/foundry/test_foundry_agent.py | Adds regression coverage for missing SDK lookup method and updates the hosted session kwargs assertion to user_isolation_key. |
| raise TypeError("Foundry agent details did not include a latest version string.") | ||
| self.agent_version = agent_version | ||
| return agent_version | ||
| return None |
There was a problem hiding this comment.
Could we keep resolving a version through project_client.agents.get(...), or otherwise always supply a valid VersionIndicator here? With the pinned azure-ai-projects==2.2.0, beta.agents.create_session() treats version_indicator as required and raises TypeError("missing required argument: version_indicator") before sending a request, so the reported HostedAgent path with no explicit agent_version still crashes. The new test stops at get_agent_version(), while the session-creation test supplies agent_version="1.0", so neither exercises this failure path.
|
Tao Chen (@TaoChenOSU) is this PR still required? |
|
There's been a lot of churn in the Foundry related projects these days. Tao Chen (@TaoChenOSU) will be checking if this is still needed. |
Motivation & Context
Hosted FoundryAgent sessions currently fail against
azure-ai-projects==2.2.0whenallow_preview=Trueand anisolation_keyis provided. The Foundry SDK no longer exposes the agent-name.get(...)lookup used byget_agent_version(), andcreate_session(...)expectsuser_isolation_keyinstead ofisolation_key.Description & Review Guide
project_client.beta.agents.get(...)API when no explicitagent_versionis configured.user_isolation_keytoproject_client.beta.agents.create_session(...).agent_versionbehavior when callers provide one.uv run pytest tests/foundry/test_foundry_agent.py::test_raw_foundry_agent_chat_client_get_agent_version_skips_sdk_lookup tests/foundry/test_foundry_agent.py::test_raw_foundry_agent_prepare_run_context_creates_service_session_from_isolation_key -quv run pytest tests/foundry/test_foundry_agent.py -quv run poe test -P foundry -m "not integration"uv run ruff check packages/foundry/agent_framework_foundry/_agent.py packages/foundry/tests/foundry/test_foundry_agent.pyuv run ruff format --check packages/foundry/agent_framework_foundry/_agent.py packages/foundry/tests/foundry/test_foundry_agent.pyuv run pyright packages/foundry/agent_framework_foundry/_agent.pyversion_indicatorwhen callers do not passagent_version.Related Issue
Fixes #6857
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.