Skip to content

Commit 9b22ecd

Browse files
moonbox3CopilotCopilot
authored
Python: Add requirements.txt and .env.example to the a2a/ sample for pip-based setup (#5510)
* 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: Add `requirements.txt` and `.env.example` to the `a2a/` sample for pip-based setup Fixes #5395 * 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> * Address review feedback for #5395: Python: [Samples][Python] a2a/ sample missing requirements.txt — beginners cannot install dependencies --------- Co-authored-by: Copilot <copilot@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2eb0705 commit 9b22ecd

8 files changed

Lines changed: 62 additions & 4 deletions

File tree

python/packages/core/agent_framework/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,11 @@
277277
"USER_AGENT_TELEMETRY_DISABLED_ENV_VAR",
278278
"Agent",
279279
"AgentContext",
280-
"AgentFrameworkException",
281280
"AgentEvalConverter",
282281
"AgentExecutor",
283282
"AgentExecutorRequest",
284283
"AgentExecutorResponse",
284+
"AgentFrameworkException",
285285
"AgentMiddleware",
286286
"AgentMiddlewareLayer",
287287
"AgentMiddlewareTypes",

python/packages/core/tests/core/test_exceptions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
"""Tests for AgentFrameworkException inner_exception handling."""
44

5-
import pytest
6-
75
from agent_framework import AgentFrameworkException
86

97

python/samples/01-get-started/05_functional_workflow_with_agents.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ async def poem_workflow(topic: str) -> str:
3737
poem = (await writer.run(f"Write a poem about: {topic}")).text
3838
review = (await reviewer.run(f"Review this poem: {poem}")).text
3939
return f"Poem:\n{poem}\n\nReview: {review}"
40+
41+
4042
# </create_workflow>
4143

4244

python/samples/01-get-started/06_functional_workflow_basics.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ async def text_workflow(text: str) -> str:
3636
"""Uppercase the text, then reverse it."""
3737
upper = await to_upper_case(text)
3838
return await reverse_text(upper)
39+
40+
3941
# </create_workflow>
4042

4143

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Azure AI Foundry Configuration (required for a2a_server.py and a2a_agent_as_function_tools.py)
2+
FOUNDRY_PROJECT_ENDPOINT=https://your-project.services.ai.azure.com/api/projects/your-project
3+
FOUNDRY_MODEL=gpt-4o
4+
5+
# A2A Client Configuration (required for agent_with_a2a.py and a2a_agent_as_function_tools.py)
6+
# The function-tools flow uses http://localhost:5000/ in the sample docs/output.
7+
# Update this value if you start a different local A2A server instance on another port.
8+
A2A_AGENT_HOST=http://localhost:5000/

python/samples/04-hosting/a2a/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,33 @@ All commands below should be run from this directory:
4242
cd python/samples/04-hosting/a2a
4343
```
4444

45+
### 0. Install Dependencies
46+
47+
Copy `.env.example` to `.env` and fill in your values:
48+
49+
```powershell
50+
copy .env.example .env
51+
```
52+
53+
**Option A — pip (standard):**
54+
55+
```powershell
56+
python -m venv .venv
57+
.venv\Scripts\Activate.ps1 # Windows
58+
# source .venv/bin/activate # macOS / Linux
59+
pip install -r requirements.txt
60+
```
61+
62+
**Option B — uv:**
63+
64+
```powershell
65+
uv run python a2a_server.py --agent-type policy
66+
```
67+
4568
### 1. Start the A2A Server
4669

70+
> **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.
71+
4772
Pick an agent type and start the server (each in its own terminal):
4873

4974
```powershell

python/samples/04-hosting/a2a/agent_framework_to_a2a.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
agent = Agent(
5252
client=OpenAIChatClient(),
5353
name="Europe Travel Agent",
54-
instructions="You are a helpful Europe Travel Agent. You can help users search and book flights and hotels across Europe."
54+
instructions="You are a helpful Europe Travel Agent. You can help users search and book flights and hotels across Europe.",
5555
)
5656

5757
request_handler = DefaultRequestHandler(
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Agent Framework packages
2+
# To use the deployed version, uncomment the lines below and comment out the local installation lines
3+
# agent-framework-a2a
4+
# agent-framework-foundry
5+
6+
# Local installation (for development and testing)
7+
# Each package must be listed explicitly because pip doesn't resolve uv workspace sources.
8+
# Without explicit entries, pip would fetch transitive dependencies from PyPI instead of local source.
9+
-e ../../../packages/core # Core framework - base dependency for all packages
10+
-e ../../../packages/foundry # Foundry support - dependency for FoundryChatClient in a2a_server.py
11+
-e ../../../packages/a2a # A2A integration - provides A2AAgent and a2a-sdk
12+
13+
# Azure authentication
14+
azure-identity
15+
16+
# A2A server runtime
17+
uvicorn
18+
19+
# HTTP client used by A2A client samples
20+
httpx
21+
22+
# Environment variable loading
23+
python-dotenv

0 commit comments

Comments
 (0)