Skip to content

fix: restore Azure Foundry sample compatibility with a2a-sdk 1.x - #758

Open
anxkhn wants to merge 2 commits into
a2aproject:mainfrom
anxkhn:fix/azure-foundry-a2a-v1
Open

anxkhn wants to merge 2 commits into
a2aproject:mainfrom
anxkhn:fix/azure-foundry-a2a-v1

Conversation

@anxkhn

@anxkhn anxkhn commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Restore the Azure Foundry calendar sample's compatibility with the a2a-sdk==1.1.2 already selected by its lockfile. The executor, server, and example client still used removed 0.3 APIs, so the locked installation could not start.

Relates to #462. This updates only samples/python/agents/azureaifoundry_sdk/azurefoundryagent, not the other Python samples.

Changes

  • Replace legacy parts, task states, agent-card fields, application routes, and client requests with the A2A 1.x equivalents.
  • Announce the initial task before publishing updates and preserve task/context correlation. Reuse an Azure thread for follow-up messages within the same A2A context.
  • Use separate HTTP clients for regular and streaming conversations. Propagate transport and failed-task errors from the example client.
  • Reject unsupported cancellation instead of reporting a terminal state while the Azure run can continue.
  • Declare a2a-sdk>=1.1.2,<2.0, add twelve credential-free regression tests, and document setup and limitations.

The Azure backend is unchanged. This is not a migration to Azure AI Projects 2.x or the Responses API. Every resolved package version remains unchanged, including azure-ai-agents==1.0.0 and azure-ai-projects==1.0.0b11.

Proof of the fix

Before

Running the new regression suite against the original sample at 1d7b7be24971c60fe5019182c1d26b7e9ae137ed, with its locked dependencies installed, produces twelve errors. The first executor import fails before making an Azure request:

ImportError: cannot import name 'FilePart' from 'a2a.types'

After

From the sample directory:

uv sync --locked --python 3.12
uv run --python 3.12 --no-sync --with pytest==9.0.2 python -m pytest -q .
............                                                             [100%]
12 passed, 2 subtests passed

The tests exercise the real A2A SDK and in-process HTTP routes, mocking only the Foundry agent behavior. Coverage includes imports, server configuration, health and card discovery, protobuf parts, task-event order and correlation, context isolation/reuse, exceptions, cancellation rejection, and the complete example client in both messaging modes.

Additional local checks passed:

  • Ruff lint and formatting on all changed Python files, without rule exclusions.
  • Targeted Mypy and Pyright checks on the changed scripts and tests. Mypy uses protobuf stubs, explicit package bases, and silent import following for unchanged dependencies.
  • git diff --check.

The tests can also run without pytest:

uv run --python 3.12 --no-sync python -m unittest discover -s tests -v

Real Azure validation

Tested on November 16, 2026 using GPT-5 mini 2025-08-07, Global Standard, East US 2, through the existing classic Agents API.

Check Result
Included client, regular and streaming 10 provider runs completed
Follow-up context One reused conversation per messaging mode
Additional explicit UTC-window availability request 1 provider run completed
Tools exercised check_availability and get_upcoming_events
Total provider usage 12,826 prompt tokens, 8,008 completion tokens
Temporary lab cleanup Agents, threads, role assignments, deployment, and resource group removed; group absence verified

Provider terminal states and usage were checked, rather than treating HTTP 200 or response text as proof of completion. The broad availability questions in the example client prompted clarification, so the additional request supplied exact UTC timestamps to exercise the availability tool.

The calendar functions remain simulated. This did not access an Outlook calendar. No credentials, account identifiers, or raw authenticated logs are included.

Scope and limitations

The classic Azure calls and polling remain synchronous. Cancellation, automatic cleanup on server shutdown, and durable conversation storage are not implemented. Full monorepo tests and other Azure model configurations were not validated.

CI

Both upstream workflow jobs passed for 3a2c10fa0dff4f05fca4548e15ed7a6647d526e6:

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant