From 9d19b1ae8a212b9fb38e0c175659c18d55a1553f Mon Sep 17 00:00:00 2001 From: Copilot Date: Mon, 27 Apr 2026 09:52:43 +0000 Subject: [PATCH 1/4] Add requirements.txt and .env.example to a2a sample Beginners following the a2a/ sample had no pip-based install path: the directory lacked requirements.txt and .env.example, unlike every other 04-hosting/ sample. - Add requirements.txt with editable local package paths matching the pattern used in azure_functions/ and similar hosting samples - Add .env.example documenting FOUNDRY_PROJECT_ENDPOINT, FOUNDRY_MODEL, and A2A_AGENT_HOST - Update README Quick Start to cover both pip (.venv) and uv workflows Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- python/samples/04-hosting/a2a/.env.example | 6 +++++ python/samples/04-hosting/a2a/README.md | 23 +++++++++++++++++++ .../samples/04-hosting/a2a/requirements.txt | 23 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 python/samples/04-hosting/a2a/.env.example create mode 100644 python/samples/04-hosting/a2a/requirements.txt diff --git a/python/samples/04-hosting/a2a/.env.example b/python/samples/04-hosting/a2a/.env.example new file mode 100644 index 0000000000..d1a8feef9e --- /dev/null +++ b/python/samples/04-hosting/a2a/.env.example @@ -0,0 +1,6 @@ +# Azure AI Foundry Configuration (required for a2a_server.py and a2a_agent_as_function_tools.py) +FOUNDRY_PROJECT_ENDPOINT=https://your-project.services.ai.azure.com/api/projects/your-project +FOUNDRY_MODEL=gpt-4o + +# A2A Client Configuration (required for agent_with_a2a.py and a2a_agent_as_function_tools.py) +A2A_AGENT_HOST=http://localhost:5001/ diff --git a/python/samples/04-hosting/a2a/README.md b/python/samples/04-hosting/a2a/README.md index aca25a4dab..4843453b45 100644 --- a/python/samples/04-hosting/a2a/README.md +++ b/python/samples/04-hosting/a2a/README.md @@ -42,6 +42,29 @@ All commands below should be run from this directory: cd python/samples/04-hosting/a2a ``` +### 0. Install Dependencies + +Copy `.env.example` to `.env` and fill in your values: + +```powershell +copy .env.example .env +``` + +**Option A — pip (standard):** + +```powershell +python -m venv .venv +.venv\Scripts\Activate.ps1 # Windows +# source .venv/bin/activate # macOS / Linux +pip install -r requirements.txt +``` + +**Option B — uv (from repo root):** + +```powershell +uv run python a2a_server.py --agent-type policy +``` + ### 1. Start the A2A Server Pick an agent type and start the server (each in its own terminal): diff --git a/python/samples/04-hosting/a2a/requirements.txt b/python/samples/04-hosting/a2a/requirements.txt new file mode 100644 index 0000000000..fe6e43a138 --- /dev/null +++ b/python/samples/04-hosting/a2a/requirements.txt @@ -0,0 +1,23 @@ +# Agent Framework packages +# To use the deployed version, uncomment the lines below and comment out the local installation lines +# agent-framework-a2a +# agent-framework-foundry + +# Local installation (for development and testing) +# Each package must be listed explicitly because pip doesn't resolve uv workspace sources. +# Without explicit entries, pip would fetch transitive dependencies from PyPI instead of local source. +-e ../../../packages/core # Core framework - base dependency for all packages +-e ../../../packages/foundry # Foundry support - dependency for FoundryChatClient in a2a_server.py +-e ../../../packages/a2a # A2A integration - provides A2AAgent and a2a-sdk + +# Azure authentication +azure-identity + +# A2A server runtime +uvicorn + +# HTTP client used by A2A client samples +httpx + +# Environment variable loading +python-dotenv From 36749a88ce0d56dba1047eb65a8291126ab221c0 Mon Sep 17 00:00:00 2001 From: Copilot Date: Mon, 27 Apr 2026 10:00:46 +0000 Subject: [PATCH 2/4] Python: Add `requirements.txt` and `.env.example` to the `a2a/` sample for pip-based setup Fixes #5395 --- python/packages/core/agent_framework/__init__.py | 2 +- python/packages/core/tests/core/test_exceptions.py | 1 - .../01-get-started/05_functional_workflow_with_agents.py | 2 ++ python/samples/01-get-started/06_functional_workflow_basics.py | 2 ++ python/samples/04-hosting/a2a/agent_framework_to_a2a.py | 2 +- 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/python/packages/core/agent_framework/__init__.py b/python/packages/core/agent_framework/__init__.py index a098159a50..13d7bade00 100644 --- a/python/packages/core/agent_framework/__init__.py +++ b/python/packages/core/agent_framework/__init__.py @@ -277,11 +277,11 @@ "USER_AGENT_TELEMETRY_DISABLED_ENV_VAR", "Agent", "AgentContext", - "AgentFrameworkException", "AgentEvalConverter", "AgentExecutor", "AgentExecutorRequest", "AgentExecutorResponse", + "AgentFrameworkException", "AgentMiddleware", "AgentMiddlewareLayer", "AgentMiddlewareTypes", diff --git a/python/packages/core/tests/core/test_exceptions.py b/python/packages/core/tests/core/test_exceptions.py index 47b3a53197..b22faedc1e 100644 --- a/python/packages/core/tests/core/test_exceptions.py +++ b/python/packages/core/tests/core/test_exceptions.py @@ -2,7 +2,6 @@ """Tests for AgentFrameworkException inner_exception handling.""" -import pytest from agent_framework import AgentFrameworkException diff --git a/python/samples/01-get-started/05_functional_workflow_with_agents.py b/python/samples/01-get-started/05_functional_workflow_with_agents.py index 05e5f2637f..7ffb0165c4 100644 --- a/python/samples/01-get-started/05_functional_workflow_with_agents.py +++ b/python/samples/01-get-started/05_functional_workflow_with_agents.py @@ -37,6 +37,8 @@ async def poem_workflow(topic: str) -> str: poem = (await writer.run(f"Write a poem about: {topic}")).text review = (await reviewer.run(f"Review this poem: {poem}")).text return f"Poem:\n{poem}\n\nReview: {review}" + + # diff --git a/python/samples/01-get-started/06_functional_workflow_basics.py b/python/samples/01-get-started/06_functional_workflow_basics.py index 8033a7ac4e..a679e70a99 100644 --- a/python/samples/01-get-started/06_functional_workflow_basics.py +++ b/python/samples/01-get-started/06_functional_workflow_basics.py @@ -36,6 +36,8 @@ async def text_workflow(text: str) -> str: """Uppercase the text, then reverse it.""" upper = await to_upper_case(text) return await reverse_text(upper) + + # diff --git a/python/samples/04-hosting/a2a/agent_framework_to_a2a.py b/python/samples/04-hosting/a2a/agent_framework_to_a2a.py index 0693b61b0a..6e68f21a02 100644 --- a/python/samples/04-hosting/a2a/agent_framework_to_a2a.py +++ b/python/samples/04-hosting/a2a/agent_framework_to_a2a.py @@ -51,7 +51,7 @@ agent = Agent( client=OpenAIChatClient(), name="Europe Travel Agent", - instructions="You are a helpful Europe Travel Agent. You can help users search and book flights and hotels across Europe." + instructions="You are a helpful Europe Travel Agent. You can help users search and book flights and hotels across Europe.", ) request_handler = DefaultRequestHandler( From 296b6c30828d26f81b9efa3bacfd82efd07b5e2f Mon Sep 17 00:00:00 2001 From: Copilot Date: Mon, 27 Apr 2026 10:07:18 +0000 Subject: [PATCH 3/4] fix(a2a-sample): address PR review feedback for issue #5395 - Remove 'from repo root' wording from Option B uv heading in README to avoid contradicting the 'run from this directory' instruction - Fix A2A_AGENT_HOST default in .env.example from 5001 to 5000 to match function-tools flow; add clarifying comments about port usage - Add note for pip users explaining they can replace 'uv run python' with 'python' once the virtual environment is activated Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- python/samples/04-hosting/a2a/.env.example | 4 +++- python/samples/04-hosting/a2a/README.md | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/python/samples/04-hosting/a2a/.env.example b/python/samples/04-hosting/a2a/.env.example index d1a8feef9e..91f0530fcd 100644 --- a/python/samples/04-hosting/a2a/.env.example +++ b/python/samples/04-hosting/a2a/.env.example @@ -3,4 +3,6 @@ FOUNDRY_PROJECT_ENDPOINT=https://your-project.services.ai.azure.com/api/projects FOUNDRY_MODEL=gpt-4o # A2A Client Configuration (required for agent_with_a2a.py and a2a_agent_as_function_tools.py) -A2A_AGENT_HOST=http://localhost:5001/ +# The function-tools flow uses http://localhost:5000/ in the sample docs/output. +# Update this value if you start a different local A2A server instance on another port. +A2A_AGENT_HOST=http://localhost:5000/ diff --git a/python/samples/04-hosting/a2a/README.md b/python/samples/04-hosting/a2a/README.md index 4843453b45..bc76d124f6 100644 --- a/python/samples/04-hosting/a2a/README.md +++ b/python/samples/04-hosting/a2a/README.md @@ -59,7 +59,7 @@ python -m venv .venv pip install -r requirements.txt ``` -**Option B — uv (from repo root):** +**Option B — uv:** ```powershell uv run python a2a_server.py --agent-type policy @@ -67,6 +67,8 @@ uv run python a2a_server.py --agent-type policy ### 1. Start the A2A Server +> **Note (Option A — pip users):** Replace `uv run python` with `python` in all `uv run` commands below (e.g. `python a2a_server.py ...`). `uv` is not required once the virtual environment is activated. + Pick an agent type and start the server (each in its own terminal): ```powershell From 399202951972d13ff259dc20b14c58997c79894f Mon Sep 17 00:00:00 2001 From: Copilot Date: Mon, 27 Apr 2026 10:11:23 +0000 Subject: [PATCH 4/4] =?UTF-8?q?Address=20review=20feedback=20for=20#5395:?= =?UTF-8?q?=20Python:=20[Samples][Python]=20a2a/=20sample=20missing=20requ?= =?UTF-8?q?irements.txt=20=E2=80=94=20beginners=20cannot=20install=20depen?= =?UTF-8?q?dencies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/packages/core/tests/core/test_exceptions.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/packages/core/tests/core/test_exceptions.py b/python/packages/core/tests/core/test_exceptions.py index b22faedc1e..bf164cdbe2 100644 --- a/python/packages/core/tests/core/test_exceptions.py +++ b/python/packages/core/tests/core/test_exceptions.py @@ -2,7 +2,6 @@ """Tests for AgentFrameworkException inner_exception handling.""" - from agent_framework import AgentFrameworkException