Skip to content

Python: Add requirements.txt and .env.example to the a2a/ sample for pip-based setup#5510

Merged
moonbox3 merged 4 commits intomicrosoft:mainfrom
moonbox3:agent/fix-5395-1
Apr 27, 2026
Merged

Python: Add requirements.txt and .env.example to the a2a/ sample for pip-based setup#5510
moonbox3 merged 4 commits intomicrosoft:mainfrom
moonbox3:agent/fix-5395-1

Conversation

@moonbox3
Copy link
Copy Markdown
Contributor

Motivation and Context

The python/samples/04-hosting/a2a/ directory shipped with no requirements.txt or .env.example, making it impossible for beginers to install dependencies with standard pip tooling. Every other sample under 04-hosting/ provides these files, leaving the a2a/ sample as an inconsistent outlier that silently fails on pip install -r requirements.txt.

Fixes #5395

Description

Added requirements.txt that lists the required local editable installs (core, foundry, a2a) alongside PyPI packages (uvicorn, httpx, azure-identity, python-dotenv), following the same pattern used by the durabletask/ and azure_functions/ sibling samples. Added .env.example documenting 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 standard pip workflow and the existing uv path.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Note: PR autogenerated by moonbox3's agent

Copilot and others added 2 commits April 27, 2026 09:52
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>
Copilot AI review requested due to automatic review settings April 27, 2026 10:00
@moonbox3 moonbox3 self-assigned this Apr 27, 2026
@moonbox3 moonbox3 added documentation Improvements or additions to documentation python labels Apr 27, 2026
@moonbox3
Copy link
Copy Markdown
Contributor Author

moonbox3 commented Apr 27, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
TOTAL29865347988% 
report-only-changed-files is enabled. No files were changed during this commit :)

Python Unit Test Overview

Tests Skipped Failures Errors Time
6026 30 💤 0 ❌ 0 🔥 1m 41s ⏱️

Copy link
Copy Markdown
Contributor Author

@moonbox3 moonbox3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 4 | Confidence: 97% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Design Approach


Automated review by moonbox3's agents

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 unused pytest import, PEP 8 blank-line fixes, a trailing comma addition, and new documentation/configuration files (.env.example, README.md install section, requirements.txt). All changes are correct and introduce no functional or correctness issues. The relative -e paths in requirements.txt resolve to existing package directories, and the removed pytest import 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 pytest in test_exceptions.py is correct — the file uses only bare assert statements 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.txt does not include the local OpenAI package even though the README still tells users to run agent_framework_to_a2a.py and that file imports OpenAIChatClient (python/samples/04-hosting/a2a/agent_framework_to_a2a.py:14). Because agent-framework-foundry depends on agent-framework-openai transitively (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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.txt with editable installs for local packages plus required PyPI deps.
  • Added python/samples/04-hosting/a2a/.env.example and 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.

Comment thread python/samples/04-hosting/a2a/README.md Outdated
Comment thread python/samples/04-hosting/a2a/.env.example Outdated
Comment thread python/samples/04-hosting/a2a/README.md
Copilot and others added 2 commits April 27, 2026 10:07
- 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
Copy link
Copy Markdown
Contributor Author

@moonbox3 moonbox3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 4 | Confidence: 99% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Design Approach


Automated review by moonbox3's agents

@moonbox3 moonbox3 added this pull request to the merge queue Apr 27, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 27, 2026
@moonbox3 moonbox3 added this pull request to the merge queue Apr 27, 2026
Merged via the queue into microsoft:main with commit 9b22ecd Apr 27, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Samples][Python] a2a/ sample missing requirements.txt — beginners cannot install dependencies

4 participants