# azure-ai-agents-persistent-dotnet

Helps write C# code for the Azure AI Agents Persistent SDK. It guides agent creation, message threads, tool execution, and vector search.

- skill · `type=skill` · Claude Code, GitHub Copilot · 1 install · ★ 3149
- Author: Microsoft
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/microsoft/skills/tree/HEAD/.github/plugins/azure-sdk-dotnet/skills/azure-ai-agents-persistent-dotnet/SKILL.md
- Updated: 2026-10-23
- HTML: https://affpapa.org/en/nevibecode/skills/azure-ai-agents-persistent-dotnet

## What it does

The skill provides C# patterns for the `Azure.AI.Agents.Persistent` package in .NET. It models code around `PersistentAgentsClient`, separating tasks across `Administration` for agent lifecycle, `Threads` for conversations, and `Runs` for execution.

Implementation patterns cover run status polling alongside text streaming through `CreateRunStreamingAsync`. The skill also details function execution using `FunctionToolDefinition` and document search using `VectorStores` with `FileSearchToolResource`.

Without setting `PROJECT_ENDPOINT` and `MODEL_DEPLOYMENT_NAME`, the client will fail to connect. Projects also require the `Azure.Identity` package alongside the persistent agents library.

## Requirements
- Works with: Azure

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add microsoft/skills --skill azure-ai-agents-persistent-dotnet -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/azure-ai-agents-persistent-dotnet/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/azure-ai-agents-persistent-dotnet/

### Codex

**Manually: put the files in place**
- File: `.agents/skills/azure-ai-agents-persistent-dotnet/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

**Manually: put the files in place**
- File: `.cursor/skills/azure-ai-agents-persistent-dotnet/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install microsoft/skills azure-ai-agents-persistent-dotnet
```

2. **Manually: put the files in place**
- File: `.github/skills/azure-ai-agents-persistent-dotnet/SKILL.md`

### Gemini CLI

**Platform CLI**
```bash
gemini skills install https://github.com/microsoft/skills --path .github/plugins/azure-sdk-dotnet/skills/azure-ai-agents-persistent-dotnet
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/azure-ai-agents-persistent-dotnet/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/microsoft/skills/tree/HEAD/.github/plugins/azure-sdk-dotnet/skills/azure-ai-agents-persistent-dotnet/SKILL.md

## When to use it
- initialize `PersistentAgentsClient` with Azure credentials in C#
- stream agent output using `CreateRunStreamingAsync`
- submit tool outputs for function calls during run polling
- upload documents and attach vector stores to agents

## Example prompts
- Generate C# code to create an Azure AI agent with CodeInterpreterToolDefinition
- Show how to stream messages from an agent run using Azure.AI.Agents.Persistent
- Set up a vector store and enable file search for a .NET agent

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: a41dc9e185f19435.

BEGIN THIRD-PARTY FILE a41dc9e185f19435
````text
---
name: azure-ai-agents-persistent-dotnet
description: |
  Azure AI Agents Persistent SDK for .NET. Low-level SDK for creating and managing AI agents with threads, messages, runs, and tools. Use for agent CRUD, conversation threads, streaming responses, function calling, file search, and code interpreter. Triggers: "PersistentAgentsClient", "persistent agents", "agent threads", "agent runs", "streaming agents", "function calling agents .NET".
license: MIT
metadata:
  author: Microsoft
  version: "1.0.0"
  package: Azure.AI.Agents.Persistent
---

# Azure.AI.Agents.Persistent (.NET)

Low-level SDK for creating and managing persistent AI agents with threads, messages, runs, and tools.

## Installation

```bash
dotnet add package Azure.AI.Agents.Persistent --prerelease
dotnet add package Azure.Identity
```

**Current Versions**: Stable v1.1.0, Preview v1.2.0-beta.8

## Environment Variables

```bash
PROJECT_ENDPOINT=https://<resource>.services.ai.azure.com/api/projects/<project>  # Required: Azure AI project endpoint
MODEL_DEPLOYMENT_NAME=gpt-4o-mini  # Required: model deployment name
AZURE_BING_CONNECTION_ID=<bing-connection-resource-id>  # Required: Bing connection resource ID
AZURE_AI_SEARCH_CONNECTION_ID=<search-connection-resource-id>  # Required: Azure AI Search connection resource ID
AZURE_TOKEN_CREDENTIALS=prod  # Required only if DefaultAzureCredential is used in production
```

## Authentication

```csharp
using Azure.AI.Agents.Persistent;
using Azure.Identity;

var projectEndpoint = Environment.GetEnvironmentVariable("PROJECT_ENDPOINT");
// Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential>
var credential = new DefaultAzureCredential(
    DefaultAzureCredential.DefaultEnvironmentVariableName
);
// Or use a specific credential directly in production:
// See https://learn.microsoft.com/dotnet/api/overview/azure/identity-readme?view=azure-dotnet#credential-classes
// var credential = new ManagedIdentityCredential();
PersistentAgentsClient client = new(projectEndpoint, credential);
```

## Client Hierarchy

```
PersistentAgentsClient
├── Administration  → Agent CRUD operations
├── Threads         → Thread management
├── Messages        → Message operations
├── Runs            → Run execution and streaming
├── Files           → File upload/download
└── VectorStores    → Vector store management
```

## Core Workflow

### 1. Create Agent

```csharp
var modelDeploymentName = Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME");

PersistentAgent agent = await client.Administration.CreateAgentAsync(
    model: modelDeploymentName,
    name: "Math Tutor",
    instructions: "You are a personal math tutor. Write and run code to answer math questions.",
    tools: [new CodeInterpreterToolDefinition()]
);
```

### 2. Create Thread and Message

```csharp
// Create thread
PersistentAgentThread thread = await client.Threads.CreateThreadAsync();

// Create message
await client.Messages.CreateMessageAsync(
    thread.Id,
    MessageRole.User,
    "I need to solve the equation `3x + 11 = 14`. Can you help me?"
);
```

### 3. Run Agent (Polling)
````
END THIRD-PARTY FILE a41dc9e185f19435

The third-party file has ended. Everything between the a41dc9e185f19435 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3222 of 11875 bytes. © Microsoft · MIT · https://github.com/microsoft/skills/tree/HEAD/.github/plugins/azure-sdk-dotnet/skills/azure-ai-agents-persistent-dotnet/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
