$npx -y skills add managedcode/dotnet-skills --skill microsoft-agent-frameworkBuild .NET AI agents and multi-agent workflows with Microsoft Agent Framework using the right agent type, threads, tools, workflows, hosting protocols, and enterprise guardrails. USE FOR: building or reviewing .NET code that uses Microsoft.Agents.*, Microsoft.Extensions.AI, AIAge
| 1 | # Microsoft Agent Framework |
| 2 | |
| 3 | ## Trigger On |
| 4 | |
| 5 | - building or reviewing `.NET` code that uses `Microsoft.Agents.*`, `Microsoft.Extensions.AI`, `AIAgent`, `AgentThread`, `AgentSession`, or Agent Framework hosting packages |
| 6 | - choosing between `ChatClientAgent`, Responses agents, hosted agents, custom agents, Anthropic agents, workflows, or durable agents |
| 7 | - authoring preview-era `Microsoft.Agents.AI.Workflows.Declarative*` packages or wrapping a workflow with `workflow.AsAIAgent()` |
| 8 | - adding tools, MCP, A2A, OpenAI-compatible hosting, AG-UI, DevUI, background responses, or OpenTelemetry |
| 9 | - migrating from Semantic Kernel agent APIs or aligning AutoGen-style multi-agent patterns to Agent Framework |
| 10 | - using Anthropic Claude models (haiku, sonnet, opus) via `AnthropicClient` or through Azure Foundry with `AnthropicFoundryClient` |
| 11 | |
| 12 | ## Workflow |
| 13 | |
| 14 | 1. Decide whether the problem should stay deterministic. If plain code or a typed workflow without LLM autonomy is enough, do that instead of adding an agent. |
| 15 | 2. Choose the execution shape first: single `AIAgent`, explicit programmatic `Workflow`, workflow-as-agent wrapper, declarative workflow when YAML portability is explicitly required, Azure Functions durable agent, ASP.NET Core hosted agent, AG-UI remote UI, or DevUI local debugging. |
| 16 | 3. Choose the agent type and provider intentionally. Prefer the simplest agent that satisfies the threading, tooling, and hosting requirements. |
| 17 | 4. Keep agents stateless and keep conversation or long-lived state in provider-owned session objects. Most persistence guidance still centers on `AgentThread`, while newer middleware and background-response examples may surface `AgentSession`. Treat both as opaque provider-specific state. |
| 18 | 5. Add only the tools and middleware that the scenario needs. Narrow the tool surface, require approval for side effects, and treat MCP, A2A, and third-party services as trust boundaries. |
| 19 | 6. For workflows, model executors, edges, typed `RequestPort` boundaries, checkpoints, shared state, and human-in-the-loop explicitly rather than hiding control flow in prompts. |
| 20 | 7. Prefer Responses-based protocols for new remote/OpenAI-compatible integrations unless you specifically need Chat Completions compatibility. |
| 21 | 8. Use durable agents only when you truly need Azure Functions serverless hosting, durable thread storage, or deterministic long-running orchestrations. |
| 22 | 9. Verify preview status, package maturity, docs recency, and provider-specific limitations before locking a production architecture. |
| 23 | |
| 24 | ## Current Upstream Notes |
| 25 | |
| 26 | - The July 2026 overview now describes one Agent Framework across .NET, Python, and Go. This catalog skill remains intentionally .NET-scoped; do not infer API or feature parity from cross-language overview wording. |
| 27 | - The refreshed AG-UI security guidance keeps the browser outside the trust boundary: put a trusted frontend/server mediator in front of the AG-UI server, validate client-supplied messages, state, tools, and forwarded properties, and filter sensitive tool or agent output before streaming it back. |
| 28 | - Middleware, function-tool, migration, support, troubleshooting, upgrade, durable-agent, observability, and AG-UI pages all changed in the same review window. Check the exact current .NET page before relying on a Python example or an older preview signature. |
| 29 | |
| 30 | ## Architecture |
| 31 | |
| 32 | ```mermaid |
| 33 | flowchart LR |
| 34 | A["Task"] --> B{"Deterministic code is enough?"} |
| 35 | B -->|Yes| C["Write normal .NET code or a plain workflow"] |
| 36 | B -->|No| D{"One dynamic decision-maker is enough?"} |
| 37 | D -->|Yes| E["Use an `AIAgent` / `ChatClientAgent`"] |
| 38 | D -->|No| F["Use a typed `Workflow`"] |
| 39 | F --> G{"Needs durable Azure hosting or week-long execution?"} |
| 40 | G -->|Yes| H["Use durable agents on Azure Functions"] |
| 41 | G -->|No| I["Use in-process workflows"] |
| 42 | E --> J{"Need a remote protocol or UI?"} |
| 43 | F --> J |
| 44 | J -->|OpenAI-compatible HTTP| K["ASP.NET Core Hosting.OpenAI"] |
| 45 | J -->|Agent-to-agent protocol| L["A2A hosting"] |
| 46 | J -->|Web UI protocol| M["AG-UI"] |
| 47 | J -->|Local debug shell| N["DevUI (dev only)"] |
| 48 | ``` |
| 49 | |
| 50 | ## Core Knowledge |
| 51 | |
| 52 | - `AIAgent` is the common runtime abstraction. It should stay mostly stateless. |
| 53 | - `AgentThread` still anchors most persisted conversation guidance, |