Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
echo "language=$language" >> "$GITHUB_OUTPUT"
echo "sample=$SAMPLE dir=$dir -> language=$language"

# Toolchain setup — GH-native setup-* actions, versions pinned to match the P1.4 audit.
# Toolchain setup — versions pinned to the supported sample runtime floor.
# Each installs ONLY for the language this leg actually needs (barren-by-default).
- name: Set up .NET
if: steps.lang.outputs.language == 'csharp'
Expand All @@ -103,6 +103,12 @@ jobs:
with:
python-version: '3.12'

- name: Set up uv
if: steps.lang.outputs.language == 'python'
uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0
with:
version: '0.11.7'

- name: Set up Node.js
if: steps.lang.outputs.language == 'typescript'
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
Expand Down Expand Up @@ -283,6 +289,11 @@ jobs:
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.12'
- name: Set up uv
if: needs.detect.outputs.has_changes == 'true' && steps.langs.outputs.has_python == 'true'
uses: astral-sh/setup-uv@bec219d24cd3e171d82865faccec33120bb574f4 # v10.1.0
with:
version: '0.11.7'
- name: Set up Node.js
if: needs.detect.outputs.has_changes == 'true' && steps.langs.outputs.has_node == 'true'
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
Expand Down
54 changes: 50 additions & 4 deletions samples/python/hosted-agents/agent-framework/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,36 @@ The extension also adds an **Agent Inspector** UI for chatting with a hosted age

1. **Foundry Toolkit VS Code Extension** — [install from the VS Code marketplace](https://learn.microsoft.com/en-us/azure/foundry/agents/quickstarts/quickstart-hosted-agent?pivots=vscode) and sign in to Azure.
2. For debugging Python in VS Code, install the **[Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python)** extension pack.
3. Python 3.10 or later. The uv setup option requires Python 3.13 or later.
4. [pipx](https://pipx.pypa.io/stable/installation/) if you use the uv setup option.

#### Set up the Python virtual environment

Use the setup option that matches the dependency files included with the sample.

**Using `requirements.txt`**

- Open the Command Palette (`Ctrl+Shift+P`) and run **Python: Create Environment...** (or **Python: Select Interpreter** to use an existing one).
- Install dependencies: `pip install uv && uv pip install -r requirements.txt`

**Using uv**

Install uv outside the project environment, then let uv create and synchronize the locked environment:

```bash
pipx install uv==0.11.7
uv sync --frozen --python 3.13
```

Open the Command Palette (`Ctrl+Shift+P`), run **Python: Select Interpreter**, and select the `.venv` created by uv.

#### Run and debug with F5 (recommended)

Press **F5** to start the agent. The agent starts and the **Agent Inspector** opens automatically.

#### Or run manually, then open the Inspector

Once the agent is running on `http://localhost:8088/` (via [`azd ai agent run`](#using-azd) or [`python main.py`](#using-python)):
Once the agent is running on `http://localhost:8088/` (via [`azd ai agent run`](#using-azd) or one of the run options under [Using `python`](#using-python)):

1. Open the Command Palette (`Ctrl+Shift+P`) and run **Foundry Toolkit: Open Agent Inspector**.
2. The Inspector auto-connects to the running agent.
Expand All @@ -189,7 +206,8 @@ Once the agent is running on `http://localhost:8088/` (via [`azd ai agent run`](
1. An existing Foundry project
2. A deployed model in your Foundry project
3. Azure CLI installed and authenticated
4. Python 3.10 or later
4. Python 3.10 or later. The uv setup option requires Python 3.13 or later.
5. [pipx](https://pipx.pypa.io/stable/installation/) if you use the uv setup option

#### Running the Agent Host with Python

Expand All @@ -202,6 +220,10 @@ cd foundry-samples/samples/python/hosted-agents/agent-framework/responses/01-bas

#### Environment setup

Use the setup option that matches the dependency files included with the sample.

**Using `requirements.txt`**

1. Navigate to the sample's service directory (the `project` path in its `azure.yaml`). Create a virtual environment:

```bash
Expand All @@ -220,20 +242,44 @@ cd foundry-samples/samples/python/hosted-agents/agent-framework/responses/01-bas
pip install -r requirements.txt
```

3. Create a `.env` file with your Foundry configuration following the `.env.example` file in the sample.
**Using uv**

4. Make sure you are logged in with the Azure CLI:
1. Install uv outside the project environment:

```bash
pipx install uv==0.11.7
```

2. Navigate to the sample's service directory (the `project` path in its `azure.yaml`), then create and synchronize the locked environment:

```bash
uv sync --frozen --python 3.13
```

After setting up the environment:

1. Create a `.env` file with your Foundry configuration following the `.env.example` file in the sample.

2. Make sure you are logged in with the Azure CLI:

```bash
az login
```

#### Running the Agent Host

With the `requirements.txt` environment activated, run:

```bash
python main.py
```

Or with uv, run:

```bash
uv run --no-sync python main.py
```

Right now, the agent host should be running on `http://localhost:8088`

#### Invoking the Agent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
FROM python:3.12-slim
FROM ghcr.io/astral-sh/uv:0.11.7 AS uv
FROM python:3.13-slim

WORKDIR /app
COPY --from=uv /uv /uvx /bin/

COPY . user_agent/
WORKDIR /app/user_agent
COPY pyproject.toml uv.lock uv.toml ./
RUN uv sync --frozen --no-dev --no-install-project

RUN if [ -f requirements.txt ]; then \
pip install -r requirements.txt; \
else \
echo "No requirements.txt found"; \
fi
COPY . .

EXPOSE 8088

Expand All @@ -23,7 +21,7 @@ EXPOSE 8088
# container start.
# PYTHONDONTWRITEBYTECODE is cleared for these commands only: it blocks
# bytecode *writes*, not *reads*, so images that set it still benefit.
RUN PYTHONDONTWRITEBYTECODE= python -m compileall -q $(python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \
PYTHONDONTWRITEBYTECODE= python -m compileall -q .
RUN PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q $(.venv/bin/python -c "import sysconfig as s; print(s.get_paths()['stdlib'], s.get_paths()['purelib'])") || true; \
PYTHONDONTWRITEBYTECODE= .venv/bin/python -m compileall -q -x '[.]venv' .

CMD ["python", "main.py"]
CMD ["/app/user_agent/.venv/bin/python", "main.py"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[project]
name = "agent-framework-a2a-caller-responses"
version = "0.1.0"
description = "A Microsoft Foundry hosted agent built with Microsoft Agent Framework."
requires-python = ">=3.13"
dependencies = [
"agent-framework-foundry",
"agent-framework-foundry-hosting>=1.0.0b260813",
"debugpy",
]

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: A2A Delegation Hosted Agent
description: Hosted Agent Framework sample that delegates tasks to a remote agent over the Agent-to-Agent (A2A) protocol via a Foundry Toolbox A2A connection.

build: "pip install -r requirements.txt"
validate: "python -m py_compile *.py"
build: "uv sync --frozen --no-dev --no-install-project"
validate: "uv run --no-sync python -m compileall -q ."
Loading
Loading