|
| 1 | +--- |
| 2 | +description: Azure AI Foundry Agent Service development mode - SDK research, MCP integration, and agent implementation patterns |
| 3 | +tools: ['edit', 'search', 'new', 'runCommands', 'runTasks', 'Microsoft Docs/*', 'github/github-mcp-server/get_file_contents', 'github/github-mcp-server/search_code', 'microsoft/playwright-mcp/*', 'runSubagent', 'usages', 'vscodeAPI', 'problems', 'changes', 'fetch', 'githubRepo', 'extensions', 'todos'] |
| 4 | +model: Claude Sonnet 4.5 (copilot) |
| 5 | +--- |
| 6 | + |
| 7 | +# Azure AI Agent Development Mode |
| 8 | + |
| 9 | +**Purpose**: Specialized mode for Azure AI Foundry Agent Service development with ASP.NET Core + React. |
| 10 | + |
| 11 | +**When to use**: AI agent features, authentication, SDK integrations, state management, UI components. |
| 12 | + |
| 13 | +## Documentation Layers |
| 14 | + |
| 15 | +Avoid token waste by understanding what lives where: |
| 16 | + |
| 17 | +1. **copilot-instructions.md** (always loaded) → Architecture, workflows, deployment commands, critical patterns |
| 18 | +2. **AGENTS.md files** (loaded on-demand) → Implementation details when touching backend/, frontend/, infra/, deployment/ |
| 19 | +3. **This file** → SDK research patterns, MCP tool usage, testing workflows |
| 20 | + |
| 21 | +**Your role**: Research SDKs, validate with tests, connect documentation sources. Don't duplicate what's in copilot-instructions.md. |
| 22 | + |
| 23 | +## Azure AI Agent SDK Research Pattern |
| 24 | + |
| 25 | +**CRITICAL**: Don't guess SDK usage. Follow this research workflow: |
| 26 | + |
| 27 | +### 1. Search Official Documentation (Start here) |
| 28 | + |
| 29 | +**Official SDK Repository**: https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/ai/Azure.AI.Agents.Persistent |
| 30 | + |
| 31 | +Use available MCP tools to search Microsoft Learn documentation for Azure AI Agents Persistent SDK features, patterns, and examples. |
| 32 | + |
| 33 | +### 2. Check Semantic Kernel Samples (Complementary patterns) |
| 34 | + |
| 35 | +**Repository**: https://github.com/microsoft/semantic-kernel |
| 36 | + |
| 37 | +**Relevant paths**: |
| 38 | +- `dotnet/samples/GettingStartedWithAgents/AzureAIAgent/` - Getting started examples |
| 39 | +- `dotnet/samples/Concepts/Agents/` - Advanced patterns (Step##_*.cs files) |
| 40 | + |
| 41 | +Semantic Kernel provides rich examples of Azure AI Agent patterns using its abstraction layer. Use available GitHub MCP tools to search and browse these samples for proven implementation patterns. |
| 42 | + |
| 43 | +**Note**: Semantic Kernel abstracts agent operations through its framework. When adapting patterns, translate SK abstractions to direct Azure.AI.Agents.Persistent SDK types. |
| 44 | + |
| 45 | +### 3. Azure AI Foundry Agent Samples |
| 46 | + |
| 47 | +**Official Samples Repository**: https://github.com/azure-ai-foundry/foundry-samples |
| 48 | + |
| 49 | +**Key paths**: |
| 50 | +- `samples/microsoft/csharp/getting-started-agents/` - C# quickstart samples |
| 51 | +- `samples/microsoft/python/getting-started-agents/` - Python quickstart samples |
| 52 | +- `samples/microsoft/typescript/getting-started-agents/` - TypeScript quickstart samples |
| 53 | +- `samples/microsoft/data/` - Sample data files (product info, etc.) |
| 54 | + |
| 55 | +These are the official Azure AI Foundry Agent Service samples showing function calling, file search, code interpreter, and streaming patterns. Use available GitHub MCP tools to explore language-specific implementations. |
| 56 | + |
| 57 | +**Additional UI Sample**: https://github.com/Azure-Samples/get-started-with-ai-agents |
| 58 | +- React-based chat UI components and UX patterns |
| 59 | +- **Note**: Backend uses Node.js - focus on frontend patterns only |
| 60 | + |
| 61 | +### 4. Broad Code Search (Last resort) |
| 62 | + |
| 63 | +Use available GitHub search tools to find usage examples of specific Azure.AI.Agents.Persistent types across public repositories when official documentation is insufficient. |
| 64 | + |
| 65 | +### Current SDK Version |
| 66 | + |
| 67 | +**Package**: `Azure.AI.Agents.Persistent` v1.2.0-beta.6 (pinned in WebApp.Api.csproj) |
| 68 | + |
| 69 | +**Why pinned**: Beta SDK with evolving API surface. Upgrade deliberately to avoid breaking changes. |
| 70 | + |
| 71 | +**Resources**: |
| 72 | +- **NuGet**: https://www.nuget.org/packages/Azure.AI.Agents.Persistent |
| 73 | +- **SDK Source**: https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/ai/Azure.AI.Agents.Persistent |
| 74 | +- **API Reference**: https://learn.microsoft.com/en-us/dotnet/api/azure.ai.agents.persistent |
| 75 | +- **Official Samples**: https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/ai/Azure.AI.Agents.Persistent/samples |
| 76 | + |
| 77 | +**Key sample files**: |
| 78 | +- Function calling with streaming |
| 79 | +- MCP tool integration |
| 80 | +- File upload and vector search |
| 81 | +- Async patterns |
| 82 | + |
| 83 | +### Microsoft Agent Framework (Higher-level abstraction) |
| 84 | + |
| 85 | +**Package**: `Microsoft.Agents.AI.AzureAI` v1.0.0-preview (also in project) |
| 86 | + |
| 87 | +The Microsoft Agent Framework provides a higher-level abstraction over the Azure AI Foundry Agent Service, offering simplified agent creation and orchestration patterns. |
| 88 | + |
| 89 | +**Resources**: |
| 90 | +- **NuGet**: https://www.nuget.org/packages/Microsoft.Agents.AI.AzureAI |
| 91 | +- **Documentation**: https://learn.microsoft.com/en-us/agent-framework/user-guide/agents/agent-types/azure-ai-foundry-agent |
| 92 | +- **GitHub Samples**: https://github.com/microsoft/agent-framework/tree/main/dotnet/samples |
| 93 | +- **Quickstart**: https://learn.microsoft.com/en-us/agent-framework/tutorials/quick-start |
| 94 | + |
| 95 | +**When to use**: |
| 96 | +- Need unified agent abstraction across multiple AI services |
| 97 | +- Want simplified agent lifecycle management |
| 98 | +- Building multi-agent orchestration scenarios |
| 99 | +- Prefer higher-level `AIAgent` abstractions over direct SDK calls |
| 100 | + |
| 101 | +**Relationship**: Agent Framework wraps `PersistentAgentsClient` and provides `CreateAIAgentAsync()` extension methods for simplified agent creation. Both can coexist in the same project. |
| 102 | + |
| 103 | +See backend/AGENTS.md for full implementation patterns (credentials, streaming, error handling, cancellation tokens). |
| 104 | + |
| 105 | +## Testing with Playwright MCP |
| 106 | + |
| 107 | +**CRITICAL**: Always test changes before completion. |
| 108 | + |
| 109 | +### Testing Priority (Token efficiency) |
| 110 | + |
| 111 | +1. **Console logs** - State transitions, errors (0 tokens) |
| 112 | +2. **Network tab** - API calls, status codes (minimal tokens) |
| 113 | +3. **Accessibility snapshot** - DOM structure (low tokens) |
| 114 | +4. **Screenshots** - Visual verification (high tokens - only when essential) |
| 115 | + |
| 116 | +### Workflow |
| 117 | + |
| 118 | +```powershell |
| 119 | +# Start servers |
| 120 | +.\deployment\scripts\start-local-dev.ps1 |
| 121 | +
|
| 122 | +# Then use Playwright MCP: |
| 123 | +# 1. Navigate to http://localhost:5173 |
| 124 | +# 2. Check console (before/after interactions) |
| 125 | +# 3. Verify network requests |
| 126 | +# 4. Take accessibility snapshot for DOM validation |
| 127 | +``` |
| 128 | + |
| 129 | +### When to Test (Not optional) |
| 130 | + |
| 131 | +- After UI component or API endpoint changes |
| 132 | +- Before committing multi-step implementations |
| 133 | +- When user reports issues |
| 134 | + |
| 135 | +### Validation Checklist |
| 136 | + |
| 137 | +- [ ] Console shows expected actions (🔄 [timestamp] ACTION_TYPE) |
| 138 | +- [ ] No console errors/warnings |
| 139 | +- [ ] Network tab shows correct status codes (200/400/401/500) |
| 140 | +- [ ] DOM elements present in accessibility snapshot |
| 141 | + |
| 142 | +## MCP Tool Usage Strategy |
| 143 | + |
| 144 | +### Documentation Research |
| 145 | + |
| 146 | +Use available Microsoft Learn documentation tools to: |
| 147 | +1. **Search** Microsoft Learn for Azure AI Agents SDK topics |
| 148 | +2. **Fetch** complete documentation pages when search results need more depth |
| 149 | +3. Find official samples, API references, and best practices |
| 150 | + |
| 151 | +### GitHub Repository Access |
| 152 | + |
| 153 | +Use available GitHub MCP tools to: |
| 154 | +1. **Search code** across repositories for implementation examples |
| 155 | +2. **Browse files** in specific paths for sample code |
| 156 | +3. Access repositories: Azure SDK, Semantic Kernel, Azure Samples |
| 157 | + |
| 158 | +### Browser Testing |
| 159 | + |
| 160 | +Use available browser automation tools to: |
| 161 | +1. Navigate to http://localhost:5173 after starting local dev |
| 162 | +2. Check console logs for state transitions and errors |
| 163 | +3. Inspect network requests for API validation |
| 164 | +4. Capture accessibility snapshots for DOM structure |
| 165 | +5. Take screenshots only when visual verification is essential |
| 166 | + |
| 167 | +## Project-Specific Context |
| 168 | + |
| 169 | +**Architecture**: Single-conversation UI (full-width chat, no sidebar/history) |
| 170 | +**State**: Redux-style via React Context + useReducer with dev logging |
| 171 | + |
| 172 | +### AI Agent Service Configuration |
| 173 | + |
| 174 | +**Auto-discovery** (`azd up`): Searches subscription for AI Foundry resources → prompts user to select if multiple exist → discovers agents via REST API → validates RBAC permissions → configures everything automatically. |
| 175 | + |
| 176 | +**Change resource**: `azd provision` (re-runs discovery + updates RBAC + regenerates `.env` files) or `azd env set AI_FOUNDRY_RESOURCE_GROUP <rg>` then `azd provision`. |
| 177 | + |
| 178 | +**Implementation**: `deployment/hooks/preprovision.ps1` (discovery), `infra/main.bicep` (RBAC via `core/security/role-assignment.bicep`). |
0 commit comments