$39
You are building AI agents using the Anthropic C# SDK in .NET. There is no .NET Agent SDK — agents must be built manually atop the Messages API. Read the relevant docs below based on what you're building.
| Need | Pattern | Doc |
|---|---|---|
| Simplest agent with auto tool loop | IChatClient + UseFunctionInvocation() | 06 |
| Full control over each tool call | Manual Messages API loop | 06 |
| Stream responses to user in real-time | Streaming agentic loop | 07 |
| Production service with DI | DI-friendly agent service | 02, 06 |
| Complex reasoning before acting | Extended thinking | 08 |
| Choose between SDK packages | SDK comparison | 01 |
| Connect to external tool servers | MCP integration | 13 |
| Multi-step orchestration | Architecture patterns | 12 |
UseFunctionInvocation() with IChatClient.end_turn means done, tool_use means execute tools and continue. Ignoring this breaks the loop.UseFunctionInvocation() handles the tool loop automatically. Only use manual loops when you need per-iteration control.IAsyncEnumerable streams must be properly consumed or disposed. Use await foreach or ConfigureAwait(false).CreateStreaming, not the synchronous Create method.ANTHROPIC_API_KEY), user secrets, or a vault.tool_result with is_error: true. Don't let tool failures crash the loop.