Add this skill
npx mdskills install sickn33/azure-ai-agents-persistent-javaDocumentation for Azure SDK usage, not actionable agent instructions or workflow triggers
1---2name: azure-ai-agents-persistent-java3description: |4 Azure AI Agents Persistent SDK for Java. Low-level SDK for creating and managing AI agents with threads, messages, runs, and tools.5 Triggers: "PersistentAgentsClient", "persistent agents java", "agent threads java", "agent runs java", "streaming agents java".6package: com.azure:azure-ai-agents-persistent7---89# Azure AI Agents Persistent SDK for Java1011Low-level SDK for creating and managing persistent AI agents with threads, messages, runs, and tools.1213## Installation1415```xml16<dependency>17 <groupId>com.azure</groupId>18 <artifactId>azure-ai-agents-persistent</artifactId>19 <version>1.0.0-beta.1</version>20</dependency>21```2223## Environment Variables2425```bash26PROJECT_ENDPOINT=https://<resource>.services.ai.azure.com/api/projects/<project>27MODEL_DEPLOYMENT_NAME=gpt-4o-mini28```2930## Authentication3132```java33import com.azure.ai.agents.persistent.PersistentAgentsClient;34import com.azure.ai.agents.persistent.PersistentAgentsClientBuilder;35import com.azure.identity.DefaultAzureCredentialBuilder;3637String endpoint = System.getenv("PROJECT_ENDPOINT");38PersistentAgentsClient client = new PersistentAgentsClientBuilder()39 .endpoint(endpoint)40 .credential(new DefaultAzureCredentialBuilder().build())41 .buildClient();42```4344## Key Concepts4546The Azure AI Agents Persistent SDK provides a low-level API for managing persistent agents that can be reused across sessions.4748### Client Hierarchy4950| Client | Purpose |51|--------|---------|52| `PersistentAgentsClient` | Sync client for agent operations |53| `PersistentAgentsAsyncClient` | Async client for agent operations |5455## Core Workflow5657### 1. Create Agent5859```java60// Create agent with tools61PersistentAgent agent = client.createAgent(62 modelDeploymentName,63 "Math Tutor",64 "You are a personal math tutor."65);66```6768### 2. Create Thread6970```java71PersistentAgentThread thread = client.createThread();72```7374### 3. Add Message7576```java77client.createMessage(78 thread.getId(),79 MessageRole.USER,80 "I need help with equations."81);82```8384### 4. Run Agent8586```java87ThreadRun run = client.createRun(thread.getId(), agent.getId());8889// Poll for completion90while (run.getStatus() == RunStatus.QUEUED || run.getStatus() == RunStatus.IN_PROGRESS) {91 Thread.sleep(500);92 run = client.getRun(thread.getId(), run.getId());93}94```9596### 5. Get Response9798```java99PagedIterable<PersistentThreadMessage> messages = client.listMessages(thread.getId());100for (PersistentThreadMessage message : messages) {101 System.out.println(message.getRole() + ": " + message.getContent());102}103```104105### 6. Cleanup106107```java108client.deleteThread(thread.getId());109client.deleteAgent(agent.getId());110```111112## Best Practices1131141. **Use DefaultAzureCredential** for production authentication1152. **Poll with appropriate delays** — 500ms recommended between status checks1163. **Clean up resources** — Delete threads and agents when done1174. **Handle all run statuses** — Check for RequiresAction, Failed, Cancelled1185. **Use async client** for better throughput in high-concurrency scenarios119120## Error Handling121122```java123import com.azure.core.exception.HttpResponseException;124125try {126 PersistentAgent agent = client.createAgent(modelName, name, instructions);127} catch (HttpResponseException e) {128 System.err.println("Error: " + e.getResponse().getStatusCode() + " - " + e.getMessage());129}130```131132## Reference Links133134| Resource | URL |135|----------|-----|136| Maven Package | https://central.sonatype.com/artifact/com.azure/azure-ai-agents-persistent |137| GitHub Source | https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/ai/azure-ai-agents-persistent |138
Full transparency — inspect the skill content before installing.