Skip to content

Commit 7b460a7

Browse files
westey-mLearn Build Service GitHub ApplokitothrogerbarretoCopilot
authored
Merge latest changes to live (#956)
* docs: remove comma splice in tool-approval.md * docs: Remove duplicate codeblock in tool-approval.md * docs: Remove duplicate code block * fix header language * docs: Link to topic-specific .NET sample project * docs: move full sample link to tip * Add fixes for overview page (#949) * Add fixes for overview page * Add missing import statements for python sample code * Add C# runtime-context samples and migrate middleware docs to AIProjectClient - Add full C# zone pivot to runtime-context.md with 4 code samples covering AgentRunOptions.AdditionalProperties, FunctionInvocationContext, AgentSession.StateBag, and cross-middleware state sharing - Migrate all 9 middleware docs from Azure.AI.OpenAI (AzureOpenAIClient) to Azure.AI.Projects (AIProjectClient) with DefaultAzureCredential - Use .GetResponsesClient().AsIChatClient() for standalone IChatClient examples - Add DefaultAzureCredential production warning to all middleware docs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: correct critical provider documentation issues - copilot-studio.md: Replace non-existent CopilotStudioChatClient with CopilotStudioAgent, rewrite C# sample, add Python section - index.md: Fix comparison table (OpenAI/Anthropic/GitHub Copilot MCP, Anthropic Code Interpreter), add Foundry Local row, add Copilot Studio to Python list, note both AIAgent/.NET and BaseAgent/Python base classes - github-copilot.md: Fix PermissionRequest import path, rename thread variable to session for consistency - foundry-local.md: Fix next step link to point forward to Anthropic - microsoft-foundry.md: Fix next step link to point to Foundry Local Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: replace geopolitical term in copilot-studio example Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix doc inaccuracies in various places (#954) * Fixes for RAG docs (#952) * Adds sample documentation for two separate Neo4j context providers fo… (#361) * Python: Adds sample documentation for two separate Neo4j context providers for retrieval and memory * adding pypi links * Move Neo4j integration docs from inline sections to dedicated integration pages * Add GraphRAG section and address PR review comments Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fixing dotnet docs * fixing dotnet docs --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> * Fix for csharp declarative agent docs (#955) --------- Co-authored-by: Learn Build Service GitHub App <Learn Build Service LearnBuild@microsoft.com> Co-authored-by: Jacob Alber <jaalber@microsoft.com> Co-authored-by: Jacob Alber <jacob.alber@microsoft.com> Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Giles Odigwe <gilesodigwe@microsoft.com> Co-authored-by: Tao Chen <taochen@microsoft.com> Co-authored-by: Giles Odigwe <79032838+giles17@users.noreply.github.com> Co-authored-by: Ryan Knight <ryan@grandcloud.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com> Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com> Co-authored-by: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com> Co-authored-by: Ben Thomas <ben.thomas@microsoft.com> Co-authored-by: Chris <66376200+crickman@users.noreply.github.com> Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com> Co-authored-by: Peter Ibekwe <109177538+peibekwe@users.noreply.github.com>
2 parents a744aa5 + ac568d7 commit 7b460a7

29 files changed

Lines changed: 894 additions & 655 deletions

agent-framework/TOC.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ items:
178178
href: integrations/purview.md
179179
- name: M365
180180
href: integrations/m365.md
181+
- name: Neo4j GraphRAG Provider
182+
href: integrations/neo4j-graphrag.md
183+
- name: Neo4j Memory Provider
184+
href: integrations/neo4j-memory.md
181185
- name: A2A Protocol
182186
href: integrations/a2a.md
183187
- name: AG-UI Protocol

agent-framework/agents/declarative.md

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,53 @@ Declarative agents allow you to define agent configuration using YAML or JSON fi
1818
The following example shows how to create a declarative agent from a YAML configuration:
1919

2020
```csharp
21-
using System;
22-
using System.IO;
2321
using Azure.AI.OpenAI;
2422
using Azure.Identity;
2523
using Microsoft.Agents.AI;
2624
using Microsoft.Extensions.AI;
2725

28-
// Load agent configuration from a YAML file
29-
var yamlContent = File.ReadAllText("agent-config.yaml");
30-
31-
// Create the agent from the YAML definition
32-
AIAgent agent = AgentFactory.CreateFromYaml(
33-
yamlContent,
34-
new AzureOpenAIClient(
35-
new Uri("https://<myresource>.openai.azure.com"),
36-
new AzureCliCredential()));
37-
38-
// Run the declarative agent
39-
Console.WriteLine(await agent.RunAsync("Why is the sky blue?"));
26+
// Create the chat client
27+
IChatClient chatClient = new AzureOpenAIClient(
28+
new Uri("https://<myresource>.openai.azure.com"),
29+
new DefaultAzureCredential())
30+
.GetChatClient("gpt-4o-mini")
31+
.AsIChatClient();
32+
33+
// Define the agent using a YAML definition.
34+
var yamlDefinition =
35+
"""
36+
kind: Prompt
37+
name: Assistant
38+
description: Helpful assistant
39+
instructions: You are a helpful assistant. You answer questions in the language specified by the user. You return your answers in a JSON format.
40+
model:
41+
options:
42+
temperature: 0.9
43+
topP: 0.95
44+
outputSchema:
45+
properties:
46+
language:
47+
type: string
48+
required: true
49+
description: The language of the answer.
50+
answer:
51+
type: string
52+
required: true
53+
description: The answer text.
54+
""";
55+
56+
// Create the agent from the YAML definition.
57+
var agentFactory = new ChatClientPromptAgentFactory(chatClient);
58+
var agent = await agentFactory.CreateFromYamlAsync(yamlDefinition);
59+
60+
// Invoke the agent and output the text result.
61+
Console.WriteLine(await agent!.RunAsync("Tell me a joke about a pirate in English."));
62+
63+
// Invoke the agent with streaming support.
64+
await foreach (var update in agent!.RunStreamingAsync("Tell me a joke about a pirate in French."))
65+
{
66+
Console.WriteLine(update);
67+
}
4068
```
4169

4270
:::zone-end

agent-framework/agents/index.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The Microsoft Agent Framework provides support for several types of agents to ac
1818
::: zone pivot="programming-language-csharp"
1919
All agents are derived from a common base class, `AIAgent`, which provides a consistent interface for all agent types. This allows for building common, agent agnostic, higher level functionality such as multi-agent orchestrations.
2020
::: zone-end
21+
2122
::: zone pivot="programming-language-python"
2223
All agents are derived from a common base class, `Agent`, which provides a consistent interface for all agent types. This allows for building common, agent agnostic, higher level functionality such as multi-agent orchestrations.
2324
::: zone-end
@@ -28,7 +29,7 @@ All agents in the Microsoft Agent Framework execute using a structured runtime m
2829

2930
![AI Agent Diagram](../media/agent.svg)
3031

31-
> [!IMPORTANT]
32+
> [!WARNING]
3233
> If you use Microsoft Agent Framework to build applications that operate with third-party servers or agents, you do so at your own risk. We recommend reviewing all data being shared with third-party servers or agents and being cognizant of third-party practices for retention and location of data. It is your responsibility to manage whether your data will flow outside of your organization's Azure compliance and geographic boundaries and any related implications.
3334
3435
::: zone pivot="programming-language-csharp"
@@ -66,7 +67,6 @@ To make creating these agents even easier, Agent Framework provides helpers for
6667
|[Anthropic](./providers/anthropic.md)|An agent that uses a Claude model via the Anthropic Service as its backend.|No|Yes|
6768
|[OpenAI ChatCompletion](./providers/openai.md)|An agent that uses the OpenAI ChatCompletion service.|No|Yes|
6869
|[OpenAI Responses](./providers/openai.md)|An agent that uses the OpenAI Responses service.|Yes|Yes|
69-
|[OpenAI Assistants](./providers/openai.md)|An agent that uses the OpenAI Assistants service.|Yes|No|
7070
|[Any other `IChatClient`](./providers/custom.md)|You can also use any other [`Microsoft.Extensions.AI.IChatClient`](/dotnet/ai/microsoft-extensions-ai#the-ichatclient-interface) implementation to create an agent.|Varies|Varies|
7171

7272
## Complex custom agents
@@ -261,7 +261,6 @@ For detailed examples, see the agent-specific documentation sections below.
261261
|[Azure OpenAI Assistants](./providers/azure-openai.md)|An agent that uses the Azure OpenAI Assistants service.|Yes|
262262
|[OpenAI Chat Completion](./providers/openai.md)|An agent that uses the OpenAI Chat Completion service.|No|
263263
|[OpenAI Responses](./providers/openai.md)|An agent that uses the OpenAI Responses service.|Yes|
264-
|[OpenAI Assistants](./providers/openai.md)|An agent that uses the OpenAI Assistants service.|Yes|
265264
|[Anthropic Claude](./providers/anthropic.md)|An agent that uses Anthropic Claude models.|No|
266265
|[Amazon Bedrock](https://github.com/microsoft/agent-framework/tree/main/python/packages/bedrock)|An agent that uses Amazon Bedrock models through the Agent Framework Bedrock chat client.|No|
267266
|[GitHub Copilot](./providers/github-copilot.md)|An agent that uses the GitHub Copilot SDK backend.|No|

agent-framework/agents/middleware/agent-vs-run-scope.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ using System.Linq;
3333
using System.Runtime.CompilerServices;
3434
using System.Threading;
3535
using System.Threading.Tasks;
36-
using Azure.AI.OpenAI;
36+
using Azure.AI.Projects;
3737
using Azure.Identity;
3838
using Microsoft.Agents.AI;
3939
using Microsoft.Extensions.AI;
@@ -65,11 +65,12 @@ async IAsyncEnumerable<AgentResponseUpdate> SecurityStreamingMiddleware(
6565
}
6666
}
6767

68-
AIAgent baseAgent = new AzureOpenAIClient(
69-
new Uri("https://<myresource>.openai.azure.com"),
70-
new AzureCliCredential())
71-
.GetChatClient("gpt-4o-mini")
72-
.AsAIAgent(instructions: "You are a helpful assistant.");
68+
AIAgent baseAgent = new AIProjectClient(
69+
new Uri("<your-foundry-project-endpoint>"),
70+
new DefaultAzureCredential())
71+
.AsAIAgent(
72+
model: "gpt-4o-mini",
73+
instructions: "You are a helpful assistant.");
7374

7475
// Register middleware at the agent level
7576
var agentWithMiddleware = baseAgent
@@ -80,6 +81,9 @@ var agentWithMiddleware = baseAgent
8081
Console.WriteLine(await agentWithMiddleware.RunAsync("What's the weather in Paris?"));
8182
```
8283

84+
> [!WARNING]
85+
> `DefaultAzureCredential` is convenient for development but requires careful consideration in production. In production, consider using a specific credential (e.g., `ManagedIdentityCredential`) to avoid latency issues, unintended credential probing, and potential security risks from fallback mechanisms.
86+
8387
### Run-level middleware
8488

8589
Run-level middleware uses the same builder pattern, applied inline for a specific invocation:

agent-framework/agents/middleware/chat-middleware.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ using System.Collections.Generic;
2323
using System.Linq;
2424
using System.Threading;
2525
using System.Threading.Tasks;
26-
using Azure.AI.OpenAI;
26+
using Azure.AI.Projects;
2727
using Azure.Identity;
2828
using Microsoft.Agents.AI;
2929
using Microsoft.Extensions.AI;
@@ -48,18 +48,23 @@ async Task<ChatResponse> LoggingChatMiddleware(
4848
}
4949

5050
// Register IChatClient middleware using the client factory
51-
var agent = new AzureOpenAIClient(
52-
new Uri("https://<myresource>.openai.azure.com"),
53-
new AzureCliCredential())
54-
.GetChatClient("gpt-4o-mini")
55-
.AsAIAgent("You are a helpful assistant.", clientFactory: (chatClient) => chatClient
56-
.AsBuilder()
57-
.Use(getResponseFunc: LoggingChatMiddleware, getStreamingResponseFunc: null)
58-
.Build());
51+
var agent = new AIProjectClient(
52+
new Uri("<your-foundry-project-endpoint>"),
53+
new DefaultAzureCredential())
54+
.AsAIAgent(
55+
model: "gpt-4o-mini",
56+
instructions: "You are a helpful assistant.",
57+
clientFactory: (chatClient) => chatClient
58+
.AsBuilder()
59+
.Use(getResponseFunc: LoggingChatMiddleware, getStreamingResponseFunc: null)
60+
.Build());
5961

6062
Console.WriteLine(await agent.RunAsync("Hello, how are you?"));
6163
```
6264

65+
> [!WARNING]
66+
> `DefaultAzureCredential` is convenient for development but requires careful consideration in production. In production, consider using a specific credential (e.g., `ManagedIdentityCredential`) to avoid latency issues, unintended credential probing, and potential security risks from fallback mechanisms.
67+
6368
> [!NOTE]
6469
> For more information about `IChatClient` middleware, see [Custom IChatClient middleware](/dotnet/ai/microsoft-extensions-ai#custom-ichatclient-middleware).
6570

agent-framework/agents/middleware/defining-middleware.md

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,27 @@ First, create a basic agent with a function tool.
2626
```csharp
2727
using System;
2828
using System.ComponentModel;
29-
using Azure.AI.OpenAI;
29+
using Azure.AI.Projects;
3030
using Azure.Identity;
3131
using Microsoft.Agents.AI;
3232
using Microsoft.Extensions.AI;
33-
using OpenAI;
3433

3534
[Description("The current datetime offset.")]
3635
static string GetDateTime()
3736
=> DateTimeOffset.Now.ToString();
3837

39-
AIAgent baseAgent = new AzureOpenAIClient(
40-
new Uri("https://<myresource>.openai.azure.com"),
41-
new AzureCliCredential())
42-
.GetChatClient("gpt-4o-mini")
38+
AIAgent baseAgent = new AIProjectClient(
39+
new Uri("<your-foundry-project-endpoint>"),
40+
new DefaultAzureCredential())
4341
.AsAIAgent(
42+
model: "gpt-4o-mini",
4443
instructions: "You are an AI assistant that helps people find information.",
4544
tools: [AIFunctionFactory.Create(GetDateTime, name: nameof(GetDateTime))]);
4645
```
4746

47+
> [!WARNING]
48+
> `DefaultAzureCredential` is convenient for development but requires careful consideration in production. In production, consider using a specific credential (e.g., `ManagedIdentityCredential`) to avoid latency issues, unintended credential probing, and potential security risks from fallback mechanisms.
49+
4850
## Step 2: Create Your Agent Run Middleware
4951

5052
Next, create a function that will get invoked for each agent run.
@@ -178,9 +180,12 @@ To add middleware to your <xref:Microsoft.Extensions.AI.IChatClient>, you can us
178180
After adding the middleware, you can use the `IChatClient` with your agent as usual.
179181

180182
```csharp
181-
var chatClient = new AzureOpenAIClient(new Uri("https://<myresource>.openai.azure.com"), new AzureCliCredential())
182-
.GetChatClient("gpt-4o-mini")
183-
.AsIChatClient();
183+
var chatClient = new AIProjectClient(
184+
new Uri("<your-foundry-project-endpoint>"),
185+
new DefaultAzureCredential())
186+
.GetProjectOpenAIClient()
187+
.GetResponsesClient()
188+
.AsIChatClient("gpt-4o-mini");
184189

185190
var middlewareEnabledChatClient = chatClient
186191
.AsBuilder()
@@ -194,12 +199,16 @@ var agent = new ChatClientAgent(middlewareEnabledChatClient, instructions: "You
194199
an agent via one of the helper methods on SDK clients.
195200

196201
```csharp
197-
var agent = new AzureOpenAIClient(new Uri("https://<myresource>.openai.azure.com"), new AzureCliCredential())
198-
.GetChatClient("gpt-4o-mini")
199-
.AsAIAgent("You are a helpful assistant.", clientFactory: (chatClient) => chatClient
200-
.AsBuilder()
201-
.Use(getResponseFunc: CustomChatClientMiddleware, getStreamingResponseFunc: null)
202-
.Build());
202+
var agent = new AIProjectClient(
203+
new Uri("<your-foundry-project-endpoint>"),
204+
new DefaultAzureCredential())
205+
.AsAIAgent(
206+
model: "gpt-4o-mini",
207+
instructions: "You are a helpful assistant.",
208+
clientFactory: (chatClient) => chatClient
209+
.AsBuilder()
210+
.Use(getResponseFunc: CustomChatClientMiddleware, getStreamingResponseFunc: null)
211+
.Build());
203212
```
204213

205214
::: zone-end

agent-framework/agents/middleware/exception-handling.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ using System;
2222
using System.Collections.Generic;
2323
using System.Threading;
2424
using System.Threading.Tasks;
25-
using Azure.AI.OpenAI;
25+
using Azure.AI.Projects;
2626
using Azure.Identity;
2727
using Microsoft.Agents.AI;
2828
using Microsoft.Extensions.AI;
@@ -54,11 +54,12 @@ async Task<AgentResponse> ExceptionHandlingMiddleware(
5454
}
5555
}
5656

57-
AIAgent agent = new AzureOpenAIClient(
58-
new Uri("https://<myresource>.openai.azure.com"),
59-
new AzureCliCredential())
60-
.GetChatClient("gpt-4o-mini")
61-
.AsAIAgent(instructions: "You are a helpful assistant.");
57+
AIAgent agent = new AIProjectClient(
58+
new Uri("<your-foundry-project-endpoint>"),
59+
new DefaultAzureCredential())
60+
.AsAIAgent(
61+
model: "gpt-4o-mini",
62+
instructions: "You are a helpful assistant.");
6263

6364
var safeAgent = agent
6465
.AsBuilder()
@@ -68,6 +69,9 @@ var safeAgent = agent
6869
Console.WriteLine(await safeAgent.RunAsync("Get user statistics"));
6970
```
7071

72+
> [!WARNING]
73+
> `DefaultAzureCredential` is convenient for development but requires careful consideration in production. In production, consider using a specific credential (e.g., `ManagedIdentityCredential`) to avoid latency issues, unintended credential probing, and potential security risks from fallback mechanisms.
74+
7175
:::zone-end
7276

7377
:::zone pivot="programming-language-python"

agent-framework/agents/middleware/index.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ var middlewareEnabledAgent = originalAgent
4343
`IChatClient` middleware can be registered on an `IChatClient` before it is used with a `ChatClientAgent`, by using the chat client builder pattern.
4444

4545
```csharp
46-
var chatClient = new AzureOpenAIClient(new Uri("https://<myresource>.openai.azure.com"), new DefaultAzureCredential())
47-
.GetChatClient(deploymentName)
48-
.AsIChatClient();
46+
var chatClient = new AIProjectClient(
47+
new Uri("<your-foundry-project-endpoint>"),
48+
new DefaultAzureCredential())
49+
.GetProjectOpenAIClient()
50+
.GetResponsesClient()
51+
.AsIChatClient(deploymentName);
4952

5053
var middlewareEnabledChatClient = chatClient
5154
.AsBuilder()
@@ -62,12 +65,16 @@ var agent = new ChatClientAgent(middlewareEnabledChatClient, instructions: "You
6265
an agent via one of the helper methods on SDK clients.
6366

6467
```csharp
65-
var agent = new AzureOpenAIClient(new Uri(endpoint), new DefaultAzureCredential())
66-
.GetChatClient(deploymentName)
67-
.AsAIAgent("You are a helpful assistant.", clientFactory: (chatClient) => chatClient
68-
.AsBuilder()
69-
.Use(getResponseFunc: CustomChatClientMiddleware, getStreamingResponseFunc: null)
70-
.Build());
68+
var agent = new AIProjectClient(
69+
new Uri("<your-foundry-project-endpoint>"),
70+
new DefaultAzureCredential())
71+
.AsAIAgent(
72+
model: deploymentName,
73+
instructions: "You are a helpful assistant.",
74+
clientFactory: (chatClient) => chatClient
75+
.AsBuilder()
76+
.Use(getResponseFunc: CustomChatClientMiddleware, getStreamingResponseFunc: null)
77+
.Build());
7178
```
7279

7380
## Agent Run Middleware

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ using System.Collections.Generic;
2323
using System.Linq;
2424
using System.Threading;
2525
using System.Threading.Tasks;
26-
using Azure.AI.OpenAI;
26+
using Azure.AI.Projects;
2727
using Azure.Identity;
2828
using Microsoft.Agents.AI;
2929
using Microsoft.Extensions.AI;
@@ -52,11 +52,12 @@ async Task<AgentResponse> ResultOverrideMiddleware(
5252
return new AgentResponse(modifiedMessages);
5353
}
5454

55-
AIAgent agent = new AzureOpenAIClient(
56-
new Uri("https://<myresource>.openai.azure.com"),
57-
new AzureCliCredential())
58-
.GetChatClient("gpt-4o-mini")
59-
.AsAIAgent(instructions: "You are a helpful weather assistant.");
55+
AIAgent agent = new AIProjectClient(
56+
new Uri("<your-foundry-project-endpoint>"),
57+
new DefaultAzureCredential())
58+
.AsAIAgent(
59+
model: "gpt-4o-mini",
60+
instructions: "You are a helpful weather assistant.");
6061

6162
var agentWithOverride = agent
6263
.AsBuilder()
@@ -66,6 +67,9 @@ var agentWithOverride = agent
6667
Console.WriteLine(await agentWithOverride.RunAsync("What's the weather in Seattle?"));
6768
```
6869

70+
> [!WARNING]
71+
> `DefaultAzureCredential` is convenient for development but requires careful consideration in production. In production, consider using a specific credential (e.g., `ManagedIdentityCredential`) to avoid latency issues, unintended credential probing, and potential security risks from fallback mechanisms.
72+
6973
:::zone-end
7074

7175
:::zone pivot="programming-language-python"

0 commit comments

Comments
 (0)