Skip to content

Latest commit

 

History

History

Folders and files

README.md

Basic Hosted Agent (Responses Protocol)

A minimal Agent Framework agent hosted on Microsoft Foundry using the Responses protocol. This sample demonstrates basic request/response interaction and multi-turn conversations.

How it works

The agent uses FoundryChatClient from the Agent Framework and is served via ResponsesHostServer, which exposes a REST API compatible with the OpenAI Responses protocol. See main.py for the implementation.

Option 1: Azure Developer CLI (azd)

Prerequisites

  1. Azure Developer CLI (azd) — Install azd
  2. Install the AI agent extension:
    azd ext install microsoft.foundry
  3. Authenticate:
    azd auth login

Initialize the agent project

No cloning required. Create a new folder and initialize from the manifest:

mkdir my-basic-agent && cd my-basic-agent

azd ai agent init -m https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/agent-framework/responses/01-basic/azure.yaml

Follow the prompts to configure your Foundry project and model deployment. If you don't have an existing Foundry project, azd ai agent init will guide you through creating one.

Provision Azure resources (if needed)

If you don't already have a Foundry project and model deployment:

azd provision

Run the agent locally

azd ai agent run

The agent host will start on http://localhost:8088.

Invoke the local agent

In a separate terminal, from the project directory:

azd ai agent invoke --local "Hi"

Deploy to Foundry

Once tested locally, deploy to Microsoft Foundry:

azd deploy

For the full deployment guide, see Deploy a hosted agent.

Invoke the deployed agent

azd ai agent invoke "Hi"

Option 2: VS Code (Foundry Toolkit)

Prerequisites

  1. VS Code with the Foundry Toolkit extension installed.
  2. For debugging Python in VS Code, install the Python extension pack.
  3. Python 3.13 or later and uv installed outside the project virtual environment.

Set up the Python virtual environment

  • Create and synchronize the locked environment:

     uv sync --frozen
  • Open the Command Palette (Ctrl+Shift+P), run Python: Select Interpreter, and select the .venv created by uv.

Run and debug the agent

Press F5 to start the agent. The agent starts and the Agent Inspector opens automatically. Chat with the agent in the Inspector.

Or run manually, then open the Inspector

  1. Set the required environment variables and sign in to Azure with the Azure CLI (az login).
  2. Start the agent: uv run --no-sync python main.py (listens on http://localhost:8088).
  3. Command Palette (Ctrl+Shift+P) → Foundry Toolkit: Open Agent Inspector, then send a message to test.

Deploy to Foundry

  1. Open the Command Palette (Ctrl+Shift+P) and run Foundry Toolkit: Deploy Hosted Agent. The extension opens a Deploy Hosted Agent wizard and reads agent.yaml to auto-populate settings.
  2. If prompted, complete Foundry Project Setup to select subscription and project.
  3. On the Basics tab, choose deployment method (Code or Container) and confirm the agent name.
  4. On Review + Deploy, confirm runtime details, pick CPU and Memory size, and click Deploy.
  5. After deployment, invoke the agent in the Agent Playground and stream live logs from the Logs tab.

Next steps