From f545873f93be5a23761c36503edef9a5407d99e6 Mon Sep 17 00:00:00 2001 From: Darren Cohen <39422044+dargilco@users.noreply.github.com> Date: Mon, 16 Nov 2026 12:04:06 -0800 Subject: [PATCH 1/2] First --- .../foundry_hosting/test_sample_azure_yaml.py | 168 ++++++++++++++++++ .../claw_step04_production_ready/.agentignore | 2 - .../claw_step04_production_ready/.gitignore | 3 +- .../claw_step04_production_ready/README.md | 14 +- .../agent.manifest.yaml | 30 ---- .../claw_step04_production_ready/agent.py | 2 +- .../claw_step04_production_ready/agent.yaml | 18 -- .../claw_step04_production_ready/azure.yaml | 51 ++++++ .../claw_step04_production_ready/hosted.py | 2 +- .../hyperlight_codeact/.dockerignore | 4 + .../container/hyperlight_codeact/Dockerfile | 31 +--- .../container/hyperlight_codeact/README.md | 25 ++- .../hyperlight_codeact/agent.manifest.yaml | 24 --- .../container/hyperlight_codeact/agent.yaml | 23 --- .../container/hyperlight_codeact/azure.yaml | 52 ++++++ .../container/hyperlight_codeact/main.py | 3 +- .../hyperlight_codeact/requirements.txt | 8 +- .../foundry-hosted-agents/README.md | 54 +++--- .../invocations/basic/README.md | 6 +- .../invocations/basic/agent.manifest.yaml | 23 --- .../invocations/basic/agent.yaml | 9 - .../invocations/basic/azure.yaml | 51 ++++++ .../break_glass/agent.manifest.yaml | 23 --- .../invocations/break_glass/agent.yaml | 9 - .../invocations/break_glass/azure.yaml | 51 ++++++ .../invocations/telegram/azure.yaml | 26 +-- .../telegram/tests/test_infrastructure.py | 7 +- .../responses/azure_search_rag/README.md | 4 +- .../azure_search_rag/agent.manifest.yaml | 38 ---- .../responses/azure_search_rag/agent.yaml | 16 -- .../responses/azure_search_rag/azure.yaml | 56 ++++++ .../responses/basic/README.md | 2 +- .../responses/basic/agent.manifest.yaml | 23 --- .../responses/basic/agent.yaml | 12 -- .../responses/basic/azure.yaml | 51 ++++++ .../responses/custom_storage/README.md | 2 +- .../custom_storage/agent.manifest.yaml | 29 --- .../responses/custom_storage/agent.yaml | 18 -- .../responses/custom_storage/azure.yaml | 54 ++++++ .../agent.manifest.yaml | 25 --- .../declarative_customer_support/agent.yaml | 12 -- .../declarative_customer_support/azure.yaml | 52 ++++++ .../responses/files/README.md | 3 + .../responses/files/agent.manifest.yaml | 32 ---- .../responses/files/agent.yaml | 14 -- .../responses/files/azure.yaml | 63 +++++++ .../responses/foundry_memory/README.md | 4 +- .../foundry_memory/agent.manifest.yaml | 33 ---- .../responses/foundry_memory/agent.yaml | 14 -- .../responses/foundry_memory/azure.yaml | 54 ++++++ .../responses/foundry_toolbox/.azdignore | 7 +- .../responses/foundry_toolbox/.dockerignore | 5 +- .../responses/foundry_toolbox/README.md | 23 +-- .../foundry_toolbox/agent.manifest.yaml | 30 ---- .../responses/foundry_toolbox/agent.yaml | 13 -- .../responses/foundry_toolbox/azure.yaml | 122 +++++++++++++ .../foundry_toolbox_mcp_skills/.azdignore | 5 - .../foundry_toolbox_mcp_skills/.dockerignore | 1 + .../foundry_toolbox_mcp_skills/README.md | 19 +- .../agent.manifest.yaml | 43 ----- .../foundry_toolbox_mcp_skills/agent.yaml | 20 --- .../foundry_toolbox_mcp_skills/azure.yaml | 57 ++++++ .../responses/mcp/agent.manifest.yaml | 25 --- .../responses/mcp/agent.yaml | 13 -- .../responses/mcp/azure.yaml | 52 ++++++ .../responses/monty_codeact/README.md | 2 +- .../monty_codeact/agent.manifest.yaml | 28 --- .../responses/monty_codeact/agent.yaml | 15 -- .../responses/monty_codeact/azure.yaml | 54 ++++++ .../observability/agent.manifest.yaml | 25 --- .../responses/observability/agent.yaml | 14 -- .../responses/observability/azure.yaml | 52 ++++++ .../agent.manifest.yaml | 18 -- .../agent.yaml | 9 - .../azure.yaml | 43 +++++ .../agent.manifest.yaml | 25 --- .../steerable_long_running_agent/agent.yaml | 12 -- .../steerable_long_running_agent/azure.yaml | 53 ++++++ .../responses/tools/agent.manifest.yaml | 23 --- .../responses/tools/agent.yaml | 11 -- .../responses/tools/azure.yaml | 51 ++++++ .../responses/workflows/agent.manifest.yaml | 23 --- .../responses/workflows/agent.yaml | 11 -- .../responses/workflows/azure.yaml | 51 ++++++ .../foundry-hosted-agent-validation/SKILL.md | 150 +++++++--------- 85 files changed, 1446 insertions(+), 989 deletions(-) create mode 100644 python/packages/foundry_hosting/tests/foundry_hosting/test_sample_azure_yaml.py delete mode 100644 python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/agent.manifest.yaml delete mode 100644 python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/agent.yaml create mode 100644 python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/azure.yaml delete mode 100644 python/samples/04-hosting/container/hyperlight_codeact/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/container/hyperlight_codeact/agent.yaml create mode 100644 python/samples/04-hosting/container/hyperlight_codeact/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/invocations/basic/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/invocations/basic/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/invocations/basic/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/invocations/break_glass/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/invocations/break_glass/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/invocations/break_glass/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/azure_search_rag/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/azure_search_rag/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/azure_search_rag/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/basic/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/basic/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/basic/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/custom_storage/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/custom_storage/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/custom_storage/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/declarative_customer_support/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/declarative_customer_support/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/declarative_customer_support/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/files/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/files/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/files/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/foundry_memory/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/foundry_memory/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/foundry_memory/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/mcp/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/mcp/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/mcp/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/monty_codeact/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/monty_codeact/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/monty_codeact/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/observability/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/observability/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/observability/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/resilient_long_running_workflow/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/resilient_long_running_workflow/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/resilient_long_running_workflow/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/steerable_long_running_agent/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/steerable_long_running_agent/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/steerable_long_running_agent/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/tools/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/tools/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/tools/azure.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/workflows/agent.manifest.yaml delete mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/workflows/agent.yaml create mode 100644 python/samples/04-hosting/foundry-hosted-agents/responses/workflows/azure.yaml diff --git a/python/packages/foundry_hosting/tests/foundry_hosting/test_sample_azure_yaml.py b/python/packages/foundry_hosting/tests/foundry_hosting/test_sample_azure_yaml.py new file mode 100644 index 00000000000..5b998988382 --- /dev/null +++ b/python/packages/foundry_hosting/tests/foundry_hosting/test_sample_azure_yaml.py @@ -0,0 +1,168 @@ +# Copyright (c) Microsoft. All rights reserved. + +import shutil +import subprocess +from pathlib import Path + +import pytest +import yaml + +SAMPLES = Path(__file__).parents[4] / "samples" +HOSTED = SAMPLES / "04-hosting" / "foundry-hosted-agents" + + +@pytest.mark.parametrize( + ("sample", "protocol", "entry_point"), + [ + (HOSTED / "invocations" / "basic", "invocations", "main.py"), + (HOSTED / "invocations" / "break_glass", "invocations", "main.py"), + (HOSTED / "invocations" / "telegram", "invocations", "main.py"), + (HOSTED / "responses" / "azure_search_rag", "responses", "main.py"), + (HOSTED / "responses" / "basic", "responses", "main.py"), + (HOSTED / "responses" / "custom_storage", "responses", "main.py"), + (HOSTED / "responses" / "declarative_customer_support", "responses", "main.py"), + (HOSTED / "responses" / "files", "responses", "main.py"), + (HOSTED / "responses" / "foundry_memory", "responses", "main.py"), + (HOSTED / "responses" / "foundry_toolbox", "responses", "main.py"), + (HOSTED / "responses" / "foundry_toolbox_mcp_skills", "responses", "main.py"), + (HOSTED / "responses" / "mcp", "responses", "main.py"), + (HOSTED / "responses" / "monty_codeact", "responses", "main.py"), + (HOSTED / "responses" / "observability", "responses", "main.py"), + (HOSTED / "responses" / "resilient_long_running_workflow", "responses", "main.py"), + (HOSTED / "responses" / "steerable_long_running_agent", "responses", "main.py"), + (HOSTED / "responses" / "tools", "responses", "main.py"), + (HOSTED / "responses" / "workflows", "responses", "main.py"), + (SAMPLES / "04-hosting" / "container" / "hyperlight_codeact", "responses", "main.py"), + ( + SAMPLES / "02-agents" / "harness" / "build_your_own_claw" / "claw_step04_production_ready", + "responses", + "hosted.py", + ), + ], +) +def test_hosted_agent_uses_a_self_contained_azure_project(sample: Path, protocol: str, entry_point: str) -> None: + config = yaml.safe_load((sample / "azure.yaml").read_text(encoding="utf-8")) + services = config["services"] + projects = {name: service for name, service in services.items() if service["host"] == "azure.ai.project"} + agents = [service for service in services.values() if service["host"] == "azure.ai.agent"] + + assert len(projects) == 1 + assert len(agents) == 1 + agent = agents[0] + assert next(iter(projects)) in agent["uses"] + assert agent["kind"] == "hosted" + assert agent["protocols"] == [{"protocol": protocol, "version": "2.0.0"}] + assert agent["env"]["PYTHONNOUSERSITE"] == "1" + assert "FOUNDRY_PROJECT_ENDPOINT" not in agent["env"] + + source = (sample / agent["project"]).resolve() + assert source.is_relative_to(sample.resolve()) + assert (source / entry_point).is_file() + if "codeConfiguration" in agent: + assert agent["codeConfiguration"]["entryPoint"] == entry_point + else: + assert (source / "Dockerfile").is_file() + assert agent["docker"]["remoteBuild"] is True + assert agent["startupCommand"].endswith(entry_point) + + assert not (sample / "agent.manifest.yaml").exists() + assert not (sample / "agent.yaml").exists() + + if sample.name == "resilient_long_running_workflow": + assert "AZURE_AI_MODEL_DEPLOYMENT_NAME" not in agent["env"] + assert not next(iter(projects.values())).get("deployments") + else: + assert agent["env"]["AZURE_AI_MODEL_DEPLOYMENT_NAME"] == "${AZURE_AI_MODEL_DEPLOYMENT_NAME}" + + if sample.name == "claw_step04_production_ready": + assert agent["env"]["TOOLBOX_MCP_SERVER_URL"] == "${TOOLBOX_MCP_SERVER_URL:-}" + assert agent["env"]["PURVIEW_CLIENT_APP_ID"] == "${PURVIEW_CLIENT_APP_ID:-}" + + +@pytest.mark.parametrize( + ("sample", "expected"), + [ + ("azure_search_rag", ("AZURE_SEARCH_ENDPOINT", "AZURE_SEARCH_INDEX_NAME")), + ("custom_storage", ("AZURE_COSMOS_ENDPOINT", "COSMOS_DATABASE_NAME", "COSMOS_CONTAINER_NAME")), + ("foundry_memory", ("MEMORY_STORE_NAME",)), + ("foundry_toolbox_mcp_skills", ("TOOLBOX_ENDPOINT",)), + ("mcp", ("GITHUB_PAT",)), + ], +) +def test_hosted_agent_passes_sample_specific_configuration(sample: str, expected: tuple[str, ...]) -> None: + config = yaml.safe_load((HOSTED / "responses" / sample / "azure.yaml").read_text(encoding="utf-8")) + agent = next(service for service in config["services"].values() if service["host"] == "azure.ai.agent") + + for name in expected: + assert agent["env"][name] == f"${{{name}}}" + + +def test_files_sample_deploys_its_toolbox_before_the_agent() -> None: + config = yaml.safe_load((HOSTED / "responses" / "files" / "azure.yaml").read_text(encoding="utf-8")) + services = config["services"] + toolbox = services["agent-tools"] + agent = next(service for service in services.values() if service["host"] == "azure.ai.agent") + + assert toolbox["host"] == "azure.ai.toolbox" + assert {tool["type"] for tool in toolbox["tools"]} == {"web_search", "code_interpreter"} + assert "agent-tools" in agent["uses"] + assert agent["env"]["TOOLBOX_NAME"] == "agent-tools" + + +def test_toolbox_sample_wires_the_managed_toolbox_endpoint() -> None: + config = yaml.safe_load((HOSTED / "responses" / "foundry_toolbox" / "azure.yaml").read_text(encoding="utf-8")) + services = config["services"] + toolbox = services["agent-tools"] + agent = next(service for service in services.values() if service["host"] == "azure.ai.agent") + + assert toolbox["host"] == "azure.ai.toolbox" + assert {"ghmcppat", "langmcpconn", "foundrymcpconn"} <= set(toolbox["uses"]) + assert "agent-tools" in agent["uses"] + assert agent["env"]["TOOLBOX_ENDPOINT"] == "${TOOLBOX_AGENT_TOOLS_MCP_ENDPOINT}" + + +@pytest.mark.skipif(shutil.which("git") is None, reason="Git is required to evaluate azd ignore rules") +@pytest.mark.parametrize( + ("sample", "required_files"), + [ + ( + "foundry_toolbox", + ( + Path(".env.example"), + Path("toolbox.yaml"), + Path("scripts") / "list-foundry-connectors.sh", + Path("scripts") / "list-foundry-connectors.ps1", + ), + ), + ( + "foundry_toolbox_mcp_skills", + ( + Path(".env.example"), + Path("toolbox.yaml"), + Path("skills") / "support-style" / "SKILL.md", + Path("skills") / "escalation-policy" / "SKILL.md", + ), + ), + ], +) +def test_toolbox_template_includes_setup_files(tmp_path: Path, sample: str, required_files: tuple[Path, ...]) -> None: + source = HOSTED / "responses" / sample + for path in required_files: + assert (source / path).is_file() + files = (Path(".env"), *required_files) + for path in files: + target = tmp_path / path + target.parent.mkdir(parents=True, exist_ok=True) + target.touch() + (tmp_path / ".gitignore").write_text((source / ".azdignore").read_text(encoding="utf-8"), encoding="utf-8") + subprocess.run(["git", "init", "--quiet", "--template="], cwd=tmp_path, check=True, timeout=30) + result = subprocess.run( + ["git", "-c", "core.excludesfile=", "check-ignore", "--no-index", "--", *files], + cwd=tmp_path, + capture_output=True, + text=True, + check=False, + timeout=30, + ) + assert result.returncode == 0, result.stderr + assert result.stdout.splitlines() == [".env"] diff --git a/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/.agentignore b/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/.agentignore index 4e8de03ee83..ba4107a5595 100644 --- a/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/.agentignore +++ b/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/.agentignore @@ -5,8 +5,6 @@ # To include a file that is excluded by default, use negation: !filename # azd tooling files -agent.yaml -agent.manifest.yaml azure.yaml .agentignore diff --git a/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/.gitignore b/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/.gitignore index 5fe72b02045..347ea51b72a 100644 --- a/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/.gitignore +++ b/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/.gitignore @@ -1,2 +1 @@ -.azure -azure.yaml \ No newline at end of file +.azure \ No newline at end of file diff --git a/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/README.md b/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/README.md index 1d6e3174415..d94958205b7 100644 --- a/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/README.md +++ b/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/README.md @@ -138,17 +138,17 @@ credential-gated behaviors or deployments is proven by an offline smoke check. ### Deploy to Foundry ```bash -cd python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready -azd ai agent init -m agent.manifest.yaml --entry-point hosted.py +mkdir claw-hosted-agent && cd claw-hosted-agent +azd ai agent init -t https://github.com/microsoft/agent-framework/blob/main/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/azure.yaml --src . --model-deployment "" azd deploy ``` -Foundry deploys this agent with **code (ZIP) deployment** — the default for Python hosted agents. -It uploads this folder, installs `requirements.txt`, and runs a Python entry point. Which file runs -is set by `codeConfiguration.entryPoint` in the generated `azure.yaml` and defaults to `main.py`, so -you must point it at `hosted.py`. We therefore pass `--entry-point hosted.py` to -`azd ai agent init`. The deploy packages this folder only, so `skills/` and +Select the existing Foundry project containing that model. Foundry deploys this agent with **code (ZIP) +deployment**: [`azure.yaml`](azure.yaml) sets `codeConfiguration.entryPoint` and `startupCommand` to +`hosted.py`. It uploads this folder and installs `requirements.txt`. The deploy packages this folder only, so `skills/` and `subprocess_script_runner.py` are copied in here, making the folder a self-contained package. +The Toolbox and Purview integrations are optional. Set `TOOLBOX_MCP_SERVER_URL` and +`PURVIEW_CLIENT_APP_ID` with `azd env set` only when using them. ## Run evals diff --git a/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/agent.manifest.yaml b/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/agent.manifest.yaml deleted file mode 100644 index bb9302624b2..00000000000 --- a/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/agent.manifest.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: personal-finance-claw -description: > - A production-ready Agent Framework claw harness for personal finance, hosted by Foundry. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - Harness - - CodeAct - - Monty - - Observability - - Purview -template: - name: personal-finance-claw - kind: hosted - protocols: - - protocol: responses - version: 2.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" - - name: ENABLE_SENSITIVE_DATA - value: "false" - - name: TOOLBOX_MCP_SERVER_URL - value: "{{TOOLBOX_MCP_SERVER_URL}}" - - name: PURVIEW_CLIENT_APP_ID - value: "{{PURVIEW_CLIENT_APP_ID}}" -resources: [] diff --git a/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/agent.py b/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/agent.py index e05a581c8c7..d66ace4d3ec 100644 --- a/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/agent.py +++ b/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/agent.py @@ -213,7 +213,7 @@ def _build_skills_provider(credential: TokenCredential) -> tuple[SkillsProvider, logger.warning( "Foundry skills disabled: TOOLBOX_MCP_SERVER_URL is set but is not an http(s) URL. " "If this looks like an unsubstituted placeholder, check the environment variable wiring " - "in azure.yaml / agent.manifest.yaml.", + "in azure.yaml.", ) else: logger.info("Foundry skills disabled. Set TOOLBOX_MCP_SERVER_URL to enable them.") diff --git a/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/agent.yaml b/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/agent.yaml deleted file mode 100644 index 1cd5f43ac26..00000000000 --- a/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/agent.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml -kind: hosted -name: agent-framework-claw-production-ready-responses -protocols: - - protocol: responses - version: 2.0.0 -resources: - cpu: "0.5" - memory: 1Gi -environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} - - name: ENABLE_SENSITIVE_DATA - value: "false" - - name: TOOLBOX_MCP_SERVER_URL - value: ${TOOLBOX_MCP_SERVER_URL} - - name: PURVIEW_CLIENT_APP_ID - value: ${PURVIEW_CLIENT_APP_ID} diff --git a/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/azure.yaml b/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/azure.yaml new file mode 100644 index 00000000000..7b91d1b8357 --- /dev/null +++ b/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/azure.yaml @@ -0,0 +1,51 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: personal-finance-claw +services: + ai-project: + host: azure.ai.project + personal-finance-claw: + host: azure.ai.agent + project: . + language: python + uses: + - ai-project + kind: hosted + name: personal-finance-claw + description: A production-ready Agent Framework claw harness for personal finance, hosted by Foundry. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - Harness + - CodeAct + - Monty + - Observability + - Purview + protocols: + - protocol: responses + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + ENABLE_SENSITIVE_DATA: 'false' + TOOLBOX_MCP_SERVER_URL: ${TOOLBOX_MCP_SERVER_URL:-} + PURVIEW_CLIENT_APP_ID: ${PURVIEW_CLIENT_APP_ID:-} + PYTHONNOUSERSITE: '1' + startupCommand: python hosted.py + container: + resources: + cpu: '0.5' + memory: 1Gi + codeConfiguration: + dependencyResolution: remote_build + entryPoint: hosted.py + runtime: python_3_13 +infra: + provider: microsoft.foundry diff --git a/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/hosted.py b/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/hosted.py index 110e3f2fa0e..a8bf5a2e729 100644 --- a/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/hosted.py +++ b/python/samples/02-agents/harness/build_your_own_claw/claw_step04_production_ready/hosted.py @@ -23,7 +23,7 @@ default), and the Foundry hosting runtime collects and exports the traces, metrics, and logs — so there is no ``configure_otel_providers()`` call. When deployed, Foundry injects ``APPLICATIONINSIGHTS_CONNECTION_STRING`` automatically. To capture prompt/response content, set -``ENABLE_SENSITIVE_DATA=true`` (see ``agent.yaml``). Because the exporters are Foundry-managed, run +``ENABLE_SENSITIVE_DATA=true`` (see ``azure.yaml``). Because the exporters are Foundry-managed, run this host with ``azd ai agent run`` to see telemetry; running it directly won't export anything. File access and shell are disabled on the hosted container (see ``enable_file_access`` / diff --git a/python/samples/04-hosting/container/hyperlight_codeact/.dockerignore b/python/samples/04-hosting/container/hyperlight_codeact/.dockerignore index 0f0d55d2aec..fbe17687c60 100644 --- a/python/samples/04-hosting/container/hyperlight_codeact/.dockerignore +++ b/python/samples/04-hosting/container/hyperlight_codeact/.dockerignore @@ -1,5 +1,9 @@ .venv __pycache__ +.azure +.git +.env +.env.* *.pyc *.pyo *.pyd diff --git a/python/samples/04-hosting/container/hyperlight_codeact/Dockerfile b/python/samples/04-hosting/container/hyperlight_codeact/Dockerfile index 218ba87b8ba..2deae7170c0 100644 --- a/python/samples/04-hosting/container/hyperlight_codeact/Dockerfile +++ b/python/samples/04-hosting/container/hyperlight_codeact/Dockerfile @@ -1,35 +1,12 @@ -# Build this image with the repository's `python/` directory as the build context so -# the in-tree agent-framework packages can be installed from source. From the repo root: -# -# docker build \ -# -f python/samples/04-hosting/foundry-hosted-agents/responses/08_hyperlight_codeact/Dockerfile \ -# -t .azurecr.io/: \ -# python/ FROM python:3.12-slim -WORKDIR /app +ENV PYTHONNOUSERSITE=1 -# Copy the in-tree agent-framework packages we need. Order matters for editable -# installs because of inter-package dependencies; we install in dependency order -# below. Hyperlight backends are platform gated, so we install them via pip -# resolution rather than copying the wheels. -COPY packages/core /opt/af/core -COPY packages/openai /opt/af/openai -COPY packages/foundry /opt/af/foundry -COPY packages/foundry_hosting /opt/af/foundry_hosting -COPY packages/hyperlight /opt/af/hyperlight - -# Copy just the sample we care about into the user agent location. -COPY samples/04-hosting/foundry-hosted-agents/responses/08_hyperlight_codeact/ /app/user_agent/ WORKDIR /app/user_agent -RUN pip install --no-cache-dir --upgrade pip \ - && pip install --no-cache-dir /opt/af/core \ - && pip install --no-cache-dir /opt/af/openai \ - && pip install --no-cache-dir /opt/af/foundry \ - && pip install --no-cache-dir /opt/af/foundry_hosting \ - && pip install --no-cache-dir /opt/af/hyperlight \ - && if grep -Eq '^[[:space:]]*[^#[:space:]]' requirements.txt; then pip install --no-cache-dir -r requirements.txt; fi +COPY requirements.txt . +RUN pip install --no-cache-dir --pre -r requirements.txt +COPY main.py . EXPOSE 8088 diff --git a/python/samples/04-hosting/container/hyperlight_codeact/README.md b/python/samples/04-hosting/container/hyperlight_codeact/README.md index 44c9a53e918..0f6a96cc49e 100644 --- a/python/samples/04-hosting/container/hyperlight_codeact/README.md +++ b/python/samples/04-hosting/container/hyperlight_codeact/README.md @@ -19,6 +19,9 @@ direct LLM tools. All of this can be run as a container, however not under all c > below). We are working with the platform team to enable a hypervisor-capable > hosting target. +The sample's `azure.yaml` uses the current azd project format, but it does not +remove this hypervisor requirement. + ## How It Works ### Model integration @@ -62,11 +65,27 @@ nested virtualization and `/dev/kvm` device passthrough — for example an Azure VM, AKS nodes with KVM enabled, or Azure Container Instances configured for nested virt. +Build and run the self-contained container on a supported Linux host: + +```bash +docker build -t hyperlight-codeact . +docker run --device=/dev/kvm --env-file .env -p 8088:8088 hyperlight-codeact +``` + +The container also needs Azure identity credentials for its Foundry model. + ## Running the Agent Host -Follow the instructions in the -[Running the Agent Host Locally](../../foundry-hosted-agents//README.md#running-the-agent-host-locally) -section of the README in the Foundry Hosted Agent directory. +To initialize a standalone project for local `azd` use: + +```bash +mkdir hyperlight-codeact && cd hyperlight-codeact +azd ai agent init -t https://github.com/microsoft/agent-framework/blob/main/python/samples/04-hosting/container/hyperlight_codeact/azure.yaml --src . +``` + +Then follow the +[local host instructions](../../foundry-hosted-agents/README.md#running-the-agent-host-locally), +using a host with a supported hypervisor. ## Interacting with the agent diff --git a/python/samples/04-hosting/container/hyperlight_codeact/agent.manifest.yaml b/python/samples/04-hosting/container/hyperlight_codeact/agent.manifest.yaml deleted file mode 100644 index 623c663291f..00000000000 --- a/python/samples/04-hosting/container/hyperlight_codeact/agent.manifest.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: agent-framework-agent-with-hyperlight-codeact-responses -description: > - An Agent Framework agent with a Hyperlight CodeAct sandbox hosted by Foundry. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - Streaming - - Hyperlight CodeAct -template: - name: agent-framework-agent-with-hyperlight-codeact-responses - kind: hosted - protocols: - - protocol: responses - version: 1.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" -resources: - - kind: model - id: gpt-4.1-mini - name: AZURE_AI_MODEL_DEPLOYMENT_NAME diff --git a/python/samples/04-hosting/container/hyperlight_codeact/agent.yaml b/python/samples/04-hosting/container/hyperlight_codeact/agent.yaml deleted file mode 100644 index 3355fb51abf..00000000000 --- a/python/samples/04-hosting/container/hyperlight_codeact/agent.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml - -kind: hosted -name: agent-framework-agent-with-hyperlight-codeact-responses -description: | - An Agent Framework agent with a Hyperlight CodeAct sandbox hosted by Foundry. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - Streaming - - Hyperlight CodeAct -protocols: - - protocol: responses - version: 1.0.0 -resources: - cpu: "1" - memory: 2Gi -environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: gpt-4.1-mini diff --git a/python/samples/04-hosting/container/hyperlight_codeact/azure.yaml b/python/samples/04-hosting/container/hyperlight_codeact/azure.yaml new file mode 100644 index 00000000000..d071826284b --- /dev/null +++ b/python/samples/04-hosting/container/hyperlight_codeact/azure.yaml @@ -0,0 +1,52 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: agent-framework-agent-with-hyperlight-codeact-responses +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-4.1-mini + model: + format: OpenAI + name: gpt-4.1-mini + version: '2025-04-14' + sku: + name: GlobalStandard + capacity: 10 + agent-framework-agent-with-hyperlight-codeact-responses: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + kind: hosted + name: agent-framework-agent-with-hyperlight-codeact-responses + description: An Agent Framework agent with a Hyperlight CodeAct sandbox hosted by Foundry. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - Streaming + - Hyperlight CodeAct + protocols: + - protocol: responses + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '1' + memory: 2Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/container/hyperlight_codeact/main.py b/python/samples/04-hosting/container/hyperlight_codeact/main.py index 55bd3a9d448..ac2ef1de8c4 100644 --- a/python/samples/04-hosting/container/hyperlight_codeact/main.py +++ b/python/samples/04-hosting/container/hyperlight_codeact/main.py @@ -5,8 +5,9 @@ from typing import Annotated, Any, Literal from agent_framework import Agent, tool -from agent_framework.foundry import FoundryChatClient, FoundryChatOptions, ResponsesHostServer +from agent_framework.foundry import FoundryChatClient, FoundryChatOptions from agent_framework.hyperlight import HyperlightCodeActProvider +from agent_framework_foundry_hosting import ResponsesHostServer from azure.identity import DefaultAzureCredential from dotenv import load_dotenv diff --git a/python/samples/04-hosting/container/hyperlight_codeact/requirements.txt b/python/samples/04-hosting/container/hyperlight_codeact/requirements.txt index aab05449a33..10991359000 100644 --- a/python/samples/04-hosting/container/hyperlight_codeact/requirements.txt +++ b/python/samples/04-hosting/container/hyperlight_codeact/requirements.txt @@ -1,3 +1,5 @@ -# agent-framework, agent-framework-foundry-hosting, and agent-framework-hyperlight -# are installed from local source by the Dockerfile (build context = python/). -# Add any sample-only third-party deps here. +agent-framework-foundry +agent-framework-foundry-hosting +agent-framework-hyperlight +azure-identity +python-dotenv diff --git a/python/samples/04-hosting/foundry-hosted-agents/README.md b/python/samples/04-hosting/foundry-hosted-agents/README.md index db81091f2dd..98bb06f9a82 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/README.md +++ b/python/samples/04-hosting/foundry-hosted-agents/README.md @@ -2,7 +2,7 @@ This directory contains samples that demonstrate how to use hosted [Agent Framework](https://github.com/microsoft/agent-framework) agents with different capabilities and configurations on Foundry using the Foundry Hosting Agent service. Each sample includes a README with instructions on how to set up, run, and interact with the agent. -> [IMPORTANT] Migrating from Protocol version 1.0.0 to 2.0.0: Foundry Hosting Agents service has been updated to use Protocol version 2.0.0. If your application is using Protocol version 1.0.0, please upgrade to Protocol version 2.0.0 in your `agent.manifest.yaml` or `agent.yaml` and upgrade to the latest `agent-framework-foundry-hosting` package. `agent-framework-foundry-hosting==1.0.0a260625` is the last version that supports Protocol version 1.0.0. +> [IMPORTANT] Migrating from Protocol version 1.0.0 to 2.0.0: Foundry Hosting Agents service has been updated to use Protocol version 2.0.0. Migrate your deployment configuration to `azure.yaml`, set its protocol version to 2.0.0, and upgrade to the latest `agent-framework-foundry-hosting` package. `agent-framework-foundry-hosting==1.0.0a260625` is the last version that supports Protocol version 1.0.0. > > The `agent-framework-foundry-hosting` Python API surface is intended to remain stable, but protocol 1.0.0 and 2.0.0 are incompatible. ## Samples @@ -22,6 +22,7 @@ This directory contains samples that demonstrate how to use hosted [Agent Framew | 9 | [Foundry Memory](responses/foundry_memory/) | An agent with persistent semantic memory backed by a Microsoft Foundry Memory Store, using `FoundryMemoryProvider` to remember user facts across sessions. | | 10 | [Monty CodeAct](responses/monty_codeact/) | An agent with a Monty-backed CodeAct context provider, exposing a single `execute_code` tool that runs Python in a [pydantic-monty](https://github.com/pydantic/monty) interpreter and invokes typed host tools (`compute`, `fetch_data`) from inside the sandbox. Uses the beta `agent-framework-monty` package. | | 11 | [Foundry Toolbox MCP Skills](responses/foundry_toolbox_mcp_skills/) | An agent that discovers MCP-based skills attached to a Foundry Toolbox and serves them via `SkillsProvider(MCPSkillsSource(...))`, fetching `SKILL.md` bodies and supplementary resources on demand. | +| 12 | [Declarative Customer Support](responses/declarative_customer_support/) | A hosted declarative customer-support workflow. | | 13 | [Custom Storage](responses/custom_storage/) | Trusted user-and-sandbox session snapshots with create-only/ETag writes and managed-identity Cosmos authentication; local snapshots need no account. | | 14 | [Resilient Long-Running Workflow](responses/resilient_long_running_workflow/) | A model-free native background workflow that pairs each outer response snapshot with its exact scoped checkpoint for crash recovery. | | 15 | [Long-Running Agent (steering gated)](responses/steerable_long_running_agent/) | A working long-running Responses agent with ordinary background polling; steering currently fails at host construction until a patched AgentServer SDK is published and verified. | @@ -97,27 +98,36 @@ to workspace, package or sample `pyproject.toml` files. 1. **Azure Developer CLI (`azd`)** - - [Install azd](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd) and the AI agent extension: `azd ext install azure.ai.agents` + - [Install azd](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd) 1.36.0 or later and the Foundry extensions: `azd ext install microsoft.foundry` - Authenticated: `azd auth login` 2. **Azure Subscription** #### Create a new project -**No cloning required**. Create a new folder, point azd at the manifest on GitHub. +**No cloning required.** Create an empty folder and initialize the Basic sample from its unified `azure.yaml`: ```bash mkdir hosted-agent-framework-agent && cd hosted-agent-framework-agent -# Initialize from the manifest -azd ai agent init -m https://github.com/microsoft/agent-framework/blob/main/python/samples/04-hosting/foundry-hosted-agents/responses/basic/agent.manifest.yaml +# Initialize the project in this folder +azd ai agent init -t https://github.com/microsoft/agent-framework/blob/main/python/samples/04-hosting/foundry-hosted-agents/responses/basic/azure.yaml --src . ``` -Follow the instructions from `azd ai agent init` to complete the agent initialization. If you don't have an existing Foundry project and a model deployment, `azd ai agent init` will guide you through creating them. +For another sample, replace `responses/basic` in the URL with its directory, such as `invocations/basic` or +`responses/files`. Follow the initialization prompts. To reuse an existing project and model deployment, add +`--model-deployment ` and select that project. Use `--agent-name ` to avoid creating a +new version of an existing agent with the same name. The selected model deployment is stored in the azd environment as +`AZURE_AI_MODEL_DEPLOYMENT_NAME`; the sample's `azure.yaml` passes it to the agent. + +Run subsequent `azd` commands from the directory containing the initialized `azure.yaml`. The +[azure.yaml reference](https://learn.microsoft.com/en-us/azure/foundry/agents/concepts/azure-yaml-reference) +describes the project and agent services. #### Provision Azure Resources -> This step is only needed if you don't have an existing Foundry project and model deployment. +> Review the `ai-project` service before provisioning. A declared model deployment can create resources and incur +> charges even when using an existing project. Skip this step when the required resources already exist. Run the following command to provision the necessary Azure resources: @@ -136,21 +146,17 @@ This will create the following Azure resources: #### Set Environment Variables -```bash -export FOUNDRY_PROJECT_ENDPOINT="https://.services.ai.azure.com/api/projects/" -export FOUNDRY_MODEL="" -# And any other environment variables required by the sample -``` - -Or in PowerShell: +Initialization configures the selected Foundry project and model in the azd environment. To change the model +deployment after initialization, set the value used by `azure.yaml`: -```powershell -$env:FOUNDRY_PROJECT_ENDPOINT="https://.services.ai.azure.com/api/projects/" -$env:FOUNDRY_MODEL="" -# And any other environment variables required by the sample +```bash +azd env set AZURE_AI_MODEL_DEPLOYMENT_NAME "" ``` -> Note: The environment variables set above are only for the current session. You will need to set them again if you open a new terminal session. if you want to set the environment variables permanently in the azd environment, you can use `azd env set `. +Set any additional sample-specific variables with `azd env set ` as described in that sample's README. +For direct Python runs, use `FOUNDRY_PROJECT_ENDPOINT` and `FOUNDRY_MODEL` in the shell or the sample's `.env` file. +Container samples use Azure Container Registry remote builds; the deploying identity needs permission to run ACR Tasks. +Set `docker.remoteBuild` to `false` in `azure.yaml` to build locally with Docker instead. #### Running the Agent Host @@ -267,7 +273,9 @@ Once you've tested locally, deploy to Microsoft Foundry. If you already have a Foundry project and the necessary Azure resources provisioned, you can skip the setup steps and proceed directly to deploying the agent. -After running `azd ai agent init -m ` and following the prompts to configure your agent, you will have a project ready for deployment. +Initialize the selected sample with `azd ai agent init -t --src .`, adding +`--model-deployment ` to reuse a model in the existing project. Review the project and model +configuration before provisioning or deploying. ### Setting Up a New Foundry Project @@ -281,11 +289,13 @@ Once the project is setup and resources are provisioned, you can deploy the agen azd deploy ``` -> The Foundry hosting infrastructure will inject the following environment variables into your agent at runtime: +> The Foundry hosting infrastructure injects the following environment variables into your agent at runtime: > > - `FOUNDRY_PROJECT_ENDPOINT`: The endpoint URL for the Foundry project where the agent is deployed. -> - `AZURE_AI_MODEL_DEPLOYMENT_NAME`: The azd-managed model deployment name configured by `azd ai agent init`. Sample code prefers `FOUNDRY_MODEL` for local runs and falls back to this hosted value. > - `APPLICATIONINSIGHTS_CONNECTION_STRING`: The connection string for Application Insights to enable telemetry for your agent. +> +> The sample's `azure.yaml` supplies `AZURE_AI_MODEL_DEPLOYMENT_NAME` from the azd environment. Sample code prefers +> `FOUNDRY_MODEL` for local runs and falls back to this hosted value. This will package your agent and deploy it to the Foundry environment, making it accessible through the Foundry project endpoint. Once it's deployed, you can also access the agent through the Foundry UI. diff --git a/python/samples/04-hosting/foundry-hosted-agents/invocations/basic/README.md b/python/samples/04-hosting/foundry-hosted-agents/invocations/basic/README.md index a5bf15b3ba9..eb70caa0620 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/invocations/basic/README.md +++ b/python/samples/04-hosting/foundry-hosted-agents/invocations/basic/README.md @@ -188,6 +188,6 @@ created hosted session and a matching routed query, as described above. Local requests retain the SDK's single-user session fallback. For hosted deployment, use the parent guide with `workflow.py` as the Python -entrypoint (or the container command). The existing basic manifest and -Dockerfile still launch `main.py`; change the entrypoint deliberately rather -than expecting this alternative to replace the agent sample. +entrypoint (or the container command). The existing `azure.yaml` and Dockerfile +still launch `main.py`; change the entrypoint deliberately rather than +expecting this alternative to replace the agent sample. diff --git a/python/samples/04-hosting/foundry-hosted-agents/invocations/basic/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/invocations/basic/agent.manifest.yaml deleted file mode 100644 index ac71182ab62..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/invocations/basic/agent.manifest.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: agent-framework-agent-basic-invocations -description: > - A basic Agent Framework agent hosted by Foundry. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Invocations Protocol - - Streaming -template: - name: agent-framework-agent-basic-invocations - kind: hosted - protocols: - - protocol: invocations - version: 2.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" -resources: - - kind: model - id: gpt-4.1-mini - name: AZURE_AI_MODEL_DEPLOYMENT_NAME diff --git a/python/samples/04-hosting/foundry-hosted-agents/invocations/basic/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/invocations/basic/agent.yaml deleted file mode 100644 index b42a6df045a..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/invocations/basic/agent.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml -kind: hosted -name: agent-framework-agent-basic-invocations -protocols: - - protocol: invocations - version: 2.0.0 -resources: - cpu: "0.25" - memory: "0.5Gi" diff --git a/python/samples/04-hosting/foundry-hosted-agents/invocations/basic/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/invocations/basic/azure.yaml new file mode 100644 index 00000000000..42e4cc20d3f --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/invocations/basic/azure.yaml @@ -0,0 +1,51 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: agent-framework-agent-basic-invocations +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-4.1-mini + model: + format: OpenAI + name: gpt-4.1-mini + version: '2025-04-14' + sku: + name: GlobalStandard + capacity: 10 + agent-framework-agent-basic-invocations: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + kind: hosted + name: agent-framework-agent-basic-invocations + description: A basic Agent Framework agent hosted by Foundry. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Invocations Protocol + - Streaming + protocols: + - protocol: invocations + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/foundry-hosted-agents/invocations/break_glass/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/invocations/break_glass/agent.manifest.yaml deleted file mode 100644 index ac71182ab62..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/invocations/break_glass/agent.manifest.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: agent-framework-agent-basic-invocations -description: > - A basic Agent Framework agent hosted by Foundry. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Invocations Protocol - - Streaming -template: - name: agent-framework-agent-basic-invocations - kind: hosted - protocols: - - protocol: invocations - version: 2.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" -resources: - - kind: model - id: gpt-4.1-mini - name: AZURE_AI_MODEL_DEPLOYMENT_NAME diff --git a/python/samples/04-hosting/foundry-hosted-agents/invocations/break_glass/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/invocations/break_glass/agent.yaml deleted file mode 100644 index b42a6df045a..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/invocations/break_glass/agent.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml -kind: hosted -name: agent-framework-agent-basic-invocations -protocols: - - protocol: invocations - version: 2.0.0 -resources: - cpu: "0.25" - memory: "0.5Gi" diff --git a/python/samples/04-hosting/foundry-hosted-agents/invocations/break_glass/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/invocations/break_glass/azure.yaml new file mode 100644 index 00000000000..42e4cc20d3f --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/invocations/break_glass/azure.yaml @@ -0,0 +1,51 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: agent-framework-agent-basic-invocations +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-4.1-mini + model: + format: OpenAI + name: gpt-4.1-mini + version: '2025-04-14' + sku: + name: GlobalStandard + capacity: 10 + agent-framework-agent-basic-invocations: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + kind: hosted + name: agent-framework-agent-basic-invocations + description: A basic Agent Framework agent hosted by Foundry. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Invocations Protocol + - Streaming + protocols: + - protocol: invocations + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/foundry-hosted-agents/invocations/telegram/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/invocations/telegram/azure.yaml index d5989239be9..dd3da63c49b 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/invocations/telegram/azure.yaml +++ b/python/samples/04-hosting/foundry-hosted-agents/invocations/telegram/azure.yaml @@ -1,5 +1,10 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json +requiredVersions: + azd: ">=1.36.0" + extensions: + azure.ai.agents: ">=1.0.0-beta.20" + azure.ai.projects: ">=1.0.0-beta.14" name: telegram-foundry-hosted-agent services: telegram-agent: @@ -19,19 +24,14 @@ services: description: > Telegram bot routed through API Management to an Agent Framework agent using the Foundry Invocations 2.0 protocol. - environmentVariables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} - - name: AZURE_COSMOS_ENDPOINT - value: ${AZURE_COSMOS_ENDPOINT} - - name: AZURE_COSMOS_DATABASE_NAME - value: ${AZURE_COSMOS_DATABASE_NAME} - - name: AZURE_COSMOS_CONTAINER_NAME - value: ${AZURE_COSMOS_CONTAINER_NAME} - - name: KEY_VAULT_URL - value: ${KEY_VAULT_URL} - - name: ENABLE_SENSITIVE_DATA - value: ${ENABLE_SENSITIVE_DATA} + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + AZURE_COSMOS_ENDPOINT: ${AZURE_COSMOS_ENDPOINT} + AZURE_COSMOS_DATABASE_NAME: ${AZURE_COSMOS_DATABASE_NAME} + AZURE_COSMOS_CONTAINER_NAME: ${AZURE_COSMOS_CONTAINER_NAME} + KEY_VAULT_URL: ${KEY_VAULT_URL} + ENABLE_SENSITIVE_DATA: ${ENABLE_SENSITIVE_DATA} + PYTHONNOUSERSITE: "1" kind: hosted metadata: tags: diff --git a/python/samples/04-hosting/foundry-hosted-agents/invocations/telegram/tests/test_infrastructure.py b/python/samples/04-hosting/foundry-hosted-agents/invocations/telegram/tests/test_infrastructure.py index 0d9bcd0018b..2b767dec3ef 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/invocations/telegram/tests/test_infrastructure.py +++ b/python/samples/04-hosting/foundry-hosted-agents/invocations/telegram/tests/test_infrastructure.py @@ -39,10 +39,13 @@ def test_dependencies_use_sample_local_pyproject() -> None: def test_sensitive_telemetry_is_configurable_for_hosted_agent() -> None: - azure_yaml = (SAMPLE_ROOT / "azure.yaml").read_text() + azure_yaml = yaml.safe_load((SAMPLE_ROOT / "azure.yaml").read_text()) deploy_script = (SAMPLE_ROOT / "deploy.sh").read_text() - assert "ENABLE_SENSITIVE_DATA" in azure_yaml + environment = azure_yaml["services"]["telegram-agent"]["env"] + assert environment["ENABLE_SENSITIVE_DATA"] == "${ENABLE_SENSITIVE_DATA}" + assert environment["AZURE_COSMOS_ENDPOINT"] == "${AZURE_COSMOS_ENDPOINT}" + assert environment["KEY_VAULT_URL"] == "${KEY_VAULT_URL}" assert 'ENABLE_SENSITIVE_DATA="${ENABLE_SENSITIVE_DATA:-true}"' in deploy_script assert 'azd_command env set ENABLE_SENSITIVE_DATA "$ENABLE_SENSITIVE_DATA"' in deploy_script diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/azure_search_rag/README.md b/python/samples/04-hosting/foundry-hosted-agents/responses/azure_search_rag/README.md index 0209037e016..79609798ceb 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/azure_search_rag/README.md +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/azure_search_rag/README.md @@ -191,13 +191,13 @@ Replace the seed documents (or point the sample at an existing index with your o To host the agent on Foundry, follow the instructions in the [Deploying the Agent to Foundry](../../README.md#deploying-the-agent-to-foundry) section of the README in the parent directory. -When deploying, make sure `AZURE_SEARCH_ENDPOINT` and `AZURE_SEARCH_INDEX_NAME` are set in your `azd` environment so they get injected into the hosted container per [`agent.manifest.yaml`](agent.manifest.yaml): +When deploying, make sure `AZURE_SEARCH_ENDPOINT` and `AZURE_SEARCH_INDEX_NAME` are set in your `azd` environment so they get passed to the hosted container by [`azure.yaml`](azure.yaml): ```bash azd env set AZURE_SEARCH_ENDPOINT "https://.search.windows.net" azd env set AZURE_SEARCH_INDEX_NAME "contoso-outdoors" ``` -If these are not set, running `azd ai agent init -m ` will prompt you to enter them interactively. +Initialization from this sample's `azure.yaml` prompts for unresolved values. The deployed agent's Managed Identity needs **Search Index Data Reader** on the Azure AI Search service. diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/azure_search_rag/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/azure_search_rag/agent.manifest.yaml deleted file mode 100644 index 5167dfcaef9..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/azure_search_rag/agent.manifest.yaml +++ /dev/null @@ -1,38 +0,0 @@ -name: agent-framework-agent-azure-search-rag-responses -description: > - An Agent Framework agent with Retrieval Augmented Generation (RAG) capabilities - backed by Azure AI Search. Uses AzureAISearchContextProvider to ground answers - in product documentation indexed in Azure AI Search before each model invocation. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - RAG - - Azure AI Search -template: - name: agent-framework-agent-azure-search-rag-responses - kind: hosted - protocols: - - protocol: responses - version: 2.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" - - name: AZURE_SEARCH_ENDPOINT - value: "{{AZURE_SEARCH_ENDPOINT}}" - - name: AZURE_SEARCH_INDEX_NAME - value: "{{AZURE_SEARCH_INDEX_NAME}}" -parameters: - properties: - - name: AZURE_SEARCH_ENDPOINT - secret: false - description: The endpoint of the Azure AI Search service to use for RAG (e.g., https://my-search-service.search.windows.net) - - name: AZURE_SEARCH_INDEX_NAME - secret: false - description: The name of the Azure AI Search index to use for RAG (e.g., contoso-outdoors) -resources: - - kind: model - id: gpt-4.1-mini - name: AZURE_AI_MODEL_DEPLOYMENT_NAME diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/azure_search_rag/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/azure_search_rag/agent.yaml deleted file mode 100644 index 7ffb60057c5..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/azure_search_rag/agent.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml -kind: hosted -name: agent-framework-agent-azure-search-rag-responses -protocols: - - protocol: responses - version: 2.0.0 -resources: - cpu: "0.25" - memory: "0.5Gi" -environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} - - name: AZURE_SEARCH_ENDPOINT - value: ${AZURE_SEARCH_ENDPOINT} - - name: AZURE_SEARCH_INDEX_NAME - value: ${AZURE_SEARCH_INDEX_NAME} diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/azure_search_rag/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/azure_search_rag/azure.yaml new file mode 100644 index 00000000000..841d4c12791 --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/azure_search_rag/azure.yaml @@ -0,0 +1,56 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: agent-framework-agent-azure-search-rag-responses +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-4.1-mini + model: + format: OpenAI + name: gpt-4.1-mini + version: '2025-04-14' + sku: + name: GlobalStandard + capacity: 10 + agent-framework-agent-azure-search-rag-responses: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + kind: hosted + name: agent-framework-agent-azure-search-rag-responses + description: An Agent Framework agent with Retrieval Augmented Generation (RAG) capabilities backed by Azure AI Search. + Uses AzureAISearchContextProvider to ground answers in product documentation indexed in Azure AI Search before each + model invocation. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - RAG + - Azure AI Search + protocols: + - protocol: responses + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + AZURE_SEARCH_ENDPOINT: ${AZURE_SEARCH_ENDPOINT} + AZURE_SEARCH_INDEX_NAME: ${AZURE_SEARCH_INDEX_NAME} + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/basic/README.md b/python/samples/04-hosting/foundry-hosted-agents/responses/basic/README.md index 479856271ce..8eac73273c4 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/basic/README.md +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/basic/README.md @@ -21,7 +21,7 @@ whether it uses that provider or downstream service storage; the host does not f stored requests. In none of these cases is the caller's `response.id` the downstream service ID. -Run one entry point at a time. The deployment manifest targets `main.py`; select another script to deploy a different +Run one entry point at a time. `azure.yaml` targets `main.py`; select another script to deploy a different mode. Set `FOUNDRY_PROJECT_ENDPOINT` and `FOUNDRY_MODEL` in `.env`, then run `python main.py`. Follow the [parent hosting guide](../../README.md) for local and deployed setup. diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/basic/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/basic/agent.manifest.yaml deleted file mode 100644 index 9547802be6a..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/basic/agent.manifest.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: agent-framework-agent-basic-responses -description: > - A basic Agent Framework agent hosted by Foundry. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - Streaming -template: - name: agent-framework-agent-basic-responses - kind: hosted - protocols: - - protocol: responses - version: 2.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" -resources: - - kind: model - id: gpt-4.1-mini - name: AZURE_AI_MODEL_DEPLOYMENT_NAME diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/basic/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/basic/agent.yaml deleted file mode 100644 index 9408da5eb40..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/basic/agent.yaml +++ /dev/null @@ -1,12 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml -kind: hosted -name: agent-framework-agent-basic-responses -protocols: - - protocol: responses - version: 2.0.0 -resources: - cpu: "0.25" - memory: "0.5Gi" -environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/basic/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/basic/azure.yaml new file mode 100644 index 00000000000..6098f952063 --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/basic/azure.yaml @@ -0,0 +1,51 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: agent-framework-agent-basic-responses +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-4.1-mini + model: + format: OpenAI + name: gpt-4.1-mini + version: '2025-04-14' + sku: + name: GlobalStandard + capacity: 10 + agent-framework-agent-basic-responses: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + kind: hosted + name: agent-framework-agent-basic-responses + description: A basic Agent Framework agent hosted by Foundry. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - Streaming + protocols: + - protocol: responses + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/custom_storage/README.md b/python/samples/04-hosting/foundry-hosted-agents/responses/custom_storage/README.md index 1a812e7f6a4..8a2a44b0cae 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/custom_storage/README.md +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/custom_storage/README.md @@ -93,7 +93,7 @@ factory. It reconstructs history from the outer transcript rather than retaining it on Python instances or enabling inner model storage. Outer `store=false` does not access/write this custom session store. -For hosted use, configure the endpoint/database/container in the manifest and +For hosted use, configure the endpoint/database/container in `azure.yaml` and follow the [parent deployment instructions](../../README.md#deploying-the-agent-to-foundry). The provider closes the Cosmos client and its own credential at shutdown; request clients are closed after their request, including failed tool entry and diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/custom_storage/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/custom_storage/agent.manifest.yaml deleted file mode 100644 index a045ba5333e..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/custom_storage/agent.manifest.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: agent-framework-agent-custom-storage-responses -description: > - An Agent Framework agent that uses custom Cosmos DB session storage when hosted. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - Custom Storage -template: - name: agent-framework-agent-custom-storage-responses - kind: hosted - protocols: - - protocol: responses - version: 2.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" - - name: AZURE_COSMOS_ENDPOINT - value: "{{AZURE_COSMOS_ENDPOINT}}" - - name: COSMOS_DATABASE_NAME - value: "{{COSMOS_DATABASE_NAME}}" - - name: COSMOS_CONTAINER_NAME - value: "{{COSMOS_CONTAINER_NAME}}" -resources: - - kind: model - id: gpt-4.1-mini - name: AZURE_AI_MODEL_DEPLOYMENT_NAME diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/custom_storage/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/custom_storage/agent.yaml deleted file mode 100644 index 4f8a99e5d34..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/custom_storage/agent.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml -kind: hosted -name: agent-framework-agent-custom-storage-responses -protocols: - - protocol: responses - version: 2.0.0 -resources: - cpu: "0.25" - memory: "0.5Gi" -environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} - - name: AZURE_COSMOS_ENDPOINT - value: ${AZURE_COSMOS_ENDPOINT} - - name: COSMOS_DATABASE_NAME - value: ${COSMOS_DATABASE_NAME} - - name: COSMOS_CONTAINER_NAME - value: ${COSMOS_CONTAINER_NAME} diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/custom_storage/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/custom_storage/azure.yaml new file mode 100644 index 00000000000..494c02ba3f0 --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/custom_storage/azure.yaml @@ -0,0 +1,54 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: agent-framework-agent-custom-storage-responses +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-4.1-mini + model: + format: OpenAI + name: gpt-4.1-mini + version: '2025-04-14' + sku: + name: GlobalStandard + capacity: 10 + agent-framework-agent-custom-storage-responses: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + kind: hosted + name: agent-framework-agent-custom-storage-responses + description: An Agent Framework agent that uses custom Cosmos DB session storage when hosted. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - Custom Storage + protocols: + - protocol: responses + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + AZURE_COSMOS_ENDPOINT: ${AZURE_COSMOS_ENDPOINT} + COSMOS_DATABASE_NAME: ${COSMOS_DATABASE_NAME} + COSMOS_CONTAINER_NAME: ${COSMOS_CONTAINER_NAME} + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/declarative_customer_support/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/declarative_customer_support/agent.manifest.yaml deleted file mode 100644 index 584120c871b..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/declarative_customer_support/agent.manifest.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: agent-framework-declarative-customer-support-responses -description: > - A multi-turn Agent Framework declarative (YAML-defined) customer-support - triage workflow hosted by Foundry. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - Declarative Workflow - - Multi-turn -template: - name: agent-framework-declarative-customer-support-responses - kind: hosted - protocols: - - protocol: responses - version: 2.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" -resources: - - kind: model - id: gpt-5.4-mini - name: AZURE_AI_MODEL_DEPLOYMENT_NAME diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/declarative_customer_support/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/declarative_customer_support/agent.yaml deleted file mode 100644 index 44ad3ede5b6..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/declarative_customer_support/agent.yaml +++ /dev/null @@ -1,12 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml -kind: hosted -name: agent-framework-declarative-customer-support-responses -protocols: - - protocol: responses - version: 2.0.0 -resources: - cpu: '0.25' - memory: '0.5Gi' -environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/declarative_customer_support/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/declarative_customer_support/azure.yaml new file mode 100644 index 00000000000..ba39fcbd5d7 --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/declarative_customer_support/azure.yaml @@ -0,0 +1,52 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: agent-framework-declarative-customer-support-responses +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-5.4-mini + model: + format: OpenAI + name: gpt-5.4-mini + version: '2026-03-17' + sku: + name: GlobalStandard + capacity: 10 + agent-framework-declarative-customer-support-responses: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + kind: hosted + name: agent-framework-declarative-customer-support-responses + description: A multi-turn Agent Framework declarative (YAML-defined) customer-support triage workflow hosted by Foundry. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - Declarative Workflow + - Multi-turn + protocols: + - protocol: responses + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/files/README.md b/python/samples/04-hosting/foundry-hosted-agents/responses/files/README.md index 9efc115b127..a1f91d50b0a 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/files/README.md +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/files/README.md @@ -23,6 +23,9 @@ Set `FOUNDRY_PROJECT_ENDPOINT` and `FOUNDRY_MODEL`, plus either `TOOLBOX_ENDPOINT` or `TOOLBOX_NAME`. The Toolbox needs a code-interpreter tool; see the [Toolbox sample](../foundry_toolbox/). Authenticate local runs with `az login`. Deployed runs use the sandbox's managed identity. +This sample's `azure.yaml` declares an `agent-tools` toolbox with code interpreter +and web search and deploys it before the agent. For local runs, that toolbox must +already exist, or you must provide the endpoint of another compatible toolbox. `ResponsesHostServer(agent=create_agent, history_source="host_managed")` creates fresh clients and a Toolbox MCP connection for each request and closes their diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/files/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/files/agent.manifest.yaml deleted file mode 100644 index 01576e0e7f2..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/files/agent.manifest.yaml +++ /dev/null @@ -1,32 +0,0 @@ -name: agent-framework-agent-files-responses -description: > - An Agent Framework agent that can work with files hosted by Foundry. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - Streaming -template: - name: agent-framework-agent-files-responses - kind: hosted - protocols: - - protocol: responses - version: 2.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" - - name: TOOLBOX_NAME - value: "agent-tools" -resources: - - kind: model - id: gpt-4.1-mini - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - - kind: toolbox - name: agent-tools - tools: - - type: web_search - name: web_search - - type: code_interpreter - name: code_interpreter diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/files/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/files/agent.yaml deleted file mode 100644 index 816e6cc15f1..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/files/agent.yaml +++ /dev/null @@ -1,14 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml -kind: hosted -name: agent-framework-agent-files-responses -protocols: - - protocol: responses - version: 2.0.0 -resources: - cpu: "0.25" - memory: "0.5Gi" -environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} - - name: TOOLBOX_NAME - value: "agent-tools" diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/files/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/files/azure.yaml new file mode 100644 index 00000000000..fc78d04e172 --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/files/azure.yaml @@ -0,0 +1,63 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' + azure.ai.toolboxes: '>=1.0.0-beta.8' +name: agent-framework-agent-files-responses +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-4.1-mini + model: + format: OpenAI + name: gpt-4.1-mini + version: '2025-04-14' + sku: + name: GlobalStandard + capacity: 10 + agent-tools: + host: azure.ai.toolbox + uses: + - ai-project + tools: + - type: web_search + name: web_search + - type: code_interpreter + name: code_interpreter + agent-framework-agent-files-responses: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + - agent-tools + kind: hosted + name: agent-framework-agent-files-responses + description: An Agent Framework agent that can work with files hosted by Foundry. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - Streaming + protocols: + - protocol: responses + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + TOOLBOX_NAME: agent-tools + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_memory/README.md b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_memory/README.md index 315e3d92308..13da2b84e14 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_memory/README.md +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_memory/README.md @@ -155,13 +155,13 @@ curl -X POST http://localhost:8088/responses -H "Content-Type: application/json" To host the agent on Foundry, follow the instructions in the [Deploying the Agent to Foundry](../../README.md#deploying-the-agent-to-foundry) section of the README in the parent directory. -When deploying, make sure `MEMORY_STORE_NAME` is set in your `azd` environment so it gets injected into the hosted container per [`agent.manifest.yaml`](agent.manifest.yaml): +When deploying, make sure `MEMORY_STORE_NAME` is set in your `azd` environment so it gets passed to the hosted container by [`azure.yaml`](azure.yaml): ```bash azd env set MEMORY_STORE_NAME "agent_framework_memory" ``` -If these are not set, running `azd ai agent init -m ` will prompt you to enter them interactively. +Initialization from this sample's `azure.yaml` prompts for unresolved values. Provision the Memory Store in the **same project** and grant the deployed managed identity the project-scoped role above. Provisioning, live Memory calls and diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_memory/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_memory/agent.manifest.yaml deleted file mode 100644 index 060e96adec7..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_memory/agent.manifest.yaml +++ /dev/null @@ -1,33 +0,0 @@ -name: agent-framework-agent-foundry-memory-responses -description: > - An Agent Framework agent with persistent semantic memory backed by an - Microsoft Foundry Memory Store. Uses FoundryMemoryProvider to retrieve and - store memories around each model invocation, allowing the agent to remember - facts about a user across sessions. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - Foundry Memory -template: - name: agent-framework-agent-foundry-memory-responses - kind: hosted - protocols: - - protocol: responses - version: 2.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" - - name: MEMORY_STORE_NAME - value: "{{MEMORY_STORE_NAME}}" -parameters: - properties: - - name: MEMORY_STORE_NAME - secret: false - description: The name of the pre-provisioned Foundry Memory Store the agent will use (e.g., agent_framework_memory) -resources: - - kind: model - id: gpt-4.1-mini - name: AZURE_AI_MODEL_DEPLOYMENT_NAME diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_memory/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_memory/agent.yaml deleted file mode 100644 index 53691375eee..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_memory/agent.yaml +++ /dev/null @@ -1,14 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml -kind: hosted -name: agent-framework-agent-foundry-memory-responses -protocols: - - protocol: responses - version: 2.0.0 -resources: - cpu: "0.25" - memory: "0.5Gi" -environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} - - name: MEMORY_STORE_NAME - value: ${MEMORY_STORE_NAME} diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_memory/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_memory/azure.yaml new file mode 100644 index 00000000000..a43240b1585 --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_memory/azure.yaml @@ -0,0 +1,54 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: agent-framework-agent-foundry-memory-responses +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-4.1-mini + model: + format: OpenAI + name: gpt-4.1-mini + version: '2025-04-14' + sku: + name: GlobalStandard + capacity: 10 + agent-framework-agent-foundry-memory-responses: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + kind: hosted + name: agent-framework-agent-foundry-memory-responses + description: An Agent Framework agent with persistent semantic memory backed by an Microsoft Foundry Memory Store. Uses + FoundryMemoryProvider to retrieve and store memories around each model invocation, allowing the agent to remember facts + about a user across sessions. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - Foundry Memory + protocols: + - protocol: responses + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + MEMORY_STORE_NAME: ${MEMORY_STORE_NAME} + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/.azdignore b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/.azdignore index 7eac03bae35..2eea525d885 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/.azdignore +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/.azdignore @@ -1,6 +1 @@ -agent.manifest.yaml -agent.yaml -.env.example -.env -toolbox.yaml -./scripts \ No newline at end of file +.env \ No newline at end of file diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/.dockerignore b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/.dockerignore index 0d6619bae00..d77b4d2074a 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/.dockerignore +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/.dockerignore @@ -4,4 +4,7 @@ __pycache__ *.pyo *.pyd .Python -.env \ No newline at end of file +.env +.env.example +toolbox.yaml +scripts \ No newline at end of file diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/README.md b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/README.md index 1d1962379c8..e04fc24bdc3 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/README.md +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/README.md @@ -65,7 +65,8 @@ For `ghmcpoauth`, create an OAuth2-based connection to the GitHub MCP server: azd ai connection create ghmcpoauth --kind remote-tool --target https://api.githubcopilot.com/mcp --auth-type oauth2 --connector-name foundrygithubmcp -p https://.services.ai.azure.com/api/projects/ ``` -> This sample uses `ghmcppat` by default, but you can switch to `ghmcpoauth` in the `toolbox.yaml` file. +> This sample uses `ghmcppat` by default. To use `ghmcpoauth`, update `toolbox.yaml` for a manually created +> toolbox, or the connection and toolbox services in `azure.yaml` for an azd-managed deployment. For `langmcpconn`, create an agent-identity-based connection to the Azure Language MCP server: @@ -126,7 +127,7 @@ Native code-interpreter file citations are a separate tracked behavior #### Prerequisites -1. **Azure Developer CLI (`azd`)** — [Install azd](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd) (1.34.2 or later) +1. **Azure Developer CLI (`azd`)** — [Install azd](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd) (1.36.0 or later) 2. Install the unified Foundry CLI extension bundle (provides `azd ai agent`, `connection`, `inspector`, `project`, `routine`, `skill`, and `toolbox`): ```bash # If you previously installed individual extensions, uninstall them first: @@ -134,7 +135,7 @@ Native code-interpreter file citations are a separate tracked behavior # azd ext uninstall azure.ai.toolboxes azd ext install microsoft.foundry ``` - Requires `azure.ai.agents` 1.0.0-beta.19 or later for `-t`. + Requires `azure.ai.agents` 1.0.0-beta.20 or later and `azure.ai.projects` 1.0.0-beta.14 or later. 3. Authenticate: ```bash azd auth login @@ -143,15 +144,17 @@ Native code-interpreter file citations are a separate tracked behavior #### Initialize the agent project -No cloning required. Create a new folder and initialize from the manifest: +No cloning required. Create an empty folder and initialize from this sample's `azure.yaml`: ```bash mkdir my-toolbox-agent && cd my-toolbox-agent -azd ai agent init -t https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/agent-framework/responses/04-foundry-toolbox/azure.yaml +azd ai agent init -t https://github.com/microsoft/agent-framework/blob/main/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/azure.yaml --src . ``` -Follow the prompts to configure your Foundry project. If you don't have an existing Foundry project, `azd ai agent init` will guide you through creating one. Initializing also sets the selected project as the active project for the `azd ai` commands that follow. +Follow the prompts to configure your Foundry project. To reuse an existing model deployment, add +`--model-deployment ` and select its project. Initializing also sets the selected project as +the active project for the `azd ai` commands that follow. Run every subsequent command from the initialized project directory containing `azure.yaml`. If initialization reports a different output directory, change to that directory first. @@ -163,14 +166,14 @@ Run every subsequent command from the initialized project directory containing ` > - [Toolbox overview](https://github.com/microsoft/GitHub-Copilot-for-Azure/blob/main/plugins/azure-skills/skills/microsoft-foundry/foundry-agent/toolbox/toolbox.md) — toolbox concept, API shape and schema, versions, endpoints, and MCP protocol. > - [Use toolbox in a hosted agent](https://github.com/microsoft/GitHub-Copilot-for-Azure/blob/main/plugins/azure-skills/skills/microsoft-foundry/foundry-agent/create/references/use-toolbox-in-hosted-agent.md) — endpoint resolution, env-var contract, payload shape, code integration patterns, and tracing. -The agent reads the toolbox's MCP endpoint from `TOOLBOX_ENDPOINT`. The initialized `azure.yaml` declares the toolbox and its connections. `azd deploy --all` below creates them. If you entered the correct dependency values during initialization, skip these commands. Use them only to correct or replace those values: +The agent reads the toolbox's MCP endpoint from `TOOLBOX_ENDPOINT`. The initialized `azure.yaml` declares the toolbox and its connections. `azd provision` below creates the connections; `azd deploy --all` creates the toolbox and agent. If you entered the correct dependency values during initialization, skip these commands. Use them only to correct or replace those values: ```bash azd env set GITHUB_MCP_PAT "" azd env set AZURE_LANGUAGE_MCP_ENDPOINT "https://.cognitiveservices.azure.com/language/mcp?api-version=2025-11-15-preview" ``` -The first version becomes the default automatically. Use `azd ai toolbox list`, `azd ai toolbox show agent-tools`, and `azd ai toolbox version list agent-tools` to inspect, and `azd ai toolbox delete agent-tools --force` to remove it. +After deployment, the first version becomes the default automatically. Use `azd ai toolbox list`, `azd ai toolbox show agent-tools`, and `azd ai toolbox version list agent-tools` to inspect, and `azd ai toolbox delete agent-tools --force` to remove it. To stage incremental changes safely, use `azd ai toolbox connection add/remove` and `azd ai toolbox skill add/list/remove`; each creates a new toolbox version that carries forward existing connections and skills but **doesn't** change the default. Promote a version with `azd ai toolbox publish agent-tools ` when you're ready to make it active. @@ -235,7 +238,7 @@ azd ai agent invoke "What tools do you have?" #### Create the project 1. Open the Command Palette (`Ctrl+Shift+P`) and run **Foundry Toolkit: Create Hosted Agent**. -2. Select this sample from the gallery. The extension scaffolds the project into a new workspace and generates `agent.yaml`, `.env`, and `.vscode/tasks.json` + `launch.json` automatically. +2. Select this sample from the gallery and follow the extension's project setup instructions. 3. Complete the **Foundry Project Setup** to pick the subscription and Foundry project (or create a new one). #### Run and debug the agent @@ -249,7 +252,7 @@ Press **F5** to start the agent in debug mode. The agent host will start on `htt #### 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. +1. Open the Command Palette (`Ctrl+Shift+P`) and run **Foundry Toolkit: Deploy Hosted Agent**. Review the configuration in the deployment wizard. 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**. diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/agent.manifest.yaml deleted file mode 100644 index 770bb0100ff..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/agent.manifest.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: agent-framework-agent-with-foundry-toolbox-responses -description: > - An Agent Framework agent with Foundry Toolbox integration. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - Streaming -template: - name: agent-framework-agent-with-foundry-toolbox-responses - kind: hosted - protocols: - - protocol: responses - version: 2.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" - - name: TOOLBOX_ENDPOINT - # Full MCP endpoint of the toolbox the agent consumes. Create the toolbox - # from the bundled toolbox.yaml, then copy the versioned endpoint it prints - # and store it in your azd environment before you run or deploy: - # azd ai toolbox create my-toolbox --from-file ./toolbox.yaml - # azd env set TOOLBOX_ENDPOINT "" - value: "{{TOOLBOX_ENDPOINT}}" -resources: - - kind: model - id: gpt-4.1 - name: AZURE_AI_MODEL_DEPLOYMENT_NAME diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/agent.yaml deleted file mode 100644 index 3711356799e..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/agent.yaml +++ /dev/null @@ -1,13 +0,0 @@ -kind: hosted -name: agent-framework-agent-with-foundry-toolbox-responses -protocols: - - protocol: responses - version: 2.0.0 -resources: - cpu: "0.25" - memory: 0.5Gi -environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} - - name: TOOLBOX_ENDPOINT - value: ${TOOLBOX_ENDPOINT} diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/azure.yaml new file mode 100644 index 00000000000..c9b1279ec64 --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox/azure.yaml @@ -0,0 +1,122 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' + azure.ai.connections: '>=1.0.0-beta.8' + azure.ai.toolboxes: '>=1.0.0-beta.8' +name: agent-framework-agent-with-foundry-toolbox-responses +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-4.1 + model: + format: OpenAI + name: gpt-4.1 + version: '2025-04-14' + sku: + name: GlobalStandard + capacity: 10 + ghmcppat: + host: azure.ai.connection + uses: + - ai-project + category: RemoteTool + target: https://api.githubcopilot.com/mcp + authType: CustomKeys + credentials: + type: CustomKeys + keys: + Authorization: Bearer ${GITHUB_MCP_PAT} + env: + GITHUB_MCP_PAT: ${GITHUB_MCP_PAT} + langmcpconn: + host: azure.ai.connection + uses: + - ai-project + category: RemoteTool + target: ${AZURE_LANGUAGE_MCP_ENDPOINT} + authType: ProjectManagedIdentity + audience: https://cognitiveservices.azure.com/ + env: + AZURE_LANGUAGE_MCP_ENDPOINT: ${AZURE_LANGUAGE_MCP_ENDPOINT} + foundrymcpconn: + host: azure.ai.connection + uses: + - ai-project + category: RemoteTool + target: https://mcp.ai.azure.com + authType: UserEntraToken + audience: https://mcp.ai.azure.com + agent-tools: + host: azure.ai.toolbox + uses: + - ai-project + - ghmcppat + - langmcpconn + - foundrymcpconn + description: Multiple MCP servers behind one endpoint + env: + AZURE_LANGUAGE_MCP_ENDPOINT: ${AZURE_LANGUAGE_MCP_ENDPOINT} + tools: + - type: web_search + name: web_search + require_approval: never + - type: code_interpreter + name: code_interpreter + require_approval: never + - type: mcp + server_label: noauth_mcp + server_url: https://gitmcp.io/Azure/azure-rest-api-specs + require_approval: never + - type: mcp + server_label: github + server_url: https://api.githubcopilot.com/mcp + connection: ghmcppat + require_approval: never + - type: mcp + server_label: language-mcp + server_url: ${AZURE_LANGUAGE_MCP_ENDPOINT} + connection: langmcpconn + require_approval: never + - type: mcp + server_label: foundry-mcp + server_url: https://mcp.ai.azure.com + connection: foundrymcpconn + require_approval: never + agent-framework-agent-with-foundry-toolbox-responses: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + - agent-tools + kind: hosted + name: agent-framework-agent-with-foundry-toolbox-responses + description: An Agent Framework agent with Foundry Toolbox integration. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - Streaming + protocols: + - protocol: responses + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + TOOLBOX_ENDPOINT: ${TOOLBOX_AGENT_TOOLS_MCP_ENDPOINT} + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/.azdignore b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/.azdignore index e228002119e..4c49bd78f1d 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/.azdignore +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/.azdignore @@ -1,6 +1 @@ -agent.manifest.yaml -agent.yaml -.env.example .env -toolbox.yaml -skills diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/.dockerignore b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/.dockerignore index 67a9a78b35d..46468a5b1a4 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/.dockerignore +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/.dockerignore @@ -5,5 +5,6 @@ __pycache__ *.pyd .Python .env +.env.example skills toolbox.yaml diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/README.md b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/README.md index 509ad01d419..c184419965b 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/README.md +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/README.md @@ -67,7 +67,7 @@ Each file includes a unique `*-CANARY-*` token that the model is asked to echo, - Python 3.12+ - A Microsoft Foundry project with a deployed model (e.g., `gpt-5`) -- **Azure Developer CLI (`azd`)** 1.25+ with the unified Foundry extension bundle: +- **Azure Developer CLI (`azd`)** 1.36.0+ with the unified Foundry extension bundle: ```bash azd extension install microsoft.foundry ``` @@ -77,6 +77,19 @@ Each file includes a unique `*-CANARY-*` token that the model is asked to echo, Your identity (and, in production, the Managed Identity running the container) needs the **Foundry User** role (formerly *Azure AI User*) on the Foundry project. This covers creating skills, creating the toolbox, and discovering skills over MCP at runtime. +## Initialize the sample + +Create a project directory and initialize it from the sample's `azure.yaml`: + +```bash +mkdir hosted-toolbox-mcp-skills && cd hosted-toolbox-mcp-skills +azd ai agent init -t https://github.com/microsoft/agent-framework/blob/main/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/azure.yaml --src . +``` + +Select the Foundry project and model deployment when prompted, then run the +following commands in that directory against the same project. The toolbox +endpoint is configured after the toolbox is created. + ## Building the toolbox from zero The agent reads the toolbox's MCP endpoint from `TOOLBOX_ENDPOINT`. Before you can run it, create the skills in your Foundry project and then create a toolbox that references them. @@ -154,7 +167,7 @@ Because skills are loaded on demand, a canary token in a response proves the mod Once tested locally, deploy to Microsoft Foundry by following the [Deploying the Agent to Foundry](../../README.md#deploying-the-agent-to-foundry) section of the parent README. -Make sure the skills and toolbox exist in the **same** Foundry project you deploy to (run the steps above against it first), and that `TOOLBOX_ENDPOINT` is set in your `azd` environment so it is injected into the hosted container per [`agent.manifest.yaml`](agent.manifest.yaml): +Make sure the skills and toolbox exist in the **same** Foundry project you deploy to (run the steps above against it first), and that `TOOLBOX_ENDPOINT` is set in your `azd` environment so it is passed to the hosted container by [`azure.yaml`](azure.yaml): ```bash azd env set TOOLBOX_ENDPOINT "" @@ -166,4 +179,4 @@ resource access are distinct permission checks; successful discovery alone does not prove a skill body can be loaded. Provisioning skills, Toolbox resources and permissions requires external setup and is not exercised by offline checks. -> The bundled `skills/` folder and `toolbox.yaml` are authoring inputs only; they are excluded from the deployed container via [`.azdignore`](.azdignore) / [`.dockerignore`](.dockerignore). The running agent discovers everything it needs from the toolbox MCP endpoint. +> The bundled `skills/` folder and `toolbox.yaml` are authoring inputs only; they are excluded from the deployed container via [`.dockerignore`](.dockerignore). The running agent discovers everything it needs from the toolbox MCP endpoint. diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/agent.manifest.yaml deleted file mode 100644 index 148e7ad11fa..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/agent.manifest.yaml +++ /dev/null @@ -1,43 +0,0 @@ -name: hosted-toolbox-mcp-skills -displayName: "Hosted Toolbox MCP Skills Agent" - -description: > - A hosted agent that discovers MCP-based skills from a Foundry Toolbox - and makes them available to the agent via the agent skills provider. - -metadata: - tags: - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - Agent Framework - - MCP - - Model Context Protocol - - Agent Skills - - Foundry Toolbox - - Foundry Toolbox Skills - -template: - name: hosted-toolbox-mcp-skills - kind: hosted - protocols: - - protocol: responses - version: 2.0.0 - resources: - cpu: "0.25" - memory: 0.5Gi - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" - - name: TOOLBOX_ENDPOINT - # Full versioned MCP endpoint of the skills toolbox the agent consumes. - # Create the skills and toolbox from the bundled skills/ folder and - # toolbox.yaml, then copy the versioned endpoint it prints and store it - # in your azd environment before you run or deploy: - # azd ai toolbox create maf-skills-toolbox --from-file ./toolbox.yaml - # azd env set TOOLBOX_ENDPOINT "" - value: "{{TOOLBOX_ENDPOINT}}" -resources: - - kind: model - id: gpt-5 - name: AZURE_AI_MODEL_DEPLOYMENT_NAME diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/agent.yaml deleted file mode 100644 index 75d676ed187..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/agent.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml -kind: hosted -name: hosted-toolbox-mcp-skills -protocols: - - protocol: responses - version: 2.0.0 -resources: - cpu: "0.25" - memory: 0.5Gi -environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} - - name: TOOLBOX_ENDPOINT - # Full versioned MCP endpoint of the skills toolbox the agent consumes. - # Create the skills and toolbox from the bundled skills/ folder and - # toolbox.yaml, then copy the versioned endpoint it prints and store it in - # your azd environment before you run or deploy: - # azd ai toolbox create maf-skills-toolbox --from-file ./toolbox.yaml - # azd env set TOOLBOX_ENDPOINT "" - value: ${TOOLBOX_ENDPOINT} diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/azure.yaml new file mode 100644 index 00000000000..b21298175e8 --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/foundry_toolbox_mcp_skills/azure.yaml @@ -0,0 +1,57 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: hosted-toolbox-mcp-skills +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-5 + model: + format: OpenAI + name: gpt-5 + version: '2025-08-07' + sku: + name: GlobalStandard + capacity: 10 + hosted-toolbox-mcp-skills: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + kind: hosted + name: hosted-toolbox-mcp-skills + description: A hosted agent that discovers MCP-based skills from a Foundry Toolbox and makes them available to the agent + via the agent skills provider. + metadata: + tags: + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - Agent Framework + - MCP + - Model Context Protocol + - Agent Skills + - Foundry Toolbox + - Foundry Toolbox Skills + protocols: + - protocol: responses + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + TOOLBOX_ENDPOINT: ${TOOLBOX_ENDPOINT} + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/mcp/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/mcp/agent.manifest.yaml deleted file mode 100644 index 70eae4a779f..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/mcp/agent.manifest.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: agent-framework-agent-with-remote-mcp-tools-responses -description: > - An Agent Framework agent with remote MCP tools hosted by Foundry. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - Streaming -template: - name: agent-framework-agent-with-remote-mcp-tools-responses - kind: hosted - protocols: - - protocol: responses - version: 2.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" - - name: GITHUB_PAT - value: ${GITHUB_PAT} -resources: - - kind: model - id: gpt-4.1-mini - name: AZURE_AI_MODEL_DEPLOYMENT_NAME diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/mcp/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/mcp/agent.yaml deleted file mode 100644 index 5f9fb3d6add..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/mcp/agent.yaml +++ /dev/null @@ -1,13 +0,0 @@ -kind: hosted -name: agent-framework-agent-with-remote-mcp-tools-responses -protocols: - - protocol: responses - version: 2.0.0 -resources: - cpu: "0.25" - memory: 0.5Gi -environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} - - name: GITHUB_PAT - value: ${GITHUB_PAT} diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/mcp/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/mcp/azure.yaml new file mode 100644 index 00000000000..9d6b347e047 --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/mcp/azure.yaml @@ -0,0 +1,52 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: agent-framework-agent-with-remote-mcp-tools-responses +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-4.1-mini + model: + format: OpenAI + name: gpt-4.1-mini + version: '2025-04-14' + sku: + name: GlobalStandard + capacity: 10 + agent-framework-agent-with-remote-mcp-tools-responses: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + kind: hosted + name: agent-framework-agent-with-remote-mcp-tools-responses + description: An Agent Framework agent with remote MCP tools hosted by Foundry. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - Streaming + protocols: + - protocol: responses + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + GITHUB_PAT: ${GITHUB_PAT} + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/monty_codeact/README.md b/python/samples/04-hosting/foundry-hosted-agents/responses/monty_codeact/README.md index 7bf5d5fb7e8..0cc8d6419f7 100644 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/monty_codeact/README.md +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/monty_codeact/README.md @@ -54,7 +54,7 @@ sandbox; the registered host tools retain full Python access. ### Observability -Agent Framework's [native OpenTelemetry instrumentation](https://learn.microsoft.com/en-us/agent-framework/agents/observability?pivots=programming-language-python) is enabled by setting these env vars in `agent.yaml` / `agent.manifest.yaml`: +Agent Framework's [native OpenTelemetry instrumentation](https://learn.microsoft.com/en-us/agent-framework/agents/observability?pivots=programming-language-python) is enabled by setting these env vars in [`azure.yaml`](azure.yaml): - `ENABLE_INSTRUMENTATION=true` — turns on the framework's span/metric/log emitters. - `ENABLE_SENSITIVE_DATA=false` — the default; sensitive payload capture is opt-in for approved debugging only. diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/monty_codeact/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/monty_codeact/agent.manifest.yaml deleted file mode 100644 index cf678721b52..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/monty_codeact/agent.manifest.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: agent-framework-agent-monty-codeact-responses -description: > - An Agent Framework agent with a Monty-backed CodeAct context provider hosted by Foundry. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - CodeAct - - Monty -template: - name: agent-framework-agent-monty-codeact-responses - kind: hosted - protocols: - - protocol: responses - version: 2.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" - - name: ENABLE_INSTRUMENTATION - value: "true" - - name: ENABLE_SENSITIVE_DATA - value: "false" -resources: - - kind: model - id: gpt-4.1-mini - name: AZURE_AI_MODEL_DEPLOYMENT_NAME diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/monty_codeact/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/monty_codeact/agent.yaml deleted file mode 100644 index 041f5a5745a..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/monty_codeact/agent.yaml +++ /dev/null @@ -1,15 +0,0 @@ -kind: hosted -name: agent-framework-agent-monty-codeact-responses -protocols: - - protocol: responses - version: 2.0.0 -resources: - cpu: "0.25" - memory: 0.5Gi -environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} - - name: ENABLE_INSTRUMENTATION - value: "true" - - name: ENABLE_SENSITIVE_DATA - value: "false" diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/monty_codeact/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/monty_codeact/azure.yaml new file mode 100644 index 00000000000..3cf4a5208ba --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/monty_codeact/azure.yaml @@ -0,0 +1,54 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: agent-framework-agent-monty-codeact-responses +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-4.1-mini + model: + format: OpenAI + name: gpt-4.1-mini + version: '2025-04-14' + sku: + name: GlobalStandard + capacity: 10 + agent-framework-agent-monty-codeact-responses: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + kind: hosted + name: agent-framework-agent-monty-codeact-responses + description: An Agent Framework agent with a Monty-backed CodeAct context provider hosted by Foundry. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - CodeAct + - Monty + protocols: + - protocol: responses + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + ENABLE_INSTRUMENTATION: 'true' + ENABLE_SENSITIVE_DATA: 'false' + PYTHONNOUSERSITE: '1' + startupCommand: uv run --no-sync python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/observability/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/observability/agent.manifest.yaml deleted file mode 100644 index 2d5f20c3d86..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/observability/agent.manifest.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: agent-framework-agent-observability-responses -description: > - A basic Agent Framework agent hosted by Foundry. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - Streaming -template: - name: agent-framework-agent-observability-responses - kind: hosted - protocols: - - protocol: responses - version: 2.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" - - name: ENABLE_SENSITIVE_DATA - value: "false" -resources: - - kind: model - id: gpt-4.1-mini - name: AZURE_AI_MODEL_DEPLOYMENT_NAME diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/observability/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/observability/agent.yaml deleted file mode 100644 index 6ce2a78704a..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/observability/agent.yaml +++ /dev/null @@ -1,14 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml -kind: hosted -name: agent-framework-agent-observability-responses -protocols: - - protocol: responses - version: 2.0.0 -resources: - cpu: "0.25" - memory: "0.5Gi" -environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} - - name: ENABLE_SENSITIVE_DATA - value: "false" diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/observability/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/observability/azure.yaml new file mode 100644 index 00000000000..963e3c905d7 --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/observability/azure.yaml @@ -0,0 +1,52 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: agent-framework-agent-observability-responses +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-4.1-mini + model: + format: OpenAI + name: gpt-4.1-mini + version: '2025-04-14' + sku: + name: GlobalStandard + capacity: 10 + agent-framework-agent-observability-responses: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + kind: hosted + name: agent-framework-agent-observability-responses + description: A basic Agent Framework agent hosted by Foundry. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - Streaming + protocols: + - protocol: responses + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + ENABLE_SENSITIVE_DATA: 'false' + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/resilient_long_running_workflow/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/resilient_long_running_workflow/agent.manifest.yaml deleted file mode 100644 index 7502e04fc2f..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/resilient_long_running_workflow/agent.manifest.yaml +++ /dev/null @@ -1,18 +0,0 @@ -name: agent-framework-resilient-long-running-workflow -description: > - A hosted agent that demonstrates a resilient long-running workflow using the Responses protocol. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - Streaming - - Workflows - - Resilience -template: - name: agent-framework-resilient-long-running-workflow - kind: hosted - protocols: - - protocol: responses - version: 2.0.0 diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/resilient_long_running_workflow/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/resilient_long_running_workflow/agent.yaml deleted file mode 100644 index 09728900fe2..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/resilient_long_running_workflow/agent.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml -kind: hosted -name: agent-framework-resilient-long-running-workflow -protocols: - - protocol: responses - version: 2.0.0 -resources: - cpu: "0.25" - memory: "0.5Gi" diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/resilient_long_running_workflow/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/resilient_long_running_workflow/azure.yaml new file mode 100644 index 00000000000..35465af3ab1 --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/resilient_long_running_workflow/azure.yaml @@ -0,0 +1,43 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: agent-framework-resilient-long-running-workflow +services: + ai-project: + host: azure.ai.project + agent-framework-resilient-long-running-workflow: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + kind: hosted + name: agent-framework-resilient-long-running-workflow + description: A hosted agent that demonstrates a resilient long-running workflow using the Responses protocol. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - Streaming + - Workflows + - Resilience + protocols: + - protocol: responses + version: 2.0.0 + env: + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/steerable_long_running_agent/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/steerable_long_running_agent/agent.manifest.yaml deleted file mode 100644 index d9a59b8b978..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/steerable_long_running_agent/agent.manifest.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: agent-framework-steerable-long-running-agent -description: > - A long-running Responses agent with background polling. Steering is temporarily gated until - a patched AgentServer SDK is published and verified. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - Streaming - - Background -template: - name: agent-framework-steerable-long-running-agent - kind: hosted - protocols: - - protocol: responses - version: 2.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" -resources: - - kind: model - id: gpt-4.1-mini - name: AZURE_AI_MODEL_DEPLOYMENT_NAME diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/steerable_long_running_agent/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/steerable_long_running_agent/agent.yaml deleted file mode 100644 index eb5b5340403..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/steerable_long_running_agent/agent.yaml +++ /dev/null @@ -1,12 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/AgentSchema/refs/heads/main/schemas/v1.0/ContainerAgent.yaml -kind: hosted -name: agent-framework-steerable-long-running-agent -protocols: - - protocol: responses - version: 2.0.0 -resources: - cpu: "0.25" - memory: "0.5Gi" -environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/steerable_long_running_agent/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/steerable_long_running_agent/azure.yaml new file mode 100644 index 00000000000..a4303f57bcc --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/steerable_long_running_agent/azure.yaml @@ -0,0 +1,53 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: agent-framework-steerable-long-running-agent +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-4.1-mini + model: + format: OpenAI + name: gpt-4.1-mini + version: '2025-04-14' + sku: + name: GlobalStandard + capacity: 10 + agent-framework-steerable-long-running-agent: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + kind: hosted + name: agent-framework-steerable-long-running-agent + description: A long-running Responses agent with background polling. Steering is temporarily gated until a patched AgentServer + SDK is published and verified. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - Streaming + - Background + protocols: + - protocol: responses + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/tools/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/tools/agent.manifest.yaml deleted file mode 100644 index 42840f80d34..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/tools/agent.manifest.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: agent-framework-agent-with-local-tools-responses -description: > - An Agent Framework agent with local tools hosted by Foundry. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - Streaming -template: - name: agent-framework-agent-with-local-tools-responses - kind: hosted - protocols: - - protocol: responses - version: 2.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" -resources: - - kind: model - id: gpt-4.1-mini - name: AZURE_AI_MODEL_DEPLOYMENT_NAME diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/tools/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/tools/agent.yaml deleted file mode 100644 index 2a27cd4f002..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/tools/agent.yaml +++ /dev/null @@ -1,11 +0,0 @@ -kind: hosted -name: agent-framework-agent-with-local-tools-responses -protocols: - - protocol: responses - version: 2.0.0 -resources: - cpu: "0.25" - memory: 0.5Gi -environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/tools/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/tools/azure.yaml new file mode 100644 index 00000000000..22accf9e912 --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/tools/azure.yaml @@ -0,0 +1,51 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: agent-framework-agent-with-local-tools-responses +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-4.1-mini + model: + format: OpenAI + name: gpt-4.1-mini + version: '2025-04-14' + sku: + name: GlobalStandard + capacity: 10 + agent-framework-agent-with-local-tools-responses: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + kind: hosted + name: agent-framework-agent-with-local-tools-responses + description: An Agent Framework agent with local tools hosted by Foundry. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - Streaming + protocols: + - protocol: responses + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/workflows/agent.manifest.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/workflows/agent.manifest.yaml deleted file mode 100644 index 6305ab4d792..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/workflows/agent.manifest.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: agent-framework-workflows-responses -description: > - An Agent Framework workflow hosted by Foundry. -metadata: - tags: - - Agent Framework - - AI Agent Hosting - - Azure AI AgentServer - - Responses Protocol - - Streaming -template: - name: agent-framework-workflows-responses - kind: hosted - protocols: - - protocol: responses - version: 2.0.0 - environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: "{{AZURE_AI_MODEL_DEPLOYMENT_NAME}}" -resources: - - kind: model - id: gpt-5.4 - name: AZURE_AI_MODEL_DEPLOYMENT_NAME diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/workflows/agent.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/workflows/agent.yaml deleted file mode 100644 index db73258994b..00000000000 --- a/python/samples/04-hosting/foundry-hosted-agents/responses/workflows/agent.yaml +++ /dev/null @@ -1,11 +0,0 @@ -kind: hosted -name: agent-framework-workflows-responses -protocols: - - protocol: responses - version: 2.0.0 -resources: - cpu: "0.25" - memory: 0.5Gi -environment_variables: - - name: AZURE_AI_MODEL_DEPLOYMENT_NAME - value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} diff --git a/python/samples/04-hosting/foundry-hosted-agents/responses/workflows/azure.yaml b/python/samples/04-hosting/foundry-hosted-agents/responses/workflows/azure.yaml new file mode 100644 index 00000000000..c3dc8e4a4c5 --- /dev/null +++ b/python/samples/04-hosting/foundry-hosted-agents/responses/workflows/azure.yaml @@ -0,0 +1,51 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +requiredVersions: + azd: '>=1.36.0' + extensions: + azure.ai.agents: '>=1.0.0-beta.20' + azure.ai.projects: '>=1.0.0-beta.14' +name: agent-framework-workflows-responses +services: + ai-project: + host: azure.ai.project + deployments: + - name: gpt-5.4 + model: + format: OpenAI + name: gpt-5.4 + version: '2026-03-05' + sku: + name: GlobalStandard + capacity: 10 + agent-framework-workflows-responses: + host: azure.ai.agent + project: . + language: docker + docker: + remoteBuild: true + uses: + - ai-project + kind: hosted + name: agent-framework-workflows-responses + description: An Agent Framework workflow hosted by Foundry. + metadata: + tags: + - Agent Framework + - AI Agent Hosting + - Azure AI AgentServer + - Responses Protocol + - Streaming + protocols: + - protocol: responses + version: 2.0.0 + env: + AZURE_AI_MODEL_DEPLOYMENT_NAME: ${AZURE_AI_MODEL_DEPLOYMENT_NAME} + PYTHONNOUSERSITE: '1' + startupCommand: python main.py + container: + resources: + cpu: '0.25' + memory: 0.5Gi +infra: + provider: microsoft.foundry diff --git a/python/scripts/sample_validation/skills/foundry-hosted-agent-validation/SKILL.md b/python/scripts/sample_validation/skills/foundry-hosted-agent-validation/SKILL.md index 87ac362b523..48e034a565a 100644 --- a/python/scripts/sample_validation/skills/foundry-hosted-agent-validation/SKILL.md +++ b/python/scripts/sample_validation/skills/foundry-hosted-agent-validation/SKILL.md @@ -24,8 +24,8 @@ checks, plus cleanup: 3. **Deployed** — `azd deploy` to Foundry, then invoke the hosted agent. Each check must succeed for **single-turn** and **multi-turn** (session / -`previous_response_id`) conversation. Always end with **cleanup** (delete the -deployed agent, remove the temp `azd` project, restore the sample dir). +`previous_response_id`) conversation. Always end with **cleanup** of the +agent and temporary project created for the validation. > Read the sample's own `README.md` and the parent > `.../foundry-hosted-agents/README.md` first — they define the run/deploy @@ -44,22 +44,22 @@ Gather these: `/subscriptions//resourceGroups//providers/Microsoft.CognitiveServices/accounts//projects/`. Find it with `az cognitiveservices account list` + the project name. - **A real, deployed model name** in that project (e.g. `gpt-4.1-mini`). This is - often **different** from the model id in `agent.manifest.yaml` — the actual - deployment name wins. + often **different** from the model declared in `azure.yaml`. The + model-free workflow sample does not need one. - **An existing ACR to reuse** for deployment (login server, e.g. `myacr.azurecr.io`). Reusing one avoids `azd provision` creating resources. -- Whether a like-named agent **already exists** in the project (remove it first - for a clean validation — see below). +- A **unique agent name** for the validation, so deployment does not create a + new version of an existing agent. ## Tooling / auth - `az` (logged in: `az login`) and `azd` (logged in: `azd auth login`). -- `azd` **agents extension**: `azd extension list` should show - `azure.ai.agents`; install with `azd extension install azure.ai.agents`. +- `azd` 1.36.0 or later and the Foundry extensions: install them with + `azd extension install microsoft.foundry`. - `uv` for the native-Python local run. **`python` need not be on PATH** — `uv` and `azd ai agent run` provision their own interpreter. -- Docker is **not** required when you reuse an ACR (`remoteBuild: true` builds - in ACR Tasks). +- Container deployment needs a local Docker build or an ACR remote build, with + the permissions required by the chosen build path. --- @@ -68,8 +68,8 @@ Gather these: A responses/invocations sample folder typically contains: `main.py` (entry point + agent `ResponsesHostServer`/`InvocationsHostServer`, or native `ResponsesWorkflowHostServer`/`InvocationsWorkflowHostServer` with a request-aware factory and parser), -`agent.manifest.yaml` (used by `azd ai agent init`), `agent.yaml` (the deployed -agent definition), `requirements.txt`, `Dockerfile`, `.env.example`. +`azure.yaml` (the project and hosted-agent definition used by +`azd ai agent init -t`), `requirements.txt`, `Dockerfile`, `.env.example`. **The sample is the whole directory whose entry point is `main.py` — not every `.py` file in it.** Other Python files in (or alongside) a sample folder are @@ -77,8 +77,8 @@ agent definition), `requirements.txt`, `Dockerfile`, `.env.example`. script as an individual sample — validate the sample via its `main.py` host, and run a helper only when the sample's `README.md` calls for it as a setup. -Note the **protocol** (`responses` or `invocations`) from `agent.yaml` / -manifest — it changes the invoke command (`--protocol invocations`) and the HTTP +Note the **protocol** (`responses` or `invocations`) from the agent service in +`azure.yaml` — it changes the invoke command (`--protocol invocations`) and the HTTP path (`/responses` vs the invocations route). --- @@ -100,7 +100,8 @@ FOUNDRY_MODEL="" ``` Start the server (`python main.py`) — it listens on `http://localhost:8088`. -`main.py` uses `DefaultAzureCredential`, so `az login` must be current. +The local Azure credential requires a current `az login`; check the sample's +README for additional authentication requirements. The sample code prefers `FOUNDRY_MODEL` locally and falls back to the azd-managed `AZURE_AI_MODEL_DEPLOYMENT_NAME` when hosted. @@ -158,25 +159,22 @@ out of scope for the cached playbook. ### Init the azd project (once) Run in an **empty temp directory outside the repo** (short path avoids Windows -path-length issues, e.g. `C:\afval\`). Point `-m` at the **local** -manifest so it validates the working-tree sample: +path-length issues, e.g. `C:\afval\`). Point `-t` at the **local** +`azure.yaml` so it validates the working-tree sample: ```bash -azd ai agent init -m /agent.manifest.yaml \ +azd ai agent init -t /azure.yaml --src . \ --project-id "" \ --model-deployment "" \ - --agent-name "" \ - --no-prompt --force + --agent-name "" \ + --no-prompt ``` -`init` downloads the template into a **subfolder named after the agent**, so the -azd project root is `//`. `cd` there for all later `azd` -commands. +Omit `--model-deployment` for a model-free sample. With `--src .`, the current +temporary directory is the project root; run subsequent commands there. -> **Before init, remove any `.venv` you created in the sample dir** — `init` -> copies the entire manifest directory into `src/`. (`.venv` is excluded from -> deploy packaging by `.agentignore`/`.dockerignore`, so it is harmless but -> bloats/slows the copy.) +> Use a clean sample source without a local `.venv` or credential-bearing `.env`; +> initialization copies the referenced source into the temporary project. ### Fix the model deployment name (critical — see Gotcha 1) @@ -184,10 +182,13 @@ commands. azd env set AZURE_AI_MODEL_DEPLOYMENT_NAME "" ``` +The agent service passes this value to the container. Check any sample-specific +environment values as well. + ### Run and invoke locally ```bash -azd ai agent run --no-inspector # auto-creates a uv venv + installs deps; listens on :8088 +azd ai agent run --no-client # installs deps and listens on :8088 azd ai agent invoke --local --new-session "My name is Tao. Remember it." azd ai agent invoke --local "What is my name?" # same session is reused automatically ``` @@ -197,24 +198,11 @@ azd ai agent invoke --local "What is my name?" # same session is reused automa --- -## Removing a pre-existing agent (do this before deploying) - -`init` prints a warning if the agent name already exists in the project. To -delete it, note that **`azd ai agent delete`/`show` resolve the deployed agent -name from an azd env var, not from the positional argument.** The var is -`AGENT_{SERVICEKEY}_NAME`, where `SERVICEKEY` = the `azure.yaml` service name -uppercased with `-`/spaces → `_`. - -Example for service `agent-framework-agent-basic-responses`: - -```bash -azd env set AGENT_AGENT_FRAMEWORK_AGENT_BASIC_RESPONSES_NAME agent-framework-agent-basic-responses -azd ai agent delete --force --no-prompt --output json -# -> {"object":"agent.deleted","name":"...","deleted":true} -``` +## Choose a unique validation agent -(After a successful `azd deploy`, this var is set automatically, so later -`show`/`delete`/`invoke` work without setting it.) +Pass a unique `--agent-name` during initialization. Reusing an existing name +creates another version of that agent; do not remove an existing agent as a +prerequisite for validating the sample. --- @@ -222,25 +210,28 @@ azd ai agent delete --force --no-prompt --output json ### Reuse an existing ACR (avoid provisioning) -For an existing project + model, **do not run `azd provision`/`azd up`** — the -generated `azure.yaml` has a `deployments` block for the manifest's model -(often an auto-selected `GlobalProvisionedManaged` PTU SKU) that provision would -try to create (costly / quota failures). Instead reuse an ACR: +For an existing project + model, avoid `azd provision`/`azd up` when the sample +doesn't need other resources: its `azure.yaml` can declare a model deployment +that provisioning would try to create. When container deployment is configured, +reuse an ACR: ```bash azd env set AZURE_CONTAINER_REGISTRY_ENDPOINT # e.g. myacr.azurecr.io +azd env set AZURE_CONTAINER_REGISTRY_RESOURCE_ID "" azd deploy ``` -`azd deploy` fails with _"could not determine container registry endpoint"_ if -this is unset and no ACR is provisioned. +Check the ACR permissions for the selected local or remote build path. Code +deployment does not require an ACR. Some samples, such as Foundry Toolbox, +declare connections that `azd provision` must create first; follow their setup +instructions and review the model declarations before provisioning. ### Verify the deployed model env var, then invoke ```bash -azd ai agent show --output json # check definition.environment_variables.AZURE_AI_MODEL_DEPLOYMENT_NAME -azd ai agent invoke --new-session "My name is Tao. Remember it." -azd ai agent invoke "What is my name?" +azd ai agent show --output json # check definition.environment_variables.AZURE_AI_MODEL_DEPLOYMENT_NAME +azd ai agent invoke --new-session "My name is Tao. Remember it." +azd ai agent invoke "What is my name?" ``` Use `--output raw` on invoke to see raw SSE events and any failure, e.g.: @@ -251,8 +242,7 @@ event: response.failed ``` `DeploymentNotFound` means the deployed `AZURE_AI_MODEL_DEPLOYMENT_NAME` points -at a model that isn't deployed → fix per Gotcha 1 and redeploy (creates a new -version). +at a model that isn't deployed. Update the azd model value and redeploy. **Pass:** agent reaches `status: active`, invoke returns text (not empty, no `response.failed`), and multi-turn recalls the name. @@ -261,48 +251,34 @@ version). ## Cleanup (always) -- Delete the deployed agent: `azd ai agent delete --force --no-prompt`. +- Delete only the validation agent created for this run, with explicit approval. - Delete the temp `azd` project directory. - Remove `.env`/`.venv` you created in the sample dir; confirm the sample dir is pristine (`git status --porcelain ` is empty — `.env`/`.venv` are gitignored). -- Stop any leftover local server still holding port 8088: - `Get-NetTCPConnection -LocalPort 8088 -State Listen` → `Stop-Process -Id ` - (Linux/macOS: `lsof -ti:8088 | xargs kill`). Stopping the shell may leave the - child interpreter running. +- Stop any leftover local server started for this validation, using its recorded + process ID. Stopping the shell may leave the child interpreter running. --- ## Gotchas (the parts that waste the most time) -1. **The deployed model name comes from `agent.yaml`, not the azd env.** - `azd ai agent init` ignores `--model-deployment` in `--no-prompt` mode and - writes the **manifest's** model id (e.g. `gpt-4.1-mini`) as a **literal** into - both the azd env `AZURE_AI_MODEL_DEPLOYMENT_NAME` and the generated - `src//agent.yaml` env var. Local runs read the azd env (so - `azd env set` fixes them), but **deployment injects `agent.yaml`'s value**. - Fix by setting the generated `agent.yaml` env var to the template - `value: ${AZURE_AI_MODEL_DEPLOYMENT_NAME}` (what the repo sample already uses; - `init` flattens it) **and** `azd env set AZURE_AI_MODEL_DEPLOYMENT_NAME `, - then redeploy. A literal `value: ` also works. - -2. **`azd ai agent delete/show` need the `AGENT_{SERVICEKEY}_NAME` env var** — a - bare positional agent name is treated as the _service_ name and the deployed - agent name is looked up from that env var (see "Removing a pre-existing - agent"). - -3. **`azd provision`/`azd up` will try to create the manifest's model - deployment** (from `azure.yaml`'s `deployments` block). Prefer `azd deploy` - with a reused ACR when the project + model already exist. - -4. **`python` on PATH is not required.** `uv venv` and `azd ai agent run` +1. **The model deployment name must match the existing project.** Pass + `--model-deployment` during initialization and verify + `AZURE_AI_MODEL_DEPLOYMENT_NAME` in the azd environment and in the deployed + agent. + +2. **`azd provision`/`azd up` can create the model deployment** declared in + `azure.yaml`. Review it before provisioning an existing project. + +3. **`python` on PATH is not required.** `uv venv` and `azd ai agent run` provision their own interpreter and install `requirements.txt`. -5. **`init` copies the whole manifest directory into `src/`.** Remove a local - `.venv` from the sample dir first to keep the copy clean/fast. +4. **`init -t` copies the referenced source.** Keep local virtual environments + out of the source to keep the copy clean and fast. -6. **Port 8088 can stay bound after stopping the shell** — kill the interpreter - by PID (see Cleanup). +5. **Port 8088 can stay bound after stopping the shell** — stop only the + interpreter started by this validation, by PID (see Cleanup). --- @@ -310,7 +286,7 @@ version). - [ ] Native local run: 200 + non-empty text + multi-turn recall. - [ ] `azd ai agent run` local: text returned + session reused across invokes. -- [ ] Pre-existing agent removed (if any). +- [ ] Unique validation agent name selected. - [ ] `azd deploy` succeeds; agent `status: active`. - [ ] `azd ai agent show` confirms `AZURE_AI_MODEL_DEPLOYMENT_NAME` = the real deployed model. From 288f334330b82d003198c0a134de4a33fa0cebe9 Mon Sep 17 00:00:00 2001 From: Darren Cohen <39422044+dargilco@users.noreply.github.com> Date: Mon, 16 Nov 2026 12:19:46 -0800 Subject: [PATCH 2/2] Python: Remove hosted sample configuration tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../foundry_hosting/test_sample_azure_yaml.py | 168 ------------------ 1 file changed, 168 deletions(-) delete mode 100644 python/packages/foundry_hosting/tests/foundry_hosting/test_sample_azure_yaml.py diff --git a/python/packages/foundry_hosting/tests/foundry_hosting/test_sample_azure_yaml.py b/python/packages/foundry_hosting/tests/foundry_hosting/test_sample_azure_yaml.py deleted file mode 100644 index 5b998988382..00000000000 --- a/python/packages/foundry_hosting/tests/foundry_hosting/test_sample_azure_yaml.py +++ /dev/null @@ -1,168 +0,0 @@ -# Copyright (c) Microsoft. All rights reserved. - -import shutil -import subprocess -from pathlib import Path - -import pytest -import yaml - -SAMPLES = Path(__file__).parents[4] / "samples" -HOSTED = SAMPLES / "04-hosting" / "foundry-hosted-agents" - - -@pytest.mark.parametrize( - ("sample", "protocol", "entry_point"), - [ - (HOSTED / "invocations" / "basic", "invocations", "main.py"), - (HOSTED / "invocations" / "break_glass", "invocations", "main.py"), - (HOSTED / "invocations" / "telegram", "invocations", "main.py"), - (HOSTED / "responses" / "azure_search_rag", "responses", "main.py"), - (HOSTED / "responses" / "basic", "responses", "main.py"), - (HOSTED / "responses" / "custom_storage", "responses", "main.py"), - (HOSTED / "responses" / "declarative_customer_support", "responses", "main.py"), - (HOSTED / "responses" / "files", "responses", "main.py"), - (HOSTED / "responses" / "foundry_memory", "responses", "main.py"), - (HOSTED / "responses" / "foundry_toolbox", "responses", "main.py"), - (HOSTED / "responses" / "foundry_toolbox_mcp_skills", "responses", "main.py"), - (HOSTED / "responses" / "mcp", "responses", "main.py"), - (HOSTED / "responses" / "monty_codeact", "responses", "main.py"), - (HOSTED / "responses" / "observability", "responses", "main.py"), - (HOSTED / "responses" / "resilient_long_running_workflow", "responses", "main.py"), - (HOSTED / "responses" / "steerable_long_running_agent", "responses", "main.py"), - (HOSTED / "responses" / "tools", "responses", "main.py"), - (HOSTED / "responses" / "workflows", "responses", "main.py"), - (SAMPLES / "04-hosting" / "container" / "hyperlight_codeact", "responses", "main.py"), - ( - SAMPLES / "02-agents" / "harness" / "build_your_own_claw" / "claw_step04_production_ready", - "responses", - "hosted.py", - ), - ], -) -def test_hosted_agent_uses_a_self_contained_azure_project(sample: Path, protocol: str, entry_point: str) -> None: - config = yaml.safe_load((sample / "azure.yaml").read_text(encoding="utf-8")) - services = config["services"] - projects = {name: service for name, service in services.items() if service["host"] == "azure.ai.project"} - agents = [service for service in services.values() if service["host"] == "azure.ai.agent"] - - assert len(projects) == 1 - assert len(agents) == 1 - agent = agents[0] - assert next(iter(projects)) in agent["uses"] - assert agent["kind"] == "hosted" - assert agent["protocols"] == [{"protocol": protocol, "version": "2.0.0"}] - assert agent["env"]["PYTHONNOUSERSITE"] == "1" - assert "FOUNDRY_PROJECT_ENDPOINT" not in agent["env"] - - source = (sample / agent["project"]).resolve() - assert source.is_relative_to(sample.resolve()) - assert (source / entry_point).is_file() - if "codeConfiguration" in agent: - assert agent["codeConfiguration"]["entryPoint"] == entry_point - else: - assert (source / "Dockerfile").is_file() - assert agent["docker"]["remoteBuild"] is True - assert agent["startupCommand"].endswith(entry_point) - - assert not (sample / "agent.manifest.yaml").exists() - assert not (sample / "agent.yaml").exists() - - if sample.name == "resilient_long_running_workflow": - assert "AZURE_AI_MODEL_DEPLOYMENT_NAME" not in agent["env"] - assert not next(iter(projects.values())).get("deployments") - else: - assert agent["env"]["AZURE_AI_MODEL_DEPLOYMENT_NAME"] == "${AZURE_AI_MODEL_DEPLOYMENT_NAME}" - - if sample.name == "claw_step04_production_ready": - assert agent["env"]["TOOLBOX_MCP_SERVER_URL"] == "${TOOLBOX_MCP_SERVER_URL:-}" - assert agent["env"]["PURVIEW_CLIENT_APP_ID"] == "${PURVIEW_CLIENT_APP_ID:-}" - - -@pytest.mark.parametrize( - ("sample", "expected"), - [ - ("azure_search_rag", ("AZURE_SEARCH_ENDPOINT", "AZURE_SEARCH_INDEX_NAME")), - ("custom_storage", ("AZURE_COSMOS_ENDPOINT", "COSMOS_DATABASE_NAME", "COSMOS_CONTAINER_NAME")), - ("foundry_memory", ("MEMORY_STORE_NAME",)), - ("foundry_toolbox_mcp_skills", ("TOOLBOX_ENDPOINT",)), - ("mcp", ("GITHUB_PAT",)), - ], -) -def test_hosted_agent_passes_sample_specific_configuration(sample: str, expected: tuple[str, ...]) -> None: - config = yaml.safe_load((HOSTED / "responses" / sample / "azure.yaml").read_text(encoding="utf-8")) - agent = next(service for service in config["services"].values() if service["host"] == "azure.ai.agent") - - for name in expected: - assert agent["env"][name] == f"${{{name}}}" - - -def test_files_sample_deploys_its_toolbox_before_the_agent() -> None: - config = yaml.safe_load((HOSTED / "responses" / "files" / "azure.yaml").read_text(encoding="utf-8")) - services = config["services"] - toolbox = services["agent-tools"] - agent = next(service for service in services.values() if service["host"] == "azure.ai.agent") - - assert toolbox["host"] == "azure.ai.toolbox" - assert {tool["type"] for tool in toolbox["tools"]} == {"web_search", "code_interpreter"} - assert "agent-tools" in agent["uses"] - assert agent["env"]["TOOLBOX_NAME"] == "agent-tools" - - -def test_toolbox_sample_wires_the_managed_toolbox_endpoint() -> None: - config = yaml.safe_load((HOSTED / "responses" / "foundry_toolbox" / "azure.yaml").read_text(encoding="utf-8")) - services = config["services"] - toolbox = services["agent-tools"] - agent = next(service for service in services.values() if service["host"] == "azure.ai.agent") - - assert toolbox["host"] == "azure.ai.toolbox" - assert {"ghmcppat", "langmcpconn", "foundrymcpconn"} <= set(toolbox["uses"]) - assert "agent-tools" in agent["uses"] - assert agent["env"]["TOOLBOX_ENDPOINT"] == "${TOOLBOX_AGENT_TOOLS_MCP_ENDPOINT}" - - -@pytest.mark.skipif(shutil.which("git") is None, reason="Git is required to evaluate azd ignore rules") -@pytest.mark.parametrize( - ("sample", "required_files"), - [ - ( - "foundry_toolbox", - ( - Path(".env.example"), - Path("toolbox.yaml"), - Path("scripts") / "list-foundry-connectors.sh", - Path("scripts") / "list-foundry-connectors.ps1", - ), - ), - ( - "foundry_toolbox_mcp_skills", - ( - Path(".env.example"), - Path("toolbox.yaml"), - Path("skills") / "support-style" / "SKILL.md", - Path("skills") / "escalation-policy" / "SKILL.md", - ), - ), - ], -) -def test_toolbox_template_includes_setup_files(tmp_path: Path, sample: str, required_files: tuple[Path, ...]) -> None: - source = HOSTED / "responses" / sample - for path in required_files: - assert (source / path).is_file() - files = (Path(".env"), *required_files) - for path in files: - target = tmp_path / path - target.parent.mkdir(parents=True, exist_ok=True) - target.touch() - (tmp_path / ".gitignore").write_text((source / ".azdignore").read_text(encoding="utf-8"), encoding="utf-8") - subprocess.run(["git", "init", "--quiet", "--template="], cwd=tmp_path, check=True, timeout=30) - result = subprocess.run( - ["git", "-c", "core.excludesfile=", "check-ignore", "--no-index", "--", *files], - cwd=tmp_path, - capture_output=True, - text=True, - check=False, - timeout=30, - ) - assert result.returncode == 0, result.stderr - assert result.stdout.splitlines() == [".env"]