Skip to content

Commit a744aa5

Browse files
Merge pull request #944 from MicrosoftDocs/main
Refresh Agent Framework PR 4818 Python docs (#936)
2 parents 349ae77 + f9f22a0 commit a744aa5

48 files changed

Lines changed: 790 additions & 901 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

agent-framework/AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ Every docs page maps to sample files in both repos:
205205
| `agents/tools/local-mcp-tools.md` | `02-agents/tools/local_mcp_tools.py` | `02-agents/tools/LocalMcpTools.cs` |
206206
| `agents/tools/tool-approval.md` | `02-agents/tools/tool_approval.py` | `02-agents/tools/ToolApproval.cs` |
207207
| `agents/middleware/*.md` | `02-agents/middleware/<matching>.py` | `02-agents/middleware/<matching>.cs` |
208+
| `agents/providers/foundry-local.md` | `02-agents/providers/foundry/foundry_local_agent.py` | N/A |
208209
| `agents/providers/*.md` | `02-agents/providers/<matching>.py` | `02-agents/providers/<matching>.cs` |
209210
| `agents/conversations/*.md` | `02-agents/conversations/<matching>.py` | `02-agents/conversations/<matching>.cs` |
210211
| `workflows/<pattern>.md` | `03-workflows/<pattern>/<matching>.py` | `03-workflows/<pattern>/<matching>.cs` |

agent-framework/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ items:
102102
href: agents/providers/openai.md
103103
- name: Microsoft Foundry
104104
href: agents/providers/microsoft-foundry.md
105+
- name: Foundry Local
106+
href: agents/providers/foundry-local.md
105107
- name: Anthropic
106108
href: agents/providers/anthropic.md
107109
- name: Ollama

agent-framework/agents/agent-pipeline.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ The `Agent` class accepts any client that implements `SupportsChatGetResponse`.
190190

191191
```python
192192
from agent_framework import Agent
193-
from agent_framework.azure import AzureOpenAIResponsesClient
193+
from agent_framework.foundry import FoundryChatClient
194194

195-
client = AzureOpenAIResponsesClient(
195+
client = FoundryChatClient(
196196
credential=credential,
197197
project_endpoint=endpoint,
198-
deployment_name=model,
198+
model=model,
199199
)
200200

201201
agent = Agent(client=client, instructions="You are helpful.")

agent-framework/agents/background-responses.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@ For non-streaming scenarios, when you initially run an agent with `background=Tr
172172
```python
173173
import asyncio
174174
from agent_framework import Agent
175-
from agent_framework.openai import OpenAIResponsesClient
175+
from agent_framework.openai import OpenAIChatClient
176176

177177
agent = Agent(
178178
name="researcher",
179179
instructions="You are a helpful research assistant.",
180-
client=OpenAIResponsesClient(model_id="o3"),
180+
client=OpenAIChatClient(model="o3"),
181181
)
182182

183183
session = agent.create_session()

agent-framework/agents/conversations/compaction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Compaction solves these problems by selectively removing, collapsing, or summari
5959

6060
Compaction applies only to agents that manage their own conversation history in memory. Agents that rely on service-managed context or conversation state do not benefit from compaction because the service already handles context management. Examples of service-managed agents include:
6161

62-
- **Foundry Agents** — context is managed server-side by the Azure AI Foundry service.
62+
- **Foundry Agents** — context is managed server-side by the Microsoft Foundry service.
6363
- **Responses API with store enabled** (the default) — conversation state is stored and managed by the OpenAI service.
6464
- **Copilot Studio agents** — conversation context is maintained by the Copilot Studio service.
6565

agent-framework/agents/index.md

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ When using Foundry, Azure OpenAI, OpenAI services, or Anthropic services, you ha
101101
| [Azure OpenAI](/azure/ai-foundry/openai/overview) <sup>1</sup> | Azure OpenAI SDK <sup>2</sup> | [Azure.AI.OpenAI](https://www.nuget.org/packages/Azure.AI.OpenAI) | https://&lt;resource&gt;.openai.azure.com/ |
102102
| [Azure OpenAI](/azure/ai-foundry/openai/overview) <sup>1</sup> | OpenAI SDK | [OpenAI](https://www.nuget.org/packages/OpenAI) | https://&lt;resource&gt;.openai.azure.com/openai/v1/ |
103103
| OpenAI | OpenAI SDK | [OpenAI](https://www.nuget.org/packages/OpenAI) | No url required |
104-
| [Azure AI Foundry Anthropic](/azure/ai-foundry/foundry-models/how-to/use-foundry-models-claude) | Anthropic Foundry SDK | [Anthropic.Foundry](https://www.nuget.org/packages/Anthropic.Foundry) | Resource name required |
104+
| [Microsoft Foundry Anthropic](/azure/ai-foundry/foundry-models/how-to/use-foundry-models-claude) | Anthropic Foundry SDK | [Anthropic.Foundry](https://www.nuget.org/packages/Anthropic.Foundry) | Resource name required |
105105
| Anthropic | Anthropic SDK | [Anthropic](https://www.nuget.org/packages/Anthropic) | No url or resource name required |
106106

107107
1. [Upgrading from Azure OpenAI to Foundry](/azure/ai-foundry/how-to/upgrade-azure-openai)
@@ -169,7 +169,7 @@ AIAgent agent = await persistentAgentsClient.CreateAIAgentAsync(
169169
name: "Joker");
170170
```
171171

172-
### Using the Azure AI Foundry Anthropic SDK
172+
### Using the Foundry Anthropic SDK
173173

174174
The resource is the subdomain name / first name coming before '.services.ai.azure.com' in the endpoint Uri.
175175

@@ -217,29 +217,37 @@ To create one of these agents, simply construct an `Agent` using the chat client
217217
```python
218218
import os
219219
from agent_framework import Agent
220-
from agent_framework.azure import AzureOpenAIResponsesClient
220+
from agent_framework.foundry import FoundryChatClient
221221
from azure.identity.aio import DefaultAzureCredential
222222

223-
Agent(
224-
client=AzureOpenAIResponsesClient(credential=DefaultAzureCredential(), project_endpoint=os.getenv("AZURE_AI_PROJECT_ENDPOINT"), deployment_name=os.getenv("AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME")),
225-
instructions="You are a helpful assistant"
226-
) as agent
223+
agent = Agent(
224+
client=FoundryChatClient(
225+
credential=DefaultAzureCredential(),
226+
project_endpoint=os.getenv("AZURE_AI_PROJECT_ENDPOINT"),
227+
model=os.getenv("AZURE_AI_MODEL_DEPLOYMENT_NAME"),
228+
),
229+
instructions="You are a helpful assistant",
230+
)
227231
response = await agent.run("Hello!")
228232
```
229233

230234
Alternatively, you can use the convenience method on the chat client:
231235

232236
```python
233-
from agent_framework.azure import AzureOpenAIResponsesClient
237+
from agent_framework.foundry import FoundryChatClient
234238
from azure.identity.aio import DefaultAzureCredential
235239

236-
agent = AzureOpenAIResponsesClient(credential=DefaultAzureCredential(), project_endpoint=os.getenv("AZURE_AI_PROJECT_ENDPOINT"), deployment_name=os.getenv("AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME")).as_agent(
240+
agent = FoundryChatClient(
241+
credential=DefaultAzureCredential(),
242+
project_endpoint=os.getenv("AZURE_AI_PROJECT_ENDPOINT"),
243+
model=os.getenv("AZURE_AI_MODEL_DEPLOYMENT_NAME"),
244+
).as_agent(
237245
instructions="You are a helpful assistant"
238246
)
239247
```
240248

241249
> [!NOTE]
242-
> This example shows using the AzureOpenAIResponsesClient, but the same pattern applies to any chat client that implements `SupportsChatGetResponse`, see [providers overview](./providers/index.md) for more details on other clients.
250+
> This example shows using the FoundryChatClient, but the same pattern applies to any chat client that implements `SupportsChatGetResponse`, see [providers overview](./providers/index.md) for more details on other clients.
243251
244252
For detailed examples, see the agent-specific documentation sections below.
245253

@@ -293,17 +301,17 @@ You can provide function tools to agents for enhanced capabilities:
293301
import os
294302
from typing import Annotated
295303
from azure.identity.aio import DefaultAzureCredential
296-
from agent_framework.azure import AzureOpenAIResponsesClient
304+
from agent_framework.foundry import FoundryChatClient
297305

298306
def get_weather(location: Annotated[str, "The location to get the weather for."]) -> str:
299307
"""Get the weather for a given location."""
300308
return f"The weather in {location} is sunny with a high of 25°C."
301309

302310
async with DefaultAzureCredential() as credential:
303-
agent = AzureOpenAIResponsesClient(
311+
agent = FoundryChatClient(
304312
credential=credential,
305313
project_endpoint=os.getenv("AZURE_AI_PROJECT_ENDPOINT"),
306-
deployment_name=os.getenv("AZURE_OPENAI_RESPONSES_DEPLOYMENT_NAME"),
314+
model=os.getenv("AZURE_AI_MODEL_DEPLOYMENT_NAME"),
307315
).as_agent(
308316
instructions="You are a helpful weather assistant.",
309317
tools=get_weather,

agent-framework/agents/middleware/result-overrides.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ from agent_framework import (
9494
ResponseStream,
9595
tool,
9696
)
97-
from agent_framework.openai import OpenAIResponsesClient
97+
from agent_framework.openai import OpenAIChatClient
9898
from pydantic import Field
9999

100100
"""
@@ -260,7 +260,7 @@ async def main() -> None:
260260

261261
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
262262
# authentication option.
263-
agent = OpenAIResponsesClient(
263+
agent = OpenAIChatClient(
264264
middleware=[validate_weather_middleware, weather_override_middleware],
265265
).as_agent(
266266
name="WeatherAgent",
@@ -316,7 +316,7 @@ from agent_framework import (
316316
ResponseStream,
317317
tool,
318318
)
319-
from agent_framework.openai import OpenAIResponsesClient
319+
from agent_framework.openai import OpenAIChatClient
320320
from pydantic import Field
321321

322322
"""
@@ -482,7 +482,7 @@ async def main() -> None:
482482

483483
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
484484
# authentication option.
485-
agent = OpenAIResponsesClient(
485+
agent = OpenAIChatClient(
486486
middleware=[validate_weather_middleware, weather_override_middleware],
487487
).as_agent(
488488
name="WeatherAgent",

agent-framework/agents/middleware/runtime-context.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Use the smallest surface that fits the data. This keeps tool inputs explicit and
4949
from typing import Annotated
5050

5151
from agent_framework import FunctionInvocationContext, tool
52-
from agent_framework.openai import OpenAIResponsesClient
52+
from agent_framework.openai import OpenAIChatClient
5353

5454

5555
@tool(approval_mode="never_require")
@@ -62,7 +62,7 @@ def send_email(
6262
return f"Queued email for {address} from {user_id} ({tenant})"
6363

6464

65-
agent = OpenAIResponsesClient().as_agent(
65+
agent = OpenAIChatClient().as_agent(
6666
name="Notifier",
6767
instructions="Send email updates.",
6868
tools=[send_email],
@@ -93,7 +93,7 @@ Function middleware uses the same `FunctionInvocationContext` object that tools
9393
from collections.abc import Awaitable, Callable
9494

9595
from agent_framework import FunctionInvocationContext
96-
from agent_framework.openai import OpenAIResponsesClient
96+
from agent_framework.openai import OpenAIChatClient
9797

9898

9999
async def enrich_tool_runtime_context(
@@ -105,7 +105,7 @@ async def enrich_tool_runtime_context(
105105
await call_next()
106106

107107

108-
agent = OpenAIResponsesClient().as_agent(
108+
agent = OpenAIChatClient().as_agent(
109109
name="Notifier",
110110
instructions="Send email updates.",
111111
tools=[send_email],
@@ -121,7 +121,7 @@ The middleware contract uses `call_next()` with no arguments. Mutate `context.kw
121121
from typing import Annotated
122122

123123
from agent_framework import FunctionInvocationContext, tool
124-
from agent_framework.openai import OpenAIResponsesClient
124+
from agent_framework.openai import OpenAIChatClient
125125

126126

127127
@tool(approval_mode="never_require")
@@ -136,7 +136,7 @@ def remember_topic(
136136
return f"Stored {topic!r} in session state."
137137

138138

139-
agent = OpenAIResponsesClient().as_agent(
139+
agent = OpenAIChatClient().as_agent(
140140
name="MemoryAgent",
141141
instructions="Remember important topics.",
142142
tools=[remember_topic],
@@ -155,7 +155,7 @@ When an agent is exposed as a tool via `as_tool()`, runtime function kwargs alre
155155

156156
```python
157157
from agent_framework import FunctionInvocationContext, tool
158-
from agent_framework.openai import OpenAIResponsesClient
158+
from agent_framework.openai import OpenAIChatClient
159159

160160

161161
@tool(description="Store findings for later steps.")
@@ -164,7 +164,7 @@ def store_findings(findings: str, ctx: FunctionInvocationContext) -> None:
164164
ctx.session.state["findings"] = findings
165165

166166

167-
client = OpenAIResponsesClient()
167+
client = OpenAIChatClient()
168168

169169
research_agent = client.as_agent(
170170
name="ResearchAgent",

agent-framework/agents/multimodal.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,16 @@ First, create an agent that is able to analyze images.
6262

6363
```python
6464
import asyncio
65-
from agent_framework.azure import AzureOpenAIChatClient
65+
import os
66+
from agent_framework.openai import OpenAIChatCompletionClient
6667
from azure.identity import AzureCliCredential
6768

68-
agent = AzureOpenAIChatClient(credential=AzureCliCredential()).as_agent(
69+
agent = OpenAIChatCompletionClient(
70+
model=os.environ["AZURE_OPENAI_DEPLOYMENT_NAME"],
71+
azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
72+
api_version=os.getenv("AZURE_OPENAI_API_VERSION"),
73+
credential=AzureCliCredential(),
74+
).as_agent(
6975
name="VisionAgent",
7076
instructions="You are a helpful agent that can analyze images"
7177
)

0 commit comments

Comments
 (0)