Python: Add requirements.txt and .env.example to the a2a/ sample for pip-based setup#5510
Conversation
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>
…e for pip-based setup Fixes microsoft#5395
moonbox3
left a comment
There was a problem hiding this comment.
Automated Code Review
Reviewers: 4 | Confidence: 97% | Result: All clear
Reviewed: Correctness, Security Reliability, Test Coverage, Design Approach
Automated review by moonbox3's agents
There was a problem hiding this comment.
Automated Code Review
Reviewers: 4 | Confidence: 95%
✓ Correctness
This PR contains only formatting and housekeeping changes: alphabetical reordering of an
__all__entry, removal of an unusedpytestimport, PEP 8 blank-line fixes, a trailing comma addition, and new documentation/configuration files (.env.example,README.mdinstall section,requirements.txt). All changes are correct and introduce no functional or correctness issues. The relative-epaths inrequirements.txtresolve to existing package directories, and the removedpytestimport is confirmed unused in the test file.
✓ Security Reliability
This is a low-risk, mostly cosmetic PR: alphabetical sort of all, removal of an unused pytest import, whitespace fixes in samples, a trailing comma fix, new sample documentation (README install steps, .env.example), and a new requirements.txt for the a2a sample. The .env file is already covered by the root .gitignore (line 135), and the .env.example contains only placeholder values. No security or reliability issues found.
✓ Test Coverage
This is a cleanup and documentation PR: alphabetical reordering of all in init.py, removal of an unused pytest import in test_exceptions.py, whitespace formatting in sample files, a trailing comma fix, and new sample support files (.env.example, requirements.txt, README updates). There are no behavioral code changes, so no new tests are needed. The removal of the unused
import pytestin test_exceptions.py is correct — the file uses only bareassertstatements and no pytest APIs.
✗ Design Approach
The only design-level problem I found is in the new A2A sample bootstrap: it introduces a local editable-install workflow, but it still leaves one of the README’s documented entry points (
agent_framework_to_a2a.py) outside that local source set. That means the sample setup now mixes local repo packages with a transitive PyPI install for the OpenAI integration, which undercuts the stated goal of using local sources for development/testing and makes the onboarding path inconsistent.
Flagged Issues
- The new
python/samples/04-hosting/a2a/requirements.txtdoes not include the local OpenAI package even though the README still tells users to runagent_framework_to_a2a.pyand that file importsOpenAIChatClient(python/samples/04-hosting/a2a/agent_framework_to_a2a.py:14). Becauseagent-framework-foundrydepends onagent-framework-openaitransitively (python/packages/foundry/pyproject.toml:25-30), pip will pull that package from PyPI instead of the repo, so the new 'local installation' path is only half-local.
Automated review by moonbox3's agents
There was a problem hiding this comment.
Pull request overview
This PR makes the Python a2a/ hosting sample installable via standard pip tooling by adding missing dependency and environment-variable templates, aligning it with other 04-hosting/ samples.
Changes:
- Added
python/samples/04-hosting/a2a/requirements.txtwith editable installs for local packages plus required PyPI deps. - Added
python/samples/04-hosting/a2a/.env.exampleand updated the sample README with a dependency-installation step. - Minor formatting/cleanup tweaks in a few Python sample/core files (trailing comma, blank lines, import/export ordering).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| python/samples/04-hosting/a2a/requirements.txt | Introduces pip-friendly dependency installation for the a2a/ sample (including local editable installs). |
| python/samples/04-hosting/a2a/.env.example | Documents required env vars for running the A2A server/client/function-tools samples. |
| python/samples/04-hosting/a2a/README.md | Adds an “Install Dependencies” step and references the new .env.example. |
| python/samples/04-hosting/a2a/agent_framework_to_a2a.py | Small syntax/formatting fix (trailing comma). |
| python/samples/01-get-started/06_functional_workflow_basics.py | Adds blank lines (formatting). |
| python/samples/01-get-started/05_functional_workflow_with_agents.py | Adds blank lines (formatting). |
| python/packages/core/tests/core/test_exceptions.py | Removes an unused import. |
| python/packages/core/agent_framework/init.py | Adjusts __all__ export ordering for AgentFrameworkException. |
- 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>
… a2a/ sample missing requirements.txt — beginners cannot install dependencies
moonbox3
left a comment
There was a problem hiding this comment.
Automated Code Review
Reviewers: 4 | Confidence: 99% | Result: All clear
Reviewed: Correctness, Security Reliability, Test Coverage, Design Approach
Automated review by moonbox3's agents
Motivation and Context
The
python/samples/04-hosting/a2a/directory shipped with norequirements.txtor.env.example, making it impossible for beginers to install dependencies with standardpiptooling. Every other sample under04-hosting/provides these files, leaving thea2a/sample as an inconsistent outlier that silently fails onpip install -r requirements.txt.Fixes #5395
Description
Added
requirements.txtthat lists the required local editable installs (core,foundry,a2a) alongside PyPI packages (uvicorn,httpx,azure-identity,python-dotenv), following the same pattern used by thedurabletask/andazure_functions/sibling samples. Added.env.exampledocumenting the three required environment variables (FOUNDRY_PROJECT_ENDPOINT,FOUNDRY_MODEL,A2A_AGENT_HOST) so users no longer have to read source code to discover them. The README was also updated with a new "Install Dependencies" step that shows both the standardpipworkflow and the existinguvpath.Contribution Checklist