From cb4eb9ccb72b1a4363de2dc5d75b813bbac770c7 Mon Sep 17 00:00:00 2001 From: "huimiu[safe]" Date: Thu, 12 Mar 2026 21:06:19 +0800 Subject: [PATCH 01/10] Add two hosted agent samples using the foundry agent --- .../foundry_multiagent/.dockerignore | 51 ++++++ .../foundry_multiagent/.env.sample | 3 + .../foundry_multiagent/Dockerfile | 16 ++ .../foundry_multiagent/README.md | 159 +++++++++++++++++ .../foundry_multiagent/agent.yaml | 28 +++ .../hosted_agents/foundry_multiagent/main.py | 88 ++++++++++ .../foundry_multiagent/requirements.txt | 1 + .../foundry_singleagent/.dockerignore | 66 +++++++ .../foundry_singleagent/Dockerfile | 13 ++ .../foundry_singleagent/README.md | 166 ++++++++++++++++++ .../foundry_singleagent/agent.yaml | 31 ++++ .../hosted_agents/foundry_singleagent/main.py | 115 ++++++++++++ .../foundry_singleagent/requirements.txt | 8 + 13 files changed, 745 insertions(+) create mode 100644 python/samples/05-end-to-end/hosted_agents/foundry_multiagent/.dockerignore create mode 100644 python/samples/05-end-to-end/hosted_agents/foundry_multiagent/.env.sample create mode 100644 python/samples/05-end-to-end/hosted_agents/foundry_multiagent/Dockerfile create mode 100644 python/samples/05-end-to-end/hosted_agents/foundry_multiagent/README.md create mode 100644 python/samples/05-end-to-end/hosted_agents/foundry_multiagent/agent.yaml create mode 100644 python/samples/05-end-to-end/hosted_agents/foundry_multiagent/main.py create mode 100644 python/samples/05-end-to-end/hosted_agents/foundry_multiagent/requirements.txt create mode 100644 python/samples/05-end-to-end/hosted_agents/foundry_singleagent/.dockerignore create mode 100644 python/samples/05-end-to-end/hosted_agents/foundry_singleagent/Dockerfile create mode 100644 python/samples/05-end-to-end/hosted_agents/foundry_singleagent/README.md create mode 100644 python/samples/05-end-to-end/hosted_agents/foundry_singleagent/agent.yaml create mode 100644 python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py create mode 100644 python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/.dockerignore b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/.dockerignore new file mode 100644 index 0000000000..bdb7cbb34f --- /dev/null +++ b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/.dockerignore @@ -0,0 +1,51 @@ +# Build artifacts +bin/ +obj/ + +# IDE and editor files +.vs/ +.vscode/ +*.user +*.suo +.foundry/ + +# Source control +.git/ + +# Documentation +README.md + +# Ignore files +.gitignore +.dockerignore + +# Logs +*.log + +# Temporary files +*.tmp +*.temp + +# OS files +.DS_Store +Thumbs.db + +# Package manager directories +node_modules/ +packages/ + +# Test results +TestResults/ +*.trx + +# Coverage reports +coverage/ +*.coverage +*.coveragexml + +# Local development config +appsettings.Development.json +.env + +.venv/ +__pycache__/ diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/.env.sample b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/.env.sample new file mode 100644 index 0000000000..7a7d4d5ec3 --- /dev/null +++ b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/.env.sample @@ -0,0 +1,3 @@ +# IMPORTANT: Never commit .env to version control - add it to .gitignore +PROJECT_ENDPOINT= +MODEL_DEPLOYMENT_NAME= \ No newline at end of file diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/Dockerfile b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/Dockerfile new file mode 100644 index 0000000000..0cc939d9b3 --- /dev/null +++ b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.12-slim + +WORKDIR /app + +COPY . user_agent/ +WORKDIR /app/user_agent + +RUN if [ -f requirements.txt ]; then \ + pip install -r requirements.txt; \ + else \ + echo "No requirements.txt found"; \ + fi + +EXPOSE 8088 + +CMD ["python", "main.py"] diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/README.md b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/README.md new file mode 100644 index 0000000000..beb70ec982 --- /dev/null +++ b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/README.md @@ -0,0 +1,159 @@ +**IMPORTANT!** All samples and other resources made available in this GitHub repository ("samples") are designed to assist in accelerating development of agents, solutions, and agent workflows for various scenarios. Review all provided resources and carefully test output behavior in the context of your use case. AI responses may be inaccurate and AI actions should be monitored with human oversight. Learn more in the transparency documents for [Agent Service](https://learn.microsoft.com/en-us/azure/ai-foundry/responsible-ai/agents/transparency-note) and [Agent Framework](https://github.com/microsoft/agent-framework/blob/main/TRANSPARENCY_FAQ.md). + +Agents, solutions, or other output you create may be subject to legal and regulatory requirements, may require licenses, or may not be suitable for all industries, scenarios, or use cases. By using any sample, you are acknowledging that any output created using those samples are solely your responsibility, and that you will comply with all applicable laws, regulations, and relevant safety standards, terms of service, and codes of conduct. + +Third-party samples contained in this folder are subject to their own designated terms, and they have not been tested or verified by Microsoft or its affiliates. + +Microsoft has no responsibility to you or others with respect to any of these samples or any resulting output. + +# What this sample demonstrates + +This sample demonstrates a **key advantage of code-based hosted agents**: + +- **Agents in Workflows** - Use AI agents as executors within a workflow pipeline + +Code-based agents can execute **any Python code** you write. This sample includes a multi-agent workflow where Writer and Reviewer agents collaborate to draft content and provide review feedback. + +The agent is hosted using the [Azure AI AgentServer SDK](https://pypi.org/project/azure-ai-agentserver-agentframework/) and can be deployed to Microsoft Foundry using the Azure Developer CLI. + +## How It Works + +### Agents in Workflows + +This sample demonstrates the integration of AI agents within a workflow pipeline. The workflow operates as follows: + +1. **Writer Agent** - Drafts content +2. **Reviewer Agent** - Reviews the draft and provides concise, actionable feedback + +### Agent Hosting + +The agent workflow is hosted using the [Azure AI AgentServer SDK](https://pypi.org/project/azure-ai-agentserver-agentframework/), +which provisions a REST API endpoint compatible with the OpenAI Responses protocol. + +### Agent Deployment + +The hosted agent workflow can be deployed to Microsoft Foundry using the Azure Developer CLI [ai agent](https://learn.microsoft.com/en-us/azure/ai-foundry/agents/concepts/hosted-agents?view=foundry&tabs=cli#create-a-hosted-agent) extension. + +## Running the Agent Locally + +### Prerequisites + +Before running this sample, ensure you have: + +1. **Azure AI Foundry Project** + - Project created in [Azure AI Foundry](https://learn.microsoft.com/en-us/azure/ai-foundry/what-is-foundry?view=foundry#microsoft-foundry-portals) + - Chat model deployed (e.g., `gpt-4o` or `gpt-4.1`) + - Note your project endpoint URL and model deployment name + +2. **Azure CLI** + - Installed and authenticated + - Run `az login` and verify with `az account show` + +3. **Python 3.10 or higher** + - Verify your version: `python --version` + - If you have Python 3.9 or older, install a newer version: + - Windows: `winget install Python.Python.3.12` + - macOS: `brew install python@3.12` + - Linux: Use your package manager + +### Environment Variables + +Set the following environment variables (matching `agent.yaml`): + +- `PROJECT_ENDPOINT` - Your Azure AI Foundry project endpoint URL (required) +- `MODEL_DEPLOYMENT_NAME` - The deployment name for your chat model (defaults to `gpt-4.1-mini`) + +This sample loads environment variables from a local `.env` file if present. + +Create a `.env` file in this directory with the following content: + +``` +PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ +MODEL_DEPLOYMENT_NAME=gpt-4.1-mini +``` + +Or set them via PowerShell: + +```powershell +# Replace with your actual values +$env:PROJECT_ENDPOINT="https://.services.ai.azure.com/api/projects/" +$env:MODEL_DEPLOYMENT_NAME="gpt-4.1-mini" +``` + +### Setting Up a Virtual Environment + +It's recommended to use a virtual environment to isolate project dependencies: + +**macOS/Linux:** + +```bash +python -m venv .venv +source .venv/bin/activate +``` + +**Windows (PowerShell):** + +```powershell +python -m venv .venv +.\.venv\Scripts\Activate.ps1 +``` + +### Installing Dependencies + +Install the required Python dependencies using pip: + +```bash +pip install -r requirements.txt +``` + +### Running the Sample + +To run the agent, execute the following command in your terminal: + +```powershell +python main.py +``` + +This will start the hosted agent locally on `http://localhost:8088/`. + +### Interacting with the Agent + +**PowerShell (Windows):** + +```powershell +$body = @{ + input = "Create a slogan for a new electric SUV that is affordable and fun to drive." + stream = $false +} | ConvertTo-Json + +Invoke-RestMethod -Uri http://localhost:8088/responses -Method Post -Body $body -ContentType "application/json" +``` + +**Bash/curl (Linux/macOS):** + +```bash +curl -sS -H "Content-Type: application/json" -X POST http://localhost:8088/responses \ + -d '{"input": "Create a slogan for a new electric SUV that is affordable and fun to drive.","stream":false}' +``` + +### Deploying the Agent to Microsoft Foundry + +To deploy your agent to Microsoft Foundry, follow the comprehensive deployment guide at https://learn.microsoft.com/en-us/azure/ai-foundry/agents/concepts/hosted-agents?view=foundry&tabs=cli + +## Troubleshooting + +### Images built on Apple Silicon or other ARM64 machines do not work on our service + +We **recommend using `azd` cloud build**, which always builds images with the correct architecture. + +If you choose to **build locally**, and your machine is **not `linux/amd64`** (for example, an Apple Silicon Mac), the image will **not be compatible with our service**, causing runtime failures. + +**Fix for local builds** + +Use this command to build the image locally: + +```shell +docker build --platform=linux/amd64 -t image . +``` + +This forces the image to be built for the required `amd64` architecture. diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/agent.yaml b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/agent.yaml new file mode 100644 index 0000000000..c956905571 --- /dev/null +++ b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/agent.yaml @@ -0,0 +1,28 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml + +kind: hosted +name: foundry-multiagent +description: > + A multi-agent workflow featuring a Writer and Reviewer that collaborate + to create and refine content. +metadata: + authors: + - Microsoft + tags: + - Azure AI AgentServer + - Microsoft Agent Framework + - Multi-Agent Workflow + - Writer-Reviewer + - Content Creation +protocols: + - protocol: responses + version: v1 +environment_variables: + - name: PROJECT_ENDPOINT + value: ${PROJECT_ENDPOINT} + - name: MODEL_DEPLOYMENT_NAME + value: "{{chat}}" +resources: + - kind: model + id: gpt-4o-mini + name: chat diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/main.py b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/main.py new file mode 100644 index 0000000000..0876b46043 --- /dev/null +++ b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/main.py @@ -0,0 +1,88 @@ +import asyncio +import os +from contextlib import asynccontextmanager + +from agent_framework import Agent, WorkflowBuilder +from agent_framework.azure import AzureAIAgentClient +from azure.ai.agentserver.agentframework import from_agent_framework +from azure.identity.aio import DefaultAzureCredential, ManagedIdentityCredential +from dotenv import load_dotenv + +load_dotenv(override=True) + +# Configure these for your Foundry project +# Read the explicit variables present in the .env file +PROJECT_ENDPOINT = os.getenv( + "PROJECT_ENDPOINT" +) # e.g., "https://.services.ai.azure.com/api/projects/" +MODEL_DEPLOYMENT_NAME = os.getenv( + "MODEL_DEPLOYMENT_NAME", "gpt-4.1-mini" +) # Your model deployment name e.g., "gpt-4.1-mini" + + +def get_credential(): + """Will use Managed Identity when running in Azure, otherwise falls back to DefaultAzureCredential.""" + return ( + ManagedIdentityCredential() + if os.getenv("MSI_ENDPOINT") + else DefaultAzureCredential() + ) + + +@asynccontextmanager +async def create_agents(): + async with ( + get_credential() as credential, + AzureAIAgentClient( + project_endpoint=PROJECT_ENDPOINT, + model_deployment_name=MODEL_DEPLOYMENT_NAME, + credential=credential, + ) as writer_client, + AzureAIAgentClient( + project_endpoint=PROJECT_ENDPOINT, + model_deployment_name=MODEL_DEPLOYMENT_NAME, + credential=credential, + ) as reviewer_client, + ): + writer = Agent( + writer_client, + name="Writer", + instructions="You are an excellent content writer. You create new content and edit contents based on the feedback.", + ) + reviewer = Agent( + reviewer_client, + name="Reviewer", + instructions="You are an excellent content reviewer. Provide actionable feedback to the writer about the provided content in the most concise manner possible.", + ) + yield writer, reviewer + + +def create_workflow(writer, reviewer): + workflow = ( + WorkflowBuilder( + name="Writer-Reviewer", + start_executor=writer, + output_executors=[writer, reviewer], + ) + .add_edge(writer, reviewer) + .build() + ) + return workflow.as_agent() + + +async def main() -> None: + """ + The writer and reviewer multi-agent workflow. + + Environment variables required: + - PROJECT_ENDPOINT: Your Microsoft Foundry project endpoint + - MODEL_DEPLOYMENT_NAME: Your Microsoft Foundry model deployment name + """ + + async with create_agents() as (writer, reviewer): + agent = create_workflow(writer, reviewer) + await from_agent_framework(agent).run_async() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/requirements.txt b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/requirements.txt new file mode 100644 index 0000000000..0f530be025 --- /dev/null +++ b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/requirements.txt @@ -0,0 +1 @@ +azure-ai-agentserver-agentframework==1.0.0b16 \ No newline at end of file diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/.dockerignore b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/.dockerignore new file mode 100644 index 0000000000..779bc67aae --- /dev/null +++ b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/.dockerignore @@ -0,0 +1,66 @@ +# Virtual environments +.venv/ +venv/ +env/ +.python-version + +# Environment files with secrets +.env +.env.* +*.local + +# Python build artifacts +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# Testing +.tox/ +.nox/ +.coverage +.coverage.* +htmlcov/ +.pytest_cache/ +.mypy_cache/ + +# IDE and OS files +.DS_Store +.idea/ +.vscode/ +*.swp +*.swo +*~ + +# Foundry config +.foundry/ +build-source-*/ + +# Git +.git/ +.gitignore + +# Docker +.dockerignore + +# Documentation +docs/ +*.md +!README.md +LICENSE diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/Dockerfile b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/Dockerfile new file mode 100644 index 0000000000..abec2e20e1 --- /dev/null +++ b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.12-slim + +WORKDIR /app + +COPY requirements.txt . + +RUN pip install --no-cache-dir -r requirements.txt + +COPY main.py . + +EXPOSE 8088 + +CMD ["python", "main.py"] \ No newline at end of file diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/README.md b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/README.md new file mode 100644 index 0000000000..eaa06a2756 --- /dev/null +++ b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/README.md @@ -0,0 +1,166 @@ +**IMPORTANT!** All samples and other resources made available in this GitHub repository ("samples") are designed to assist in accelerating development of agents, solutions, and agent workflows for various scenarios. Review all provided resources and carefully test output behavior in the context of your use case. AI responses may be inaccurate and AI actions should be monitored with human oversight. Learn more in the transparency documents for [Agent Service](https://learn.microsoft.com/en-us/azure/ai-foundry/responsible-ai/agents/transparency-note) and [Agent Framework](https://github.com/microsoft/agent-framework/blob/main/TRANSPARENCY_FAQ.md). + +Agents, solutions, or other output you create may be subject to legal and regulatory requirements, may require licenses, or may not be suitable for all industries, scenarios, or use cases. By using any sample, you are acknowledging that any output created using those samples are solely your responsibility, and that you will comply with all applicable laws, regulations, and relevant safety standards, terms of service, and codes of conduct. + +Third-party samples contained in this folder are subject to their own designated terms, and they have not been tested or verified by Microsoft or its affiliates. + +Microsoft has no responsibility to you or others with respect to any of these samples or any resulting output. + +# What this sample demonstrates + +This sample demonstrates a **key advantage of code-based hosted agents**: + +- **Local Python tool execution** - Run custom Python functions as agent tools + +Code-based agents can execute **any Python code** you write. This sample includes a Seattle Hotel Agent with a `get_available_hotels` tool that searches for available hotels based on check-in/check-out dates and budget preferences. + +The agent is hosted using the [Azure AI AgentServer SDK](https://pypi.org/project/azure-ai-agentserver-agentframework/) and can be deployed to Microsoft Foundry using the Azure Developer CLI. + +## How It Works + +### Local Tools Integration + +In [main.py](main.py), the agent uses a local Python function (`get_available_hotels`) that simulates a hotel availability API. This demonstrates how code-based agents can execute custom server-side logic that prompt agents cannot access. + +The tool accepts: +- **check_in_date** - Check-in date in YYYY-MM-DD format +- **check_out_date** - Check-out date in YYYY-MM-DD format +- **max_price** - Maximum price per night in USD (optional, defaults to $500) + +### Agent Hosting + +The agent is hosted using the [Azure AI AgentServer SDK](https://pypi.org/project/azure-ai-agentserver-agentframework/), +which provisions a REST API endpoint compatible with the OpenAI Responses protocol. + +### Agent Deployment + +The hosted agent can be deployed to Microsoft Foundry using the Azure Developer CLI [ai agent](https://learn.microsoft.com/en-us/azure/ai-foundry/agents/concepts/hosted-agents?view=foundry&tabs=cli#create-a-hosted-agent) extension. + +## Running the Agent Locally + +### Prerequisites + +Before running this sample, ensure you have: + +1. **Azure AI Foundry Project** + - Project created in [Azure AI Foundry](https://learn.microsoft.com/en-us/azure/ai-foundry/what-is-foundry?view=foundry#microsoft-foundry-portals) + - Chat model deployed (e.g., `gpt-4o` or `gpt-4.1`) + - Note your project endpoint URL and model deployment name + +2. **Azure CLI** + - Installed and authenticated + - Run `az login` and verify with `az account show` + +3. **Python 3.10 or higher** + - Verify your version: `python --version` + - If you have Python 3.9 or older, install a newer version: + - Windows: `winget install Python.Python.3.12` + - macOS: `brew install python@3.12` + - Linux: Use your package manager + +### Environment Variables + +Set the following environment variables (matching `agent.yaml`): + +- `PROJECT_ENDPOINT` - Your Azure AI Foundry project endpoint URL (required) +- `MODEL_DEPLOYMENT_NAME` - The deployment name for your chat model (defaults to `gpt-4.1-mini`) + +This sample loads environment variables from a local `.env` file if present. + +Create a `.env` file in this directory with the following content: + +``` +PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ +MODEL_DEPLOYMENT_NAME=gpt-4.1-mini +``` + +Or set them via PowerShell: + +```powershell +# Replace with your actual values +$env:PROJECT_ENDPOINT="https://.services.ai.azure.com/api/projects/" +$env:MODEL_DEPLOYMENT_NAME="gpt-4.1-mini" +``` + +### Setting Up a Virtual Environment + +It's recommended to use a virtual environment to isolate project dependencies: + +**macOS/Linux:** +```bash +python -m venv .venv +source .venv/bin/activate +``` + +**Windows (PowerShell):** +```powershell +python -m venv .venv +.\.venv\Scripts\Activate.ps1 +``` + +### Installing Dependencies + +Install the required Python dependencies using pip: + +```bash +pip install -r requirements.txt +``` + +The required packages are: +- `azure-ai-agentserver-agentframework` - Agent Framework and AgentServer SDK +- `python-dotenv` - Load environment variables from `.env` file +- `azure-identity` - Azure authentication +- `azure-monitor-opentelemetry-exporter` - Azure Monitor telemetry export +- `opentelemetry-sdk` / `opentelemetry-api` - OpenTelemetry for tracing + +### Running the Sample + +To run the agent, execute the following command in your terminal: + +```powershell +python main.py +``` + +This will start the hosted agent locally on `http://localhost:8088/`. + +### Interacting with the Agent + +**PowerShell (Windows):** +```powershell +$body = @{ + input = "I need a hotel in Seattle from 2025-03-15 to 2025-03-18, budget under $200 per night" + stream = $false +} | ConvertTo-Json + +Invoke-RestMethod -Uri http://localhost:8088/responses -Method Post -Body $body -ContentType "application/json" +``` + +**Bash/curl (Linux/macOS):** +```bash +curl -sS -H "Content-Type: application/json" -X POST http://localhost:8088/responses \ + -d '{"input": "Find me hotels in Seattle for March 20-23, 2025 under $200 per night","stream":false}' +``` + +The agent will use the `get_available_hotels` tool to search for available hotels matching your criteria. + +### Deploying the Agent to Microsoft Foundry + +To deploy your agent to Microsoft Foundry, follow the comprehensive deployment guide at https://learn.microsoft.com/en-us/azure/ai-foundry/agents/concepts/hosted-agents?view=foundry&tabs=cli + +## Troubleshooting + +### Images built on Apple Silicon or other ARM64 machines do not work on our service + +We **recommend using `azd` cloud build**, which always builds images with the correct architecture. + +If you choose to **build locally**, and your machine is **not `linux/amd64`** (for example, an Apple Silicon Mac), the image will **not be compatible with our service**, causing runtime failures. + +**Fix for local builds** + +Use this command to build the image locally: + +```shell +docker build --platform=linux/amd64 -t image . +``` + +This forces the image to be built for the required `amd64` architecture. \ No newline at end of file diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/agent.yaml b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/agent.yaml new file mode 100644 index 0000000000..d85d82ece6 --- /dev/null +++ b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/agent.yaml @@ -0,0 +1,31 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml + +kind: hosted +name: foundry-singleagent +# Brief description of what this agent does +description: > + A travel assistant agent that helps users find hotels in Seattle. + Demonstrates local Python tool execution - a key advantage of code-based + hosted agents over prompt agents. +metadata: + # Categorization tags for organizing and discovering agents + authors: + - Microsoft + tags: + - Azure AI AgentServer + - Microsoft Agent Framework + - Local Tools + - Travel Assistant + - Hotel Search +protocols: + - protocol: responses + version: v1 +environment_variables: + - name: PROJECT_ENDPOINT + value: ${AZURE_AI_PROJECT_ENDPOINT} + - name: MODEL_DEPLOYMENT_NAME + value: "{{chat}}" +resources: + - kind: model + id: gpt-4.1-mini + name: chat diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py new file mode 100644 index 0000000000..0cd5ba2105 --- /dev/null +++ b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py @@ -0,0 +1,115 @@ +""" +Seattle Hotel Agent - A simple agent with a tool to find hotels in Seattle. +Uses Microsoft Agent Framework with Azure AI Foundry. +Ready for deployment to Foundry Hosted Agent service. +""" + +import asyncio +import os +from datetime import datetime +from typing import Annotated + +from agent_framework import Agent +from agent_framework.azure import AzureAIAgentClient +from azure.ai.agentserver.agentframework import from_agent_framework +from azure.identity.aio import DefaultAzureCredential +from dotenv import load_dotenv + +load_dotenv(override=True) + +# Configure these for your Foundry project +# Read the explicit variables present in the .env file +PROJECT_ENDPOINT = os.getenv("PROJECT_ENDPOINT") # e.g., "https://.services.ai.azure.com" +MODEL_DEPLOYMENT_NAME = os.getenv("MODEL_DEPLOYMENT_NAME", "gpt-4.1-mini") # Your model deployment name e.g., "gpt-4.1-mini" + + +# Simulated hotel data for Seattle +SEATTLE_HOTELS = [ + {"name": "Contoso Suites", "price_per_night": 189, "rating": 4.5, "location": "Downtown"}, + {"name": "Fabrikam Residences", "price_per_night": 159, "rating": 4.2, "location": "Pike Place Market"}, + {"name": "Alpine Ski House", "price_per_night": 249, "rating": 4.7, "location": "Seattle Center"}, + {"name": "Margie's Travel Lodge", "price_per_night": 219, "rating": 4.4, "location": "Waterfront"}, + {"name": "Northwind Inn", "price_per_night": 139, "rating": 4.0, "location": "Capitol Hill"}, + {"name": "Relecloud Hotel", "price_per_night": 99, "rating": 3.8, "location": "University District"}, +] + + +def get_available_hotels( + check_in_date: Annotated[str, "Check-in date in YYYY-MM-DD format"], + check_out_date: Annotated[str, "Check-out date in YYYY-MM-DD format"], + max_price: Annotated[int, "Maximum price per night in USD (optional)"] = 500, +) -> str: + """ + Get available hotels in Seattle for the specified dates. + This simulates a call to a fake hotel availability API. + """ + try: + # Parse dates + check_in = datetime.strptime(check_in_date, "%Y-%m-%d") + check_out = datetime.strptime(check_out_date, "%Y-%m-%d") + + # Validate dates + if check_out <= check_in: + return "Error: Check-out date must be after check-in date." + + nights = (check_out - check_in).days + + # Filter hotels by price + available_hotels = [ + hotel for hotel in SEATTLE_HOTELS + if hotel["price_per_night"] <= max_price + ] + + if not available_hotels: + return f"No hotels found in Seattle within your budget of ${max_price}/night." + + # Build response + result = f"Available hotels in Seattle from {check_in_date} to {check_out_date} ({nights} nights):\n\n" + + for hotel in available_hotels: + total_cost = hotel["price_per_night"] * nights + result += f"**{hotel['name']}**\n" + result += f" Location: {hotel['location']}\n" + result += f" Rating: {hotel['rating']}/5\n" + result += f" ${hotel['price_per_night']}/night (Total: ${total_cost})\n\n" + + return result + + except ValueError as e: + return f"Error parsing dates. Please use YYYY-MM-DD format. Details: {str(e)}" + + +async def main(): + """Main function to run the agent as a web server.""" + async with ( + DefaultAzureCredential() as credential, + AzureAIAgentClient( + project_endpoint=PROJECT_ENDPOINT, + model_deployment_name=MODEL_DEPLOYMENT_NAME, + credential=credential, + ) as client, + ): + agent = Agent( + client, + name="SeattleHotelAgent", + instructions="""You are a helpful travel assistant specializing in finding hotels in Seattle, Washington. + +When a user asks about hotels in Seattle: +1. Ask for their check-in and check-out dates if not provided +2. Ask about their budget preferences if not mentioned +3. Use the get_available_hotels tool to find available options +4. Present the results in a friendly, informative way +5. Offer to help with additional questions about the hotels or Seattle + +Be conversational and helpful. If users ask about things outside of Seattle hotels, +politely let them know you specialize in Seattle hotel recommendations.""", + tools=[get_available_hotels], + ) + + print("Seattle Hotel Agent Server running on http://localhost:8088") + server = from_agent_framework(agent) + await server.run_async() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt new file mode 100644 index 0000000000..8b4d185353 --- /dev/null +++ b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt @@ -0,0 +1,8 @@ +azure-ai-agentserver-agentframework==1.0.0b16 +python-dotenv +azure-identity + +# Azure Monitor / OpenTelemetry +azure-monitor-opentelemetry-exporter>=1.0.0b46 +opentelemetry-sdk>=1.39.0 +opentelemetry-api>=1.39.0 \ No newline at end of file From 32d892b56eac378378b044b0a4b3327fdb761131 Mon Sep 17 00:00:00 2001 From: "huimiu[safe]" Date: Thu, 12 Mar 2026 21:25:32 +0800 Subject: [PATCH 02/10] Refactor formatting and improve readability in main.py --- .../hosted_agents/foundry_singleagent/main.py | 58 +++++++++++++++---- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py index 0cd5ba2105..6759c6ac67 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py +++ b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py @@ -15,22 +15,57 @@ from azure.identity.aio import DefaultAzureCredential from dotenv import load_dotenv + load_dotenv(override=True) # Configure these for your Foundry project # Read the explicit variables present in the .env file -PROJECT_ENDPOINT = os.getenv("PROJECT_ENDPOINT") # e.g., "https://.services.ai.azure.com" -MODEL_DEPLOYMENT_NAME = os.getenv("MODEL_DEPLOYMENT_NAME", "gpt-4.1-mini") # Your model deployment name e.g., "gpt-4.1-mini" +PROJECT_ENDPOINT = os.getenv( + "PROJECT_ENDPOINT" +) # e.g., "https://.services.ai.azure.com" +MODEL_DEPLOYMENT_NAME = os.getenv( + "MODEL_DEPLOYMENT_NAME", "gpt-4.1-mini" +) # Your model deployment name e.g., "gpt-4.1-mini" # Simulated hotel data for Seattle SEATTLE_HOTELS = [ - {"name": "Contoso Suites", "price_per_night": 189, "rating": 4.5, "location": "Downtown"}, - {"name": "Fabrikam Residences", "price_per_night": 159, "rating": 4.2, "location": "Pike Place Market"}, - {"name": "Alpine Ski House", "price_per_night": 249, "rating": 4.7, "location": "Seattle Center"}, - {"name": "Margie's Travel Lodge", "price_per_night": 219, "rating": 4.4, "location": "Waterfront"}, - {"name": "Northwind Inn", "price_per_night": 139, "rating": 4.0, "location": "Capitol Hill"}, - {"name": "Relecloud Hotel", "price_per_night": 99, "rating": 3.8, "location": "University District"}, + { + "name": "Contoso Suites", + "price_per_night": 189, + "rating": 4.5, + "location": "Downtown", + }, + { + "name": "Fabrikam Residences", + "price_per_night": 159, + "rating": 4.2, + "location": "Pike Place Market", + }, + { + "name": "Alpine Ski House", + "price_per_night": 249, + "rating": 4.7, + "location": "Seattle Center", + }, + { + "name": "Margie's Travel Lodge", + "price_per_night": 219, + "rating": 4.4, + "location": "Waterfront", + }, + { + "name": "Northwind Inn", + "price_per_night": 139, + "rating": 4.0, + "location": "Capitol Hill", + }, + { + "name": "Relecloud Hotel", + "price_per_night": 99, + "rating": 3.8, + "location": "University District", + }, ] @@ -56,12 +91,13 @@ def get_available_hotels( # Filter hotels by price available_hotels = [ - hotel for hotel in SEATTLE_HOTELS - if hotel["price_per_night"] <= max_price + hotel for hotel in SEATTLE_HOTELS if hotel["price_per_night"] <= max_price ] if not available_hotels: - return f"No hotels found in Seattle within your budget of ${max_price}/night." + return ( + f"No hotels found in Seattle within your budget of ${max_price}/night." + ) # Build response result = f"Available hotels in Seattle from {check_in_date} to {check_out_date} ({nights} nights):\n\n" From e4839d023756915216fd581235da77bbc858f4a9 Mon Sep 17 00:00:00 2001 From: huimiu Date: Thu, 12 Mar 2026 21:49:54 +0800 Subject: [PATCH 03/10] Add agent-framework dependency to requirements and update copyright notice in main.py files --- .../05-end-to-end/hosted_agents/foundry_multiagent/main.py | 2 ++ .../hosted_agents/foundry_multiagent/requirements.txt | 3 ++- .../05-end-to-end/hosted_agents/foundry_singleagent/main.py | 2 ++ .../hosted_agents/foundry_singleagent/requirements.txt | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/main.py b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/main.py index 0876b46043..cb73c387b7 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/main.py +++ b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/main.py @@ -1,3 +1,5 @@ +# Copyright (c) Microsoft. All rights reserved. + import asyncio import os from contextlib import asynccontextmanager diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/requirements.txt b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/requirements.txt index 0f530be025..250c059d77 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/requirements.txt +++ b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/requirements.txt @@ -1 +1,2 @@ -azure-ai-agentserver-agentframework==1.0.0b16 \ No newline at end of file +azure-ai-agentserver-agentframework==1.0.0b16 +agent-framework diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py index 6759c6ac67..36fd8ddd81 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py +++ b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py @@ -1,3 +1,5 @@ +# Copyright (c) Microsoft. All rights reserved. + """ Seattle Hotel Agent - A simple agent with a tool to find hotels in Seattle. Uses Microsoft Agent Framework with Azure AI Foundry. diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt index 8b4d185353..b4afb96f78 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt +++ b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt @@ -1,4 +1,5 @@ azure-ai-agentserver-agentframework==1.0.0b16 +agent-framework python-dotenv azure-identity From 0db49999e704ab1be53837e27175542f503f1223 Mon Sep 17 00:00:00 2001 From: huimiu Date: Thu, 12 Mar 2026 22:18:17 +0800 Subject: [PATCH 04/10] Refactor agent imports and update credential handling in hosted agent samples --- .../hosted_agents/foundry_multiagent/main.py | 37 ++++++------------- .../hosted_agents/foundry_singleagent/main.py | 25 ++++++++----- .../foundry_singleagent/requirements.txt | 2 +- 3 files changed, 28 insertions(+), 36 deletions(-) diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/main.py b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/main.py index cb73c387b7..9171113c97 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/main.py +++ b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/main.py @@ -4,10 +4,10 @@ import os from contextlib import asynccontextmanager -from agent_framework import Agent, WorkflowBuilder -from agent_framework.azure import AzureAIAgentClient +from agent_framework import WorkflowBuilder +from agent_framework.azure import AzureAIProjectAgentProvider from azure.ai.agentserver.agentframework import from_agent_framework -from azure.identity.aio import DefaultAzureCredential, ManagedIdentityCredential +from azure.identity.aio import AzureCliCredential, ManagedIdentityCredential from dotenv import load_dotenv load_dotenv(override=True) @@ -23,11 +23,11 @@ def get_credential(): - """Will use Managed Identity when running in Azure, otherwise falls back to DefaultAzureCredential.""" + """Will use Managed Identity when running in Azure, otherwise falls back to Azure CLI Credential.""" return ( ManagedIdentityCredential() if os.getenv("MSI_ENDPOINT") - else DefaultAzureCredential() + else AzureCliCredential() ) @@ -35,24 +35,17 @@ def get_credential(): async def create_agents(): async with ( get_credential() as credential, - AzureAIAgentClient( + AzureAIProjectAgentProvider( project_endpoint=PROJECT_ENDPOINT, - model_deployment_name=MODEL_DEPLOYMENT_NAME, + model=MODEL_DEPLOYMENT_NAME, credential=credential, - ) as writer_client, - AzureAIAgentClient( - project_endpoint=PROJECT_ENDPOINT, - model_deployment_name=MODEL_DEPLOYMENT_NAME, - credential=credential, - ) as reviewer_client, + ) as provider, ): - writer = Agent( - writer_client, + writer = await provider.create_agent( name="Writer", instructions="You are an excellent content writer. You create new content and edit contents based on the feedback.", ) - reviewer = Agent( - reviewer_client, + reviewer = await provider.create_agent( name="Reviewer", instructions="You are an excellent content reviewer. Provide actionable feedback to the writer about the provided content in the most concise manner possible.", ) @@ -60,15 +53,7 @@ async def create_agents(): def create_workflow(writer, reviewer): - workflow = ( - WorkflowBuilder( - name="Writer-Reviewer", - start_executor=writer, - output_executors=[writer, reviewer], - ) - .add_edge(writer, reviewer) - .build() - ) + workflow = WorkflowBuilder(start_executor=writer).add_edge(writer, reviewer).build() return workflow.as_agent() diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py index 36fd8ddd81..bbf3a48361 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py +++ b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py @@ -11,10 +11,9 @@ from datetime import datetime from typing import Annotated -from agent_framework import Agent -from agent_framework.azure import AzureAIAgentClient +from agent_framework.azure import AzureAIProjectAgentProvider from azure.ai.agentserver.agentframework import from_agent_framework -from azure.identity.aio import DefaultAzureCredential +from azure.identity.aio import AzureCliCredential, ManagedIdentityCredential from dotenv import load_dotenv @@ -117,18 +116,26 @@ def get_available_hotels( return f"Error parsing dates. Please use YYYY-MM-DD format. Details: {str(e)}" +def get_credential(): + """Will use Managed Identity when running in Azure, otherwise falls back to Azure CLI Credential.""" + return ( + ManagedIdentityCredential() + if os.getenv("MSI_ENDPOINT") + else AzureCliCredential() + ) + + async def main(): """Main function to run the agent as a web server.""" async with ( - DefaultAzureCredential() as credential, - AzureAIAgentClient( + get_credential() as credential, + AzureAIProjectAgentProvider( project_endpoint=PROJECT_ENDPOINT, - model_deployment_name=MODEL_DEPLOYMENT_NAME, + model=MODEL_DEPLOYMENT_NAME, credential=credential, - ) as client, + ) as provider, ): - agent = Agent( - client, + agent = await provider.create_agent( name="SeattleHotelAgent", instructions="""You are a helpful travel assistant specializing in finding hotels in Seattle, Washington. diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt index b4afb96f78..37d20cd5f3 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt +++ b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt @@ -1,5 +1,5 @@ azure-ai-agentserver-agentframework==1.0.0b16 -agent-framework +agent-framework-core python-dotenv azure-identity From 40e62ff1e87e168a11d64b1ba01766d3789da8a8 Mon Sep 17 00:00:00 2001 From: huimiu Date: Thu, 12 Mar 2026 22:19:58 +0800 Subject: [PATCH 05/10] Update agent framework dependency in requirements for hosted agents --- .../hosted_agents/foundry_multiagent/requirements.txt | 2 +- .../hosted_agents/foundry_singleagent/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/requirements.txt b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/requirements.txt index 250c059d77..5ee6dd2eb5 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/requirements.txt +++ b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/requirements.txt @@ -1,2 +1,2 @@ azure-ai-agentserver-agentframework==1.0.0b16 -agent-framework +agent-framework-azure-ai diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt index 37d20cd5f3..a97eb7f13c 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt +++ b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt @@ -1,5 +1,5 @@ azure-ai-agentserver-agentframework==1.0.0b16 -agent-framework-core +agent-framework-azure-ai python-dotenv azure-identity From 2e48760f5df1921678eaabf59bb9381ca9a959bd Mon Sep 17 00:00:00 2001 From: huimiu Date: Tue, 17 Mar 2026 19:32:53 +0800 Subject: [PATCH 06/10] chore: update Python version to 3.14 and improve Dockerfile for hosted agents --- .../hosted_agents/foundry_multiagent/Dockerfile | 8 ++++---- .../hosted_agents/foundry_multiagent/agent.yaml | 6 +----- .../hosted_agents/foundry_singleagent/.env.sample | 3 +++ .../hosted_agents/foundry_singleagent/Dockerfile | 15 +++++++++------ .../hosted_agents/foundry_singleagent/agent.yaml | 8 ++------ 5 files changed, 19 insertions(+), 21 deletions(-) create mode 100644 python/samples/05-end-to-end/hosted_agents/foundry_singleagent/.env.sample diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/Dockerfile b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/Dockerfile index 0cc939d9b3..077fb78345 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/Dockerfile +++ b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/Dockerfile @@ -1,11 +1,11 @@ -FROM python:3.12-slim +FROM python:3.14-slim WORKDIR /app -COPY . user_agent/ -WORKDIR /app/user_agent +COPY ./ . -RUN if [ -f requirements.txt ]; then \ +RUN pip install --upgrade pip && \ + if [ -f requirements.txt ]; then \ pip install -r requirements.txt; \ else \ echo "No requirements.txt found"; \ diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/agent.yaml b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/agent.yaml index c956905571..6dd9c40340 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/agent.yaml +++ b/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/agent.yaml @@ -21,8 +21,4 @@ environment_variables: - name: PROJECT_ENDPOINT value: ${PROJECT_ENDPOINT} - name: MODEL_DEPLOYMENT_NAME - value: "{{chat}}" -resources: - - kind: model - id: gpt-4o-mini - name: chat + value: ${MODEL_DEPLOYMENT_NAME} \ No newline at end of file diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/.env.sample b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/.env.sample new file mode 100644 index 0000000000..7a7d4d5ec3 --- /dev/null +++ b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/.env.sample @@ -0,0 +1,3 @@ +# IMPORTANT: Never commit .env to version control - add it to .gitignore +PROJECT_ENDPOINT= +MODEL_DEPLOYMENT_NAME= \ No newline at end of file diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/Dockerfile b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/Dockerfile index abec2e20e1..077fb78345 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/Dockerfile +++ b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/Dockerfile @@ -1,13 +1,16 @@ -FROM python:3.12-slim +FROM python:3.14-slim WORKDIR /app -COPY requirements.txt . +COPY ./ . -RUN pip install --no-cache-dir -r requirements.txt - -COPY main.py . +RUN pip install --upgrade pip && \ + if [ -f requirements.txt ]; then \ + pip install -r requirements.txt; \ + else \ + echo "No requirements.txt found"; \ + fi EXPOSE 8088 -CMD ["python", "main.py"] \ No newline at end of file +CMD ["python", "main.py"] diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/agent.yaml b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/agent.yaml index d85d82ece6..50abe334b6 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/agent.yaml +++ b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/agent.yaml @@ -22,10 +22,6 @@ protocols: version: v1 environment_variables: - name: PROJECT_ENDPOINT - value: ${AZURE_AI_PROJECT_ENDPOINT} + value: ${PROJECT_ENDPOINT} - name: MODEL_DEPLOYMENT_NAME - value: "{{chat}}" -resources: - - kind: model - id: gpt-4.1-mini - name: chat + value: ${MODEL_DEPLOYMENT_NAME} \ No newline at end of file From 6b6584d09bfdaabea4655b835d573fca8647d24c Mon Sep 17 00:00:00 2001 From: huimiu Date: Tue, 17 Mar 2026 23:13:26 +0800 Subject: [PATCH 07/10] feat: add hosted agent samples for Azure AI with local tools and multi-agent workflows --- .../05-end-to-end/hosted_agents/README.md | 200 ++++++++++++++++++ .../.dockerignore | 0 .../.env.sample | 0 .../Dockerfile | 0 .../README.md | 50 ++--- .../agent.yaml | 2 +- .../main.py | 0 .../requirements.txt | 2 + .../.dockerignore | 0 .../.env.sample | 0 .../Dockerfile | 0 .../README.md | 36 ++-- .../agent.yaml | 2 +- .../main.py | 0 .../requirements.txt | 0 .../foundry_singleagent/requirements.txt | 9 - 16 files changed, 244 insertions(+), 57 deletions(-) create mode 100644 python/samples/05-end-to-end/hosted_agents/README.md rename python/samples/05-end-to-end/hosted_agents/{foundry_singleagent => azure_ai_agent_with_local_tool}/.dockerignore (100%) rename python/samples/05-end-to-end/hosted_agents/{foundry_multiagent => azure_ai_agent_with_local_tool}/.env.sample (100%) rename python/samples/05-end-to-end/hosted_agents/{foundry_multiagent => azure_ai_agent_with_local_tool}/Dockerfile (100%) rename python/samples/05-end-to-end/hosted_agents/{foundry_singleagent => azure_ai_agent_with_local_tool}/README.md (88%) rename python/samples/05-end-to-end/hosted_agents/{foundry_singleagent => azure_ai_agent_with_local_tool}/agent.yaml (95%) rename python/samples/05-end-to-end/hosted_agents/{foundry_singleagent => azure_ai_agent_with_local_tool}/main.py (100%) create mode 100644 python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/requirements.txt rename python/samples/05-end-to-end/hosted_agents/{foundry_multiagent => azure_ai_agents_in_workflow}/.dockerignore (100%) rename python/samples/05-end-to-end/hosted_agents/{foundry_singleagent => azure_ai_agents_in_workflow}/.env.sample (100%) rename python/samples/05-end-to-end/hosted_agents/{foundry_singleagent => azure_ai_agents_in_workflow}/Dockerfile (100%) rename python/samples/05-end-to-end/hosted_agents/{foundry_multiagent => azure_ai_agents_in_workflow}/README.md (92%) rename python/samples/05-end-to-end/hosted_agents/{foundry_multiagent => azure_ai_agents_in_workflow}/agent.yaml (95%) rename python/samples/05-end-to-end/hosted_agents/{foundry_multiagent => azure_ai_agents_in_workflow}/main.py (100%) rename python/samples/05-end-to-end/hosted_agents/{foundry_multiagent => azure_ai_agents_in_workflow}/requirements.txt (100%) delete mode 100644 python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt diff --git a/python/samples/05-end-to-end/hosted_agents/README.md b/python/samples/05-end-to-end/hosted_agents/README.md new file mode 100644 index 0000000000..b5a2f02480 --- /dev/null +++ b/python/samples/05-end-to-end/hosted_agents/README.md @@ -0,0 +1,200 @@ +# Hosted Agent Samples + +These samples demonstrate how to build and host AI agents in Python using the [Azure AI AgentServer SDK](https://pypi.org/project/azure-ai-agentserver-agentframework/) together with Microsoft Agent Framework. Each sample runs locally as a hosted agent and includes `Dockerfile` and `agent.yaml` assets for deployment to Microsoft Foundry. + +## Samples + +| Sample | Description | +|--------|-------------| +| [`agent_with_hosted_mcp`](./agent_with_hosted_mcp/) | Hosted MCP tool that connects to Microsoft Learn via `https://learn.microsoft.com/api/mcp` | +| [`agent_with_text_search_rag`](./agent_with_text_search_rag/) | Retrieval-augmented generation using a custom `BaseContextProvider` with Contoso Outdoors sample data | +| [`agents_in_workflow`](./agents_in_workflow/) | Concurrent workflow that combines researcher, marketer, and legal specialist agents | +| [`azure_ai_agent_with_local_tool`](./azure_ai_agent_with_local_tool/) | Azure AI Foundry project-backed agent with local Python tool execution for Seattle hotel search | +| [`azure_ai_agents_in_workflow`](./azure_ai_agents_in_workflow/) | Azure AI Foundry project-backed Writer/Reviewer workflow | + +## Two Configuration Models + +These samples fall into two groups: + +### Azure OpenAI hosted agent samples + +These use `AzureOpenAIChatClient(...).as_agent(...)` with `DefaultAzureCredential`: + +- [`agent_with_hosted_mcp`](./agent_with_hosted_mcp/) +- [`agent_with_text_search_rag`](./agent_with_text_search_rag/) +- [`agents_in_workflow`](./agents_in_workflow/) + +Required environment variables: + +| Variable | Description | +|----------|-------------| +| `AZURE_OPENAI_ENDPOINT` | Azure OpenAI resource endpoint | +| `AZURE_OPENAI_CHAT_DEPLOYMENT_NAME` | Chat model deployment name | + +### Azure AI Foundry project-backed samples + +These use `AzureAIProjectAgentProvider` and create agents against a Foundry project: + +- [`azure_ai_agent_with_local_tool`](./azure_ai_agent_with_local_tool/) +- [`azure_ai_agents_in_workflow`](./azure_ai_agents_in_workflow/) + +Required environment variables: + +| Variable | Description | +|----------|-------------| +| `PROJECT_ENDPOINT` | Foundry project endpoint, for example `https://.services.ai.azure.com/api/projects/` | +| `MODEL_DEPLOYMENT_NAME` | Model deployment name in that Foundry project | + +## Common Prerequisites + +Before running any sample, ensure you have: + +1. Python 3.10 or later +2. [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli) installed +3. Azure access configured for one of these setups: + - An Azure OpenAI resource with a chat model deployment + - An Azure AI Foundry project with a chat model deployment + +### Authenticate with Azure CLI + +All samples rely on Azure credentials. For local development, the simplest approach is Azure CLI authentication: + +```powershell +az login +az account show +``` + +Samples using `DefaultAzureCredential` will pick up Azure CLI credentials locally. The Foundry project-backed samples use `AzureCliCredential` locally and switch to managed identity automatically when running in Azure. + +## Running a Sample + +Each sample folder contains its own `requirements.txt`. Run commands from the specific sample directory you want to try. + +### Recommended: `uv` + +The sample dependencies include preview packages, so allow prerelease installs: + +```powershell +cd +uv venv .venv +uv pip install --prerelease=allow -r requirements.txt +uv run main.py +``` + +### Alternative: `venv` + +Windows PowerShell: + +```powershell +cd +python -m venv .venv +.\.venv\Scripts\Activate.ps1 +pip install -r requirements.txt +python main.py +``` + +macOS/Linux: + +```bash +cd +python -m venv .venv +source .venv/bin/activate +pip install -r requirements.txt +python main.py +``` + +Each sample starts a hosted agent locally on `http://localhost:8088/`. + +## Environment Variable Setup + +You can either export variables in your shell or create a local `.env` file in the sample directory. + +### Azure OpenAI samples + +Example `.env`: + +```dotenv +AZURE_OPENAI_ENDPOINT=https://.openai.azure.com/ +AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=gpt-4o-mini +``` + +### Azure AI Foundry project-backed samples + +Example `.env`: + +```dotenv +PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ +MODEL_DEPLOYMENT_NAME=gpt-4.1-mini +``` + +## Interacting with the Agent + +After starting a sample, send requests to the Responses endpoint. + +PowerShell: + +```powershell +$body = @{ + input = "Your question here" + stream = $false +} | ConvertTo-Json + +Invoke-RestMethod -Uri "http://localhost:8088/responses" -Method Post -Body $body -ContentType "application/json" +``` + +curl: + +```bash +curl -sS -H "Content-Type: application/json" -X POST http://localhost:8088/responses \ + -d '{"input":"Your question here","stream":false}' +``` + +Example prompts by sample: + +| Sample | Example input | +|--------|---------------| +| `agent_with_hosted_mcp` | `What does Microsoft Learn say about managed identities in Azure?` | +| `agent_with_text_search_rag` | `What is Contoso Outdoors' return policy for refunds?` | +| `agents_in_workflow` | `Create a launch strategy for a budget-friendly electric SUV.` | +| `azure_ai_agent_with_local_tool` | `Find me Seattle hotels from 2025-03-15 to 2025-03-18 under $200 per night.` | +| `azure_ai_agents_in_workflow` | `Write a slogan for a new affordable electric SUV.` | + +## Deploying to Microsoft Foundry + +Each sample includes a `Dockerfile` and `agent.yaml` for deployment. For deployment steps, follow the hosted agents guidance in Microsoft Foundry: + +- [Hosted agents overview](https://learn.microsoft.com/en-us/azure/ai-foundry/agents/concepts/hosted-agents) +- [Create a hosted agent with CLI](https://learn.microsoft.com/en-us/azure/ai-foundry/agents/concepts/hosted-agents?tabs=cli#create-a-hosted-agent) + +## Troubleshooting + +### Missing Azure credentials + +If startup fails with authentication errors, run `az login` and verify the selected subscription with `az account show`. + +### Missing `PROJECT_ENDPOINT` + +The Foundry project-backed samples require `PROJECT_ENDPOINT` and `MODEL_DEPLOYMENT_NAME`. Make sure both are set before running: + +- [`azure_ai_agent_with_local_tool`](./azure_ai_agent_with_local_tool/) +- [`azure_ai_agents_in_workflow`](./azure_ai_agents_in_workflow/) + +### Missing `AZURE_OPENAI_ENDPOINT` or deployment name + +The Azure OpenAI-based samples require `AZURE_OPENAI_ENDPOINT` and `AZURE_OPENAI_CHAT_DEPLOYMENT_NAME`: + +- [`agent_with_hosted_mcp`](./agent_with_hosted_mcp/) +- [`agent_with_text_search_rag`](./agent_with_text_search_rag/) +- [`agents_in_workflow`](./agents_in_workflow/) + +### Preview package install issues + +These samples depend on preview packages such as `azure-ai-agentserver-agentframework`. Use `uv pip install --prerelease=allow -r requirements.txt` or `pip install -r requirements.txt`. + +### ARM64 container images fail after deployment + +If you build images locally on ARM64 hardware such as Apple Silicon, build for `linux/amd64`: + +```bash +docker build --platform=linux/amd64 -t image . +``` diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/.dockerignore b/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/.dockerignore similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/foundry_singleagent/.dockerignore rename to python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/.dockerignore diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/.env.sample b/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/.env.sample similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/foundry_multiagent/.env.sample rename to python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/.env.sample diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/Dockerfile b/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/Dockerfile similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/foundry_multiagent/Dockerfile rename to python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/Dockerfile diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/README.md b/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/README.md similarity index 88% rename from python/samples/05-end-to-end/hosted_agents/foundry_singleagent/README.md rename to python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/README.md index eaa06a2756..5676b4159a 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/README.md +++ b/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/README.md @@ -23,6 +23,7 @@ The agent is hosted using the [Azure AI AgentServer SDK](https://pypi.org/projec In [main.py](main.py), the agent uses a local Python function (`get_available_hotels`) that simulates a hotel availability API. This demonstrates how code-based agents can execute custom server-side logic that prompt agents cannot access. The tool accepts: + - **check_in_date** - Check-in date in YYYY-MM-DD format - **check_out_date** - Check-out date in YYYY-MM-DD format - **max_price** - Maximum price per night in USD (optional, defaults to $500) @@ -53,10 +54,6 @@ Before running this sample, ensure you have: 3. **Python 3.10 or higher** - Verify your version: `python --version` - - If you have Python 3.9 or older, install a newer version: - - Windows: `winget install Python.Python.3.12` - - macOS: `brew install python@3.12` - - Linux: Use your package manager ### Environment Variables @@ -82,42 +79,39 @@ $env:PROJECT_ENDPOINT="https://.services.ai.azure.com/api/project $env:MODEL_DEPLOYMENT_NAME="gpt-4.1-mini" ``` -### Setting Up a Virtual Environment +### Running the Sample + +**Recommended (`uv`):** -It's recommended to use a virtual environment to isolate project dependencies: +We recommend using [uv](https://docs.astral.sh/uv/) to create and manage the virtual environment for this sample. -**macOS/Linux:** ```bash -python -m venv .venv -source .venv/bin/activate +uv venv .venv +uv pip install --prerelease=allow -r requirements.txt +uv run main.py ``` +The sample depends on preview packages, so `--prerelease=allow` is required when installing with `uv`. + +**Alternative (`venv`):** + +If you do not have `uv` installed, you can use Python's built-in `venv` module instead: + **Windows (PowerShell):** + ```powershell python -m venv .venv .\.venv\Scripts\Activate.ps1 +pip install -r requirements.txt +python main.py ``` -### Installing Dependencies - -Install the required Python dependencies using pip: +**macOS/Linux:** ```bash +python -m venv .venv +source .venv/bin/activate pip install -r requirements.txt -``` - -The required packages are: -- `azure-ai-agentserver-agentframework` - Agent Framework and AgentServer SDK -- `python-dotenv` - Load environment variables from `.env` file -- `azure-identity` - Azure authentication -- `azure-monitor-opentelemetry-exporter` - Azure Monitor telemetry export -- `opentelemetry-sdk` / `opentelemetry-api` - OpenTelemetry for tracing - -### Running the Sample - -To run the agent, execute the following command in your terminal: - -```powershell python main.py ``` @@ -126,6 +120,7 @@ This will start the hosted agent locally on `http://localhost:8088/`. ### Interacting with the Agent **PowerShell (Windows):** + ```powershell $body = @{ input = "I need a hotel in Seattle from 2025-03-15 to 2025-03-18, budget under $200 per night" @@ -136,6 +131,7 @@ Invoke-RestMethod -Uri http://localhost:8088/responses -Method Post -Body $body ``` **Bash/curl (Linux/macOS):** + ```bash curl -sS -H "Content-Type: application/json" -X POST http://localhost:8088/responses \ -d '{"input": "Find me hotels in Seattle for March 20-23, 2025 under $200 per night","stream":false}' @@ -163,4 +159,4 @@ Use this command to build the image locally: docker build --platform=linux/amd64 -t image . ``` -This forces the image to be built for the required `amd64` architecture. \ No newline at end of file +This forces the image to be built for the required `amd64` architecture. diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/agent.yaml b/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/agent.yaml similarity index 95% rename from python/samples/05-end-to-end/hosted_agents/foundry_singleagent/agent.yaml rename to python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/agent.yaml index 50abe334b6..2ff03a7557 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/agent.yaml +++ b/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/agent.yaml @@ -1,7 +1,7 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml kind: hosted -name: foundry-singleagent +name: azure_ai_agent_with_local_tool # Brief description of what this agent does description: > A travel assistant agent that helps users find hotels in Seattle. diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py b/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/main.py similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/foundry_singleagent/main.py rename to python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/main.py diff --git a/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/requirements.txt b/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/requirements.txt new file mode 100644 index 0000000000..77e6b3b039 --- /dev/null +++ b/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/requirements.txt @@ -0,0 +1,2 @@ +azure-ai-agentserver-agentframework==1.0.0b16 +agent-framework-azure-ai \ No newline at end of file diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/.dockerignore b/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/.dockerignore similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/foundry_multiagent/.dockerignore rename to python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/.dockerignore diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/.env.sample b/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/.env.sample similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/foundry_singleagent/.env.sample rename to python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/.env.sample diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/Dockerfile b/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/Dockerfile similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/foundry_singleagent/Dockerfile rename to python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/Dockerfile diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/README.md b/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/README.md similarity index 92% rename from python/samples/05-end-to-end/hosted_agents/foundry_multiagent/README.md rename to python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/README.md index beb70ec982..76decb6188 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/README.md +++ b/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/README.md @@ -51,10 +51,6 @@ Before running this sample, ensure you have: 3. **Python 3.10 or higher** - Verify your version: `python --version` - - If you have Python 3.9 or older, install a newer version: - - Windows: `winget install Python.Python.3.12` - - macOS: `brew install python@3.12` - - Linux: Use your package manager ### Environment Variables @@ -80,37 +76,39 @@ $env:PROJECT_ENDPOINT="https://.services.ai.azure.com/api/project $env:MODEL_DEPLOYMENT_NAME="gpt-4.1-mini" ``` -### Setting Up a Virtual Environment +### Running the Sample -It's recommended to use a virtual environment to isolate project dependencies: +**Recommended (`uv`):** -**macOS/Linux:** +We recommend using [uv](https://docs.astral.sh/uv/) to create and manage the virtual environment for this sample. ```bash -python -m venv .venv -source .venv/bin/activate +uv venv .venv +uv pip install --prerelease=allow -r requirements.txt +uv run main.py ``` +The sample depends on preview packages, so `--prerelease=allow` is required when installing with `uv`. + +**Alternative (`venv`):** + +If you do not have `uv` installed, you can use Python's built-in `venv` module instead: + **Windows (PowerShell):** ```powershell python -m venv .venv .\.venv\Scripts\Activate.ps1 +pip install -r requirements.txt +python main.py ``` -### Installing Dependencies - -Install the required Python dependencies using pip: +**macOS/Linux:** ```bash +python -m venv .venv +source .venv/bin/activate pip install -r requirements.txt -``` - -### Running the Sample - -To run the agent, execute the following command in your terminal: - -```powershell python main.py ``` diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/agent.yaml b/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/agent.yaml similarity index 95% rename from python/samples/05-end-to-end/hosted_agents/foundry_multiagent/agent.yaml rename to python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/agent.yaml index 6dd9c40340..dd0b7578a4 100644 --- a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/agent.yaml +++ b/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/agent.yaml @@ -1,7 +1,7 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml kind: hosted -name: foundry-multiagent +name: azure-ai-agents-in-workflow description: > A multi-agent workflow featuring a Writer and Reviewer that collaborate to create and refine content. diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/main.py b/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/main.py similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/foundry_multiagent/main.py rename to python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/main.py diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_multiagent/requirements.txt b/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/requirements.txt similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/foundry_multiagent/requirements.txt rename to python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/requirements.txt diff --git a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt b/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt deleted file mode 100644 index a97eb7f13c..0000000000 --- a/python/samples/05-end-to-end/hosted_agents/foundry_singleagent/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -azure-ai-agentserver-agentframework==1.0.0b16 -agent-framework-azure-ai -python-dotenv -azure-identity - -# Azure Monitor / OpenTelemetry -azure-monitor-opentelemetry-exporter>=1.0.0b46 -opentelemetry-sdk>=1.39.0 -opentelemetry-api>=1.39.0 \ No newline at end of file From ecf1bd431020dbde84073ae765e2dfbd6542f328 Mon Sep 17 00:00:00 2001 From: huimiu Date: Wed, 18 Mar 2026 14:04:49 +0800 Subject: [PATCH 08/10] fix: update Azure AI client import and refactor agent initialization in hotel agent sample --- .../azure_ai_agent_with_local_tool/main.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/main.py b/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/main.py index bbf3a48361..1faad6a2e9 100644 --- a/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/main.py +++ b/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/main.py @@ -11,7 +11,7 @@ from datetime import datetime from typing import Annotated -from agent_framework.azure import AzureAIProjectAgentProvider +from agent_framework.azure import AzureOpenAIResponsesClient from azure.ai.agentserver.agentframework import from_agent_framework from azure.identity.aio import AzureCliCredential, ManagedIdentityCredential from dotenv import load_dotenv @@ -127,15 +127,13 @@ def get_credential(): async def main(): """Main function to run the agent as a web server.""" - async with ( - get_credential() as credential, - AzureAIProjectAgentProvider( + async with get_credential() as credential: + client = AzureOpenAIResponsesClient( project_endpoint=PROJECT_ENDPOINT, - model=MODEL_DEPLOYMENT_NAME, + deployment_name=MODEL_DEPLOYMENT_NAME, credential=credential, - ) as provider, - ): - agent = await provider.create_agent( + ) + agent = client.as_agent( name="SeattleHotelAgent", instructions="""You are a helpful travel assistant specializing in finding hotels in Seattle, Washington. From ea0f1efcc71d0267faea4deef6f1bd847d23edc5 Mon Sep 17 00:00:00 2001 From: huimiu Date: Wed, 18 Mar 2026 16:18:28 +0800 Subject: [PATCH 09/10] feat: add hosted agent samples for Seattle hotel search and writer-reviewer workflow --- .../05-end-to-end/hosted_agents/README.md | 95 ++++--------------- .../.dockerignore | 0 .../.env.sample | 0 .../Dockerfile | 0 .../README.md | 6 +- .../agent.yaml | 0 .../main.py | 0 .../requirements.txt | 0 .../.dockerignore | 0 .../.env.sample | 0 .../Dockerfile | 0 .../README.md | 6 +- .../agent.yaml | 2 +- .../main.py | 16 ++-- .../requirements.txt | 0 15 files changed, 34 insertions(+), 91 deletions(-) rename python/samples/05-end-to-end/hosted_agents/{azure_ai_agent_with_local_tool => agent_with_local_tools}/.dockerignore (100%) rename python/samples/05-end-to-end/hosted_agents/{azure_ai_agent_with_local_tool => agent_with_local_tools}/.env.sample (100%) rename python/samples/05-end-to-end/hosted_agents/{azure_ai_agent_with_local_tool => agent_with_local_tools}/Dockerfile (100%) rename python/samples/05-end-to-end/hosted_agents/{azure_ai_agent_with_local_tool => agent_with_local_tools}/README.md (96%) rename python/samples/05-end-to-end/hosted_agents/{azure_ai_agent_with_local_tool => agent_with_local_tools}/agent.yaml (100%) rename python/samples/05-end-to-end/hosted_agents/{azure_ai_agent_with_local_tool => agent_with_local_tools}/main.py (100%) rename python/samples/05-end-to-end/hosted_agents/{azure_ai_agent_with_local_tool => agent_with_local_tools}/requirements.txt (100%) rename python/samples/05-end-to-end/hosted_agents/{azure_ai_agents_in_workflow => writer_reviewer_agents_in_workflow}/.dockerignore (100%) rename python/samples/05-end-to-end/hosted_agents/{azure_ai_agents_in_workflow => writer_reviewer_agents_in_workflow}/.env.sample (100%) rename python/samples/05-end-to-end/hosted_agents/{azure_ai_agents_in_workflow => writer_reviewer_agents_in_workflow}/Dockerfile (100%) rename python/samples/05-end-to-end/hosted_agents/{azure_ai_agents_in_workflow => writer_reviewer_agents_in_workflow}/README.md (95%) rename python/samples/05-end-to-end/hosted_agents/{azure_ai_agents_in_workflow => writer_reviewer_agents_in_workflow}/agent.yaml (94%) rename python/samples/05-end-to-end/hosted_agents/{azure_ai_agents_in_workflow => writer_reviewer_agents_in_workflow}/main.py (87%) rename python/samples/05-end-to-end/hosted_agents/{azure_ai_agents_in_workflow => writer_reviewer_agents_in_workflow}/requirements.txt (100%) diff --git a/python/samples/05-end-to-end/hosted_agents/README.md b/python/samples/05-end-to-end/hosted_agents/README.md index b5a2f02480..4f067ee4ab 100644 --- a/python/samples/05-end-to-end/hosted_agents/README.md +++ b/python/samples/05-end-to-end/hosted_agents/README.md @@ -4,46 +4,13 @@ These samples demonstrate how to build and host AI agents in Python using the [A ## Samples -| Sample | Description | -|--------|-------------| -| [`agent_with_hosted_mcp`](./agent_with_hosted_mcp/) | Hosted MCP tool that connects to Microsoft Learn via `https://learn.microsoft.com/api/mcp` | -| [`agent_with_text_search_rag`](./agent_with_text_search_rag/) | Retrieval-augmented generation using a custom `BaseContextProvider` with Contoso Outdoors sample data | -| [`agents_in_workflow`](./agents_in_workflow/) | Concurrent workflow that combines researcher, marketer, and legal specialist agents | -| [`azure_ai_agent_with_local_tool`](./azure_ai_agent_with_local_tool/) | Azure AI Foundry project-backed agent with local Python tool execution for Seattle hotel search | -| [`azure_ai_agents_in_workflow`](./azure_ai_agents_in_workflow/) | Azure AI Foundry project-backed Writer/Reviewer workflow | - -## Two Configuration Models - -These samples fall into two groups: - -### Azure OpenAI hosted agent samples - -These use `AzureOpenAIChatClient(...).as_agent(...)` with `DefaultAzureCredential`: - -- [`agent_with_hosted_mcp`](./agent_with_hosted_mcp/) -- [`agent_with_text_search_rag`](./agent_with_text_search_rag/) -- [`agents_in_workflow`](./agents_in_workflow/) - -Required environment variables: - -| Variable | Description | -|----------|-------------| -| `AZURE_OPENAI_ENDPOINT` | Azure OpenAI resource endpoint | -| `AZURE_OPENAI_CHAT_DEPLOYMENT_NAME` | Chat model deployment name | - -### Azure AI Foundry project-backed samples - -These use `AzureAIProjectAgentProvider` and create agents against a Foundry project: - -- [`azure_ai_agent_with_local_tool`](./azure_ai_agent_with_local_tool/) -- [`azure_ai_agents_in_workflow`](./azure_ai_agents_in_workflow/) - -Required environment variables: - -| Variable | Description | -|----------|-------------| -| `PROJECT_ENDPOINT` | Foundry project endpoint, for example `https://.services.ai.azure.com/api/projects/` | -| `MODEL_DEPLOYMENT_NAME` | Model deployment name in that Foundry project | +| Sample | Description | +| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | +| [`agent_with_hosted_mcp`](./agent_with_hosted_mcp/) | Hosted MCP tool that connects to Microsoft Learn via `https://learn.microsoft.com/api/mcp` | +| [`agent_with_text_search_rag`](./agent_with_text_search_rag/) | Retrieval-augmented generation using a custom `BaseContextProvider` with Contoso Outdoors sample data | +| [`agents_in_workflow`](./agents_in_workflow/) | Concurrent workflow that combines researcher, marketer, and legal specialist agents | +| [`agent_with_local_tools`](./agent_with_local_tools/) | Local Python tool execution for Seattle hotel search | +| [`writer_reviewer_agents_in_workflow`](./writer_reviewer_agents_in_workflow/) | Writer/Reviewer workflow using `AzureOpenAIResponsesClient` | ## Common Prerequisites @@ -51,9 +18,7 @@ Before running any sample, ensure you have: 1. Python 3.10 or later 2. [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli) installed -3. Azure access configured for one of these setups: - - An Azure OpenAI resource with a chat model deployment - - An Azure AI Foundry project with a chat model deployment +3. An Azure OpenAI resource or a Microsoft Foundry project with a chat model deployment ### Authenticate with Azure CLI @@ -64,8 +29,6 @@ az login az account show ``` -Samples using `DefaultAzureCredential` will pick up Azure CLI credentials locally. The Foundry project-backed samples use `AzureCliCredential` locally and switch to managed identity automatically when running in Azure. - ## Running a Sample Each sample folder contains its own `requirements.txt`. Run commands from the specific sample directory you want to try. @@ -109,22 +72,18 @@ Each sample starts a hosted agent locally on `http://localhost:8088/`. You can either export variables in your shell or create a local `.env` file in the sample directory. -### Azure OpenAI samples - -Example `.env`: +Example `.env` for Azure OpenAI samples: ```dotenv AZURE_OPENAI_ENDPOINT=https://.openai.azure.com/ -AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=gpt-4o-mini +AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=gpt-4.1 ``` -### Azure AI Foundry project-backed samples - -Example `.env`: +Example `.env` for Foundry project samples: ```dotenv PROJECT_ENDPOINT=https://.services.ai.azure.com/api/projects/ -MODEL_DEPLOYMENT_NAME=gpt-4.1-mini +MODEL_DEPLOYMENT_NAME=gpt-4.1 ``` ## Interacting with the Agent @@ -151,13 +110,13 @@ curl -sS -H "Content-Type: application/json" -X POST http://localhost:8088/respo Example prompts by sample: -| Sample | Example input | -|--------|---------------| -| `agent_with_hosted_mcp` | `What does Microsoft Learn say about managed identities in Azure?` | -| `agent_with_text_search_rag` | `What is Contoso Outdoors' return policy for refunds?` | -| `agents_in_workflow` | `Create a launch strategy for a budget-friendly electric SUV.` | -| `azure_ai_agent_with_local_tool` | `Find me Seattle hotels from 2025-03-15 to 2025-03-18 under $200 per night.` | -| `azure_ai_agents_in_workflow` | `Write a slogan for a new affordable electric SUV.` | +| Sample | Example input | +| ------------------------------------ | ---------------------------------------------------------------------------- | +| `agent_with_hosted_mcp` | `What does Microsoft Learn say about managed identities in Azure?` | +| `agent_with_text_search_rag` | `What is Contoso Outdoors' return policy for refunds?` | +| `agents_in_workflow` | `Create a launch strategy for a budget-friendly electric SUV.` | +| `agent_with_local_tools` | `Find me Seattle hotels from 2025-03-15 to 2025-03-18 under $200 per night.` | +| `writer_reviewer_agents_in_workflow` | `Write a slogan for a new affordable electric SUV.` | ## Deploying to Microsoft Foundry @@ -165,6 +124,7 @@ Each sample includes a `Dockerfile` and `agent.yaml` for deployment. For deploym - [Hosted agents overview](https://learn.microsoft.com/en-us/azure/ai-foundry/agents/concepts/hosted-agents) - [Create a hosted agent with CLI](https://learn.microsoft.com/en-us/azure/ai-foundry/agents/concepts/hosted-agents?tabs=cli#create-a-hosted-agent) +- [Create a hosted agent in Visual Studio Code](https://learn.microsoft.com/en-us/azure/foundry/agents/how-to/vs-code-agents-workflow-pro-code?tabs=windows-powershell&pivots=python) ## Troubleshooting @@ -172,21 +132,6 @@ Each sample includes a `Dockerfile` and `agent.yaml` for deployment. For deploym If startup fails with authentication errors, run `az login` and verify the selected subscription with `az account show`. -### Missing `PROJECT_ENDPOINT` - -The Foundry project-backed samples require `PROJECT_ENDPOINT` and `MODEL_DEPLOYMENT_NAME`. Make sure both are set before running: - -- [`azure_ai_agent_with_local_tool`](./azure_ai_agent_with_local_tool/) -- [`azure_ai_agents_in_workflow`](./azure_ai_agents_in_workflow/) - -### Missing `AZURE_OPENAI_ENDPOINT` or deployment name - -The Azure OpenAI-based samples require `AZURE_OPENAI_ENDPOINT` and `AZURE_OPENAI_CHAT_DEPLOYMENT_NAME`: - -- [`agent_with_hosted_mcp`](./agent_with_hosted_mcp/) -- [`agent_with_text_search_rag`](./agent_with_text_search_rag/) -- [`agents_in_workflow`](./agents_in_workflow/) - ### Preview package install issues These samples depend on preview packages such as `azure-ai-agentserver-agentframework`. Use `uv pip install --prerelease=allow -r requirements.txt` or `pip install -r requirements.txt`. diff --git a/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/.dockerignore b/python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/.dockerignore similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/.dockerignore rename to python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/.dockerignore diff --git a/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/.env.sample b/python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/.env.sample similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/.env.sample rename to python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/.env.sample diff --git a/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/Dockerfile b/python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/Dockerfile similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/Dockerfile rename to python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/Dockerfile diff --git a/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/README.md b/python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/README.md similarity index 96% rename from python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/README.md rename to python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/README.md index 5676b4159a..41fa3660fa 100644 --- a/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/README.md +++ b/python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/README.md @@ -43,8 +43,8 @@ The hosted agent can be deployed to Microsoft Foundry using the Azure Developer Before running this sample, ensure you have: -1. **Azure AI Foundry Project** - - Project created in [Azure AI Foundry](https://learn.microsoft.com/en-us/azure/ai-foundry/what-is-foundry?view=foundry#microsoft-foundry-portals) +1. **Microsoft Foundry Project** + - Project created in [Microsoft Foundry](https://learn.microsoft.com/en-us/azure/ai-foundry/what-is-foundry?view=foundry#microsoft-foundry-portals) - Chat model deployed (e.g., `gpt-4o` or `gpt-4.1`) - Note your project endpoint URL and model deployment name @@ -59,7 +59,7 @@ Before running this sample, ensure you have: Set the following environment variables (matching `agent.yaml`): -- `PROJECT_ENDPOINT` - Your Azure AI Foundry project endpoint URL (required) +- `PROJECT_ENDPOINT` - Your Microsoft Foundry project endpoint URL (required) - `MODEL_DEPLOYMENT_NAME` - The deployment name for your chat model (defaults to `gpt-4.1-mini`) This sample loads environment variables from a local `.env` file if present. diff --git a/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/agent.yaml b/python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/agent.yaml similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/agent.yaml rename to python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/agent.yaml diff --git a/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/main.py b/python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/main.py similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/main.py rename to python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/main.py diff --git a/python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/requirements.txt b/python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/requirements.txt similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/azure_ai_agent_with_local_tool/requirements.txt rename to python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/requirements.txt diff --git a/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/.dockerignore b/python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/.dockerignore similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/.dockerignore rename to python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/.dockerignore diff --git a/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/.env.sample b/python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/.env.sample similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/.env.sample rename to python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/.env.sample diff --git a/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/Dockerfile b/python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/Dockerfile similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/Dockerfile rename to python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/Dockerfile diff --git a/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/README.md b/python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/README.md similarity index 95% rename from python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/README.md rename to python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/README.md index 76decb6188..f4181f6e6b 100644 --- a/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/README.md +++ b/python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/README.md @@ -40,8 +40,8 @@ The hosted agent workflow can be deployed to Microsoft Foundry using the Azure D Before running this sample, ensure you have: -1. **Azure AI Foundry Project** - - Project created in [Azure AI Foundry](https://learn.microsoft.com/en-us/azure/ai-foundry/what-is-foundry?view=foundry#microsoft-foundry-portals) +1. **Microsoft Foundry Project** + - Project created in [Microsoft Foundry](https://learn.microsoft.com/en-us/azure/ai-foundry/what-is-foundry?view=foundry#microsoft-foundry-portals) - Chat model deployed (e.g., `gpt-4o` or `gpt-4.1`) - Note your project endpoint URL and model deployment name @@ -56,7 +56,7 @@ Before running this sample, ensure you have: Set the following environment variables (matching `agent.yaml`): -- `PROJECT_ENDPOINT` - Your Azure AI Foundry project endpoint URL (required) +- `PROJECT_ENDPOINT` - Your Microsoft Foundry project endpoint URL (required) - `MODEL_DEPLOYMENT_NAME` - The deployment name for your chat model (defaults to `gpt-4.1-mini`) This sample loads environment variables from a local `.env` file if present. diff --git a/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/agent.yaml b/python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/agent.yaml similarity index 94% rename from python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/agent.yaml rename to python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/agent.yaml index dd0b7578a4..9a5e63b83f 100644 --- a/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/agent.yaml +++ b/python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/agent.yaml @@ -1,7 +1,7 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml kind: hosted -name: azure-ai-agents-in-workflow +name: writer-reviewer-agents-in-workflow description: > A multi-agent workflow featuring a Writer and Reviewer that collaborate to create and refine content. diff --git a/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/main.py b/python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/main.py similarity index 87% rename from python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/main.py rename to python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/main.py index 9171113c97..af2c049808 100644 --- a/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/main.py +++ b/python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/main.py @@ -5,7 +5,7 @@ from contextlib import asynccontextmanager from agent_framework import WorkflowBuilder -from agent_framework.azure import AzureAIProjectAgentProvider +from agent_framework.azure import AzureOpenAIResponsesClient from azure.ai.agentserver.agentframework import from_agent_framework from azure.identity.aio import AzureCliCredential, ManagedIdentityCredential from dotenv import load_dotenv @@ -33,19 +33,17 @@ def get_credential(): @asynccontextmanager async def create_agents(): - async with ( - get_credential() as credential, - AzureAIProjectAgentProvider( + async with get_credential() as credential: + client = AzureOpenAIResponsesClient( project_endpoint=PROJECT_ENDPOINT, - model=MODEL_DEPLOYMENT_NAME, + deployment_name=MODEL_DEPLOYMENT_NAME, credential=credential, - ) as provider, - ): - writer = await provider.create_agent( + ) + writer = client.as_agent( name="Writer", instructions="You are an excellent content writer. You create new content and edit contents based on the feedback.", ) - reviewer = await provider.create_agent( + reviewer = client.as_agent( name="Reviewer", instructions="You are an excellent content reviewer. Provide actionable feedback to the writer about the provided content in the most concise manner possible.", ) diff --git a/python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/requirements.txt b/python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/requirements.txt similarity index 100% rename from python/samples/05-end-to-end/hosted_agents/azure_ai_agents_in_workflow/requirements.txt rename to python/samples/05-end-to-end/hosted_agents/writer_reviewer_agents_in_workflow/requirements.txt From cceae5823e014716230d45902057c8236f6caa0b Mon Sep 17 00:00:00 2001 From: huimiu Date: Wed, 18 Mar 2026 16:30:45 +0800 Subject: [PATCH 10/10] fix: correct agent name in YAML configuration for local tools agent --- .../hosted_agents/agent_with_local_tools/agent.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/agent.yaml b/python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/agent.yaml index 2ff03a7557..159b31996d 100644 --- a/python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/agent.yaml +++ b/python/samples/05-end-to-end/hosted_agents/agent_with_local_tools/agent.yaml @@ -1,7 +1,7 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml kind: hosted -name: azure_ai_agent_with_local_tool +name: agent-with-local-tools # Brief description of what this agent does description: > A travel assistant agent that helps users find hotels in Seattle.