Skip to content

Commit 580a0c4

Browse files
authored
Python: Update hosted agent samples with agent manifests (#2240)
* Add agent manifests * Correct agent manifest * Correct agent manifest 2 * use resource substitution * address comments
1 parent c7e7020 commit 580a0c4

File tree

12 files changed

+105
-168
lines changed

12 files changed

+105
-168
lines changed

python/samples/demos/hosted_agents/agent_with_hosted_mcp/.env.example

Lines changed: 0 additions & 2 deletions
This file was deleted.

python/samples/demos/hosted_agents/agent_with_hosted_mcp/README.md

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Unique identifier/name for this agent
2+
name: agent-with-hosted-mcp
3+
# Brief description of what this agent does
4+
description: >
5+
An AI agent that uses Azure OpenAI with a Hosted Model Context Protocol (MCP) server.
6+
The agent answers questions by searching Microsoft Learn documentation using MCP tools.
7+
metadata:
8+
# Categorization tags for organizing and discovering agents
9+
authors:
10+
- Microsoft Agent Framework Team
11+
tags:
12+
- Azure AI AgentServer
13+
- Microsoft Agent Framework
14+
- Model Context Protocol
15+
- MCP
16+
template:
17+
name: agent-with-hosted-mcp
18+
# The type of agent - "hosted" for HOBO, "container" for COBO
19+
kind: hosted
20+
protocols:
21+
- protocol: responses
22+
environment_variables:
23+
- name: AZURE_OPENAI_ENDPOINT
24+
value: ${AZURE_OPENAI_ENDPOINT}
25+
- name: AZURE_OPENAI_CHAT_DEPLOYMENT_NAME
26+
value: "{{chat}}"
27+
resources:
28+
- kind: model
29+
id: gpt-4o-mini
30+
name: chat

python/samples/demos/hosted_agents/agent_with_hosted_mcp/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Copyright (c) Microsoft. All rights reserved.
22

3-
43
from agent_framework import HostedMCPTool
5-
from agent_framework.openai import OpenAIChatClient
4+
from agent_framework.azure import AzureOpenAIChatClient
65
from azure.ai.agentserver.agentframework import from_agent_framework # pyright: ignore[reportUnknownVariableType]
6+
from azure.identity import DefaultAzureCredential
77

88

99
def main():
10-
# Create an Agent using the OpenAI Chat Client with a MCP Tool that connects to Microsoft Learn MCP
11-
agent = OpenAIChatClient().create_agent(
10+
# Create an Agent using the Azure OpenAI Chat Client with a MCP Tool that connects to Microsoft Learn MCP
11+
agent = AzureOpenAIChatClient(credential=DefaultAzureCredential()).create_agent(
1212
name="DocsAgent",
1313
instructions="You are a helpful assistant that can help with microsoft documentation questions.",
1414
tools=HostedMCPTool(

python/samples/demos/hosted_agents/agent_with_text_search_rag/.env.example

Lines changed: 0 additions & 2 deletions
This file was deleted.

python/samples/demos/hosted_agents/agent_with_text_search_rag/README.md

Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Unique identifier/name for this agent
2+
name: agent-with-text-search-rag
3+
# Brief description of what this agent does
4+
description: >
5+
An AI agent that uses a ContextProvider for retrieval augmented generation (RAG) capabilities.
6+
The agent runs searches against an external knowledge base before each model invocation and
7+
injects the results into the model context. It can answer questions about Contoso Outdoors
8+
policies and products, including return policies, refunds, shipping options, and product care
9+
instructions such as tent maintenance.
10+
metadata:
11+
# Categorization tags for organizing and discovering agents
12+
authors:
13+
- Microsoft Agent Framework Team
14+
tags:
15+
- Azure AI AgentServer
16+
- Microsoft Agent Framework
17+
- Retrieval-Augmented Generation
18+
- RAG
19+
template:
20+
name: agent-with-text-search-rag
21+
# The type of agent - "hosted" for HOBO, "container" for COBO
22+
kind: hosted
23+
protocols:
24+
- protocol: responses
25+
environment_variables:
26+
- name: AZURE_OPENAI_ENDPOINT
27+
value: ${AZURE_OPENAI_ENDPOINT}
28+
- name: AZURE_OPENAI_CHAT_DEPLOYMENT_NAME
29+
value: "{{chat}}"
30+
resources:
31+
- kind: model
32+
id: gpt-4o-mini
33+
name: chat

python/samples/demos/hosted_agents/agent_with_text_search_rag/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
from typing import Any
88

99
from agent_framework import ChatMessage, Context, ContextProvider, Role
10-
from agent_framework.openai import OpenAIChatClient
10+
from agent_framework.azure import AzureOpenAIChatClient
1111
from azure.ai.agentserver.agentframework import from_agent_framework # pyright: ignore[reportUnknownVariableType]
12+
from azure.identity import DefaultAzureCredential
1213

1314
if sys.version_info >= (3, 12):
1415
from typing import override
@@ -91,8 +92,8 @@ async def invoking(self, messages: ChatMessage | MutableSequence[ChatMessage], *
9192

9293

9394
def main():
94-
# Create an Agent using the OpenAI Chat Client
95-
agent = OpenAIChatClient().create_agent(
95+
# Create an Agent using the Azure OpenAI Chat Client
96+
agent = AzureOpenAIChatClient(credential=DefaultAzureCredential()).create_agent(
9697
name="SupportSpecialist",
9798
instructions=(
9899
"You are a helpful support specialist for Contoso Outdoors. "

python/samples/demos/hosted_agents/agents_in_workflow/.env.example

Lines changed: 0 additions & 2 deletions
This file was deleted.

python/samples/demos/hosted_agents/agents_in_workflow/README.md

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)