You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tools/Azure.Mcp.Tools.AzureAIBestPractices/src/Resources/ai-background-knowledge.txt
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,8 @@ Use this hierarchy to analyze and select AI models
18
18
- **Multi-LLM Support**: Works with OpenAI, Azure OpenAI, Azure AI Foundry, and other providers
19
19
20
20
**Agent Types:**
21
-
- **[RECOMMENDED] Azure AI Foundry Agent (`PersistentAgentsClient`)**: Service-managed persistent agents with conversation threads - best for production applications requiring conversation continuity
21
+
- **[RECOMMENDED] Azure AI Foundry Agent (`AIProjectClient`)**: Latest unified client for Azure AI Foundry agents with conversation threads - best for production applications requiring conversation continuity and modern agent features
22
+
- **[LEGACY] Azure AI Foundry Agent (`PersistentAgentsClient`)**: Older client for service-managed persistent agents - superseded by `AIProjectClient`
22
23
- **OpenAI ChatCompletion / Responses / Assistants Agent (`OpenAIClient`)**: Stateless or service-managed agents using OpenAI service
23
24
- **Azure AI Foundry Models ChatCompletion / Responses Agent (`OpenAIClient` / `AzureOpenAIClient`)**: For testing Foundry-deployed models (stateless)
24
25
- **Azure OpenAI ChatCompletion / Responses (`AzureOpenAIClient`)**: Stateless agents using Azure OpenAI ChatCompletion / Responses service
After completing the required model selection process above, gather SDK and implementation information.
67
67
#### Step 1: Fetch common quickstart pages
68
-
Use the Microsoft Document **fetch** operation to retrieve these pages directly for complete, unabridged content. These are the most commonly needed references and should be fetched for EVERY implementation:
69
-
- [Default] Azure AI Foundry Quickstart: `https://learn.microsoft.com/agent-framework/user-guide/agents/agent-types/azure-ai-foundry-agent`
70
-
71
-
#### Step 2 (Optional): Search for specific agent type documentation
72
-
**ONLY if user explicitly requests a NON-Azure AI Foundry service provider:**
73
-
- **Default for Azure AI Foundry**: ALWAYS use Azure AI Foundry Agent (`PersistentAgentsClient`) - skip this step
74
-
- **DO NOT use this step for demos, prototypes, or "local testing"** - still use `PersistentAgentsClient`
75
-
- **ONLY search other agent types if user explicitly says**: "use OpenAI service", "use Azure OpenAI service", etc.
Use the **fetch** operation to retrieve GitHub pages directly for complete, unabridged content. These are the most commonly needed references and should be fetched for EVERY implementation:
69
+
- [Default] Microsoft Agent Framework Quickstart: `https://github.com/microsoft/agent-framework/blob/main/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIProject/Program.cs`
70
+
#### Step 2: Search for feature guidelines
80
71
**Stage 1 - Identify Core Capabilities:**
81
72
Break down the user's requirement into individual capabilities
82
73
- Example: "Build a weather agent for user to query weather" → ["function calling"]
@@ -142,20 +133,20 @@ User Requirements Analysis:
142
133
143
134
### 2. Explain SDK selection
144
135
**Recommended SDK:** Microsoft Agent Framework
145
-
**Recommended Agent Type:** Azure AI Foundry Agents with PersistentAgentsClient
136
+
**Recommended Agent Type:** Azure AI Foundry Agents with AIProjectClient
146
137
**Default Programming Language:** .NET
147
138
148
139
** Agent Type Selection Rules **
149
-
- **ALWAYS use `PersistentAgentsClient` for Azure AI Foundry**
150
-
- **DO NOT use `AzureOpenAIClient`** for Azure AI Foundry models, even for demos, prototypes, or local testing
151
-
- `PersistentAgentsClient` provides service-managed persistence, conversation threads, and full agent capabilities
140
+
- **ALWAYS use `AIProjectClient` for Azure AI Foundry**
141
+
- **DO NOT use `AzureOpenAIClient` or `PersistentAgentsClient`** for Azure AI Foundry models, even for demos, prototypes, or local testing
142
+
- `AIProjectClient` provides service-managed persistence, conversation threads, and full agent capabilities
152
143
- Only use other agent types (OpenAI ChatCompletion, Azure OpenAI, etc.) if the user **explicitly requests a different service provider**
153
144
154
145
**Output format:**
155
146
```
156
147
SDK Selection: Microsoft Agent Framework
157
148
158
-
Agent Type: Azure AI Foundry Agents (PersistentAgentsClient)
149
+
Agent Type: Azure AI Foundry Agents (AIProjectClient)
159
150
160
151
Programming Language: [.NET (default) OR Python (if user specified)]
161
152
@@ -210,6 +201,7 @@ Create a step-by-step plan / todo list covering project initialization, installa
Copy file name to clipboardExpand all lines: tools/Azure.Mcp.Tools.AzureAIBestPractices/src/Resources/ai-error-patterns.txt
+80-47Lines changed: 80 additions & 47 deletions
Original file line number
Diff line number
Diff line change
@@ -74,79 +74,112 @@ var data = await context.ReadStateAsync<string>(key: stateId, scopeName: "MyScop
74
74
75
75
### Agent Type
76
76
#### Agent Type Selection
77
-
**IMPORTANT**: When using Azure AI Foundry, always use `PersistentAgentsClient` to create agents - NOT `AzureOpenAIClient`.
77
+
78
+
**For .NET:**
79
+
**IMPORTANT**: When using Azure AI Foundry, always use `AIProjectClient` to create agents - NOT `AzureOpenAIClient`.
78
80
- ❌ Do NOT use `AzureOpenAIClient` for Azure AI Foundry models - that's only for testing and lacks conversation persistence
79
-
- ✅ DO use `PersistentAgentsClient` - it provides full agent capabilities with service-managed state
81
+
- ✅ DO use `AIProjectClient` - it provides full agent capabilities with service-managed state and is the latest recommended approach
82
+
- ⚠️ `PersistentAgentsClient` is legacy - use `AIProjectClient` instead
80
83
81
-
Code samples may show `AzureOpenAIClient` for simplicity or backward compatibility, but production implementations should use `PersistentAgentsClient` for Azure AI Foundry.
84
+
Code samples may show `AzureOpenAIClient` for simplicity or backward compatibility, but production implementations should use `AIProjectClient` for Azure AI Foundry.
82
85
83
-
#### Key Difference: When to Pass ChatOptions
84
-
The main difference between `PersistentAgentsClient` and `AzureOpenAIClient` is **when** you configure ChatOptions (Tools, ResponseFormat, etc. ):
85
-
- **PersistentAgentsClient**: Pass ChatOptions when **retrieving** the agent via `GetAIAgentAsync()`
86
-
- **AzureOpenAIClient**: Pass options when **creating** the agent via `CreateAIAgent()`
86
+
#### Key Differences: AIProjectClient vs AzureOpenAIClient
87
87
88
-
Note: Only add ChatOptions properties (Tools, ResponseFormat, etc.) when user requirements explicitly need them. Do NOT add them by default.
88
+
**1. Creation Pattern:**
89
+
- `AIProjectClient` uses `await aiProjectClient.CreateAIAgentAsync(...)` - creates agents on the server
90
+
- `AzureOpenAIClient` uses `.GetChatClient(deploymentName).CreateAIAgent(...)` - creates local agents
89
91
90
-
#### ✅ CORRECT - PersistentAgentsClient Pattern
91
-
Pass all ChatOptions properties (tools, ResponseFormat, etc.) to `GetAIAgentAsync()`:
string endpoint = Environment.GetEnvironmentVariable("AZURE_FOUNDRY_PROJECT_ENDPOINT") ?? throw new InvalidOperationException("AZURE_FOUNDRY_PROJECT_ENDPOINT is not set.");
0 commit comments