From c12927e7858af19b62606b88da5c7bfa7ef50a99 Mon Sep 17 00:00:00 2001 From: Copilot Date: Mon, 27 Apr 2026 06:58:42 +0000 Subject: [PATCH 1/4] docs(samples): recommend uv venv to avoid Windows ensurepip hang Replace bare 'python -m venv .venv' with 'uv venv .venv' as the recommended approach in azure_functions and foundry-hosted-agents READMEs. Add a note explaining that python -m venv can hang indefinitely on Windows with Microsoft Store Python due to a known ensurepip issue. This matches the pattern already used in a2a/README.md which uses uv run exclusively. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- python/samples/04-hosting/azure_functions/README.md | 8 ++++++-- python/samples/04-hosting/foundry-hosted-agents/README.md | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/python/samples/04-hosting/azure_functions/README.md b/python/samples/04-hosting/azure_functions/README.md index cd410771c6..0580dee843 100644 --- a/python/samples/04-hosting/azure_functions/README.md +++ b/python/samples/04-hosting/azure_functions/README.md @@ -19,18 +19,22 @@ All of these samples are set up to run in Azure Functions. Azure Functions has a ### 2. Create and activate a virtual environment +Using [uv](https://docs.astral.sh/uv/) (recommended): + **Windows (PowerShell):** ```powershell -python -m venv .venv +uv venv .venv .venv\Scripts\Activate.ps1 ``` **Linux/macOS:** ```bash -python -m venv .venv +uv venv .venv source .venv/bin/activate ``` +> **Note:** `python -m venv .venv` also works, but can hang indefinitely on Windows with Microsoft Store Python due to a known `ensurepip` issue. Use `uv venv .venv` to avoid this. + ### 3. Running the samples - [Start the Azurite emulator](https://learn.microsoft.com/en-us/azure/storage/common/storage-install-azurite?tabs=npm%2Cblob-storage#run-azurite) diff --git a/python/samples/04-hosting/foundry-hosted-agents/README.md b/python/samples/04-hosting/foundry-hosted-agents/README.md index dcb7dcd24d..c930d1d928 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/README.md +++ b/python/samples/04-hosting/foundry-hosted-agents/README.md @@ -6,11 +6,13 @@ Read more about Foundry Hosted Agents [here](https://learn.microsoft.com/en-us/a ## Environment setup -1. Navigate to the sample directory you want to run. For example: +1. Navigate to the sample directory you want to run. For example, create and activate a virtual environment using [uv](https://docs.astral.sh/uv/) (recommended): ```bash - python -m venv .venv + uv venv .venv + ``` + ```bash # Windows .venv\Scripts\Activate @@ -18,6 +20,8 @@ Read more about Foundry Hosted Agents [here](https://learn.microsoft.com/en-us/a source .venv/bin/activate ``` + > **Note:** `python -m venv .venv` also works, but can hang indefinitely on Windows with Microsoft Store Python due to a known `ensurepip` issue. Use `uv venv .venv` to avoid this. + 2. Install dependencies: ```bash From a8e3214494837dd1b4ee25af2a240a10bee7865e Mon Sep 17 00:00:00 2001 From: Copilot Date: Mon, 27 Apr 2026 07:07:15 +0000 Subject: [PATCH 2/4] Python: docs(python/samples): recommend `uv venv` and document Windows ensurepip hang workaround Fixes #5401 --- 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 569d0b0f54db5398f7152cf9ef647e793e098e58 Mon Sep 17 00:00:00 2001 From: Copilot Date: Mon, 27 Apr 2026 07:10:28 +0000 Subject: [PATCH 3/4] fix: correct Windows venv activation commands in foundry-hosted-agents README (#5401) Split the Windows activation section into separate PowerShell (.venv\Scripts\Activate.ps1) and Command Prompt (.venv\Scripts\activate.bat) instructions, replacing the incorrect extensionless `Activate` path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- python/samples/04-hosting/foundry-hosted-agents/README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/samples/04-hosting/foundry-hosted-agents/README.md b/python/samples/04-hosting/foundry-hosted-agents/README.md index c930d1d928..609356eda0 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/README.md +++ b/python/samples/04-hosting/foundry-hosted-agents/README.md @@ -13,8 +13,11 @@ Read more about Foundry Hosted Agents [here](https://learn.microsoft.com/en-us/a ``` ```bash - # Windows - .venv\Scripts\Activate + # Windows (PowerShell) + .venv\Scripts\Activate.ps1 + + # Windows (Command Prompt) + .venv\Scripts\activate.bat # macOS/Linux source .venv/bin/activate From 8ad7bed6bcaf53176f676187b923783a967d33c2 Mon Sep 17 00:00:00 2001 From: Copilot Date: Mon, 27 Apr 2026 07:14:39 +0000 Subject: [PATCH 4/4] =?UTF-8?q?Address=20review=20feedback=20for=20#5401:?= =?UTF-8?q?=20Python:=20[Samples][Python]=20`python=20-m=20venv`=20hangs?= =?UTF-8?q?=20on=20Windows=20=E2=80=94=20READMEs=20should=20recommend=20uv?= =?UTF-8?q?=20or=20document=20workaround?= 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