Azure AI Agents Persistent Java
MicrosoftOfficialCreated by Microsoft
- Skill
- Tool integration
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The Azure AI Agents Persistent SDK for Java provides a low-level interface for developers to build and manage stateful AI agents. It supports the full lifecycle of agent interactions, including agent creation, thread management, message handling, and execution runs. The SDK is designed for integration with Azure AI services, offering both synchronous and asynchronous clients to handle agent operations, tool definitions, and status polling.
What it does
- Provides clients for managing persistent AI agents and their configurations.
- Supports thread creation and message management for multi-turn conversations.
- Enables agent execution runs with status polling and completion tracking.
- Allows integration of custom tools and code interpreters into agent workflows.
- Offers both synchronous and asynchronous API patterns for Java applications.
- Facilitates secure authentication using Azure Identity credentials.
When to use it
- When building Java applications that require stateful, persistent AI assistants.
- When you need to manage complex agent-based workflows with threads and tool calls.
- When integrating Azure AI agent capabilities into enterprise Java backends.
- When you require granular control over agent lifecycle, including cleanup and resource management.
Advantages
- Native Java support for Azure AI agent services.
- Flexible configuration for agent behavior, including temperature and top-P settings.
- Comprehensive support for tool definitions, including function calling and code interpretation.
- Asynchronous client support for high-concurrency environments.
Usage examples
- “How do I initialize the PersistentAgentsClient in Java?”
- Use the PersistentAgentsClientBuilder to set your project endpoint and provide a TokenCredential, such as DefaultAzureCredential, to build the client.
- “Show me how to create a new agent with a tool.”
- Instantiate a CreateAgentOptions object, define your tools (e.g., CodeInterpreterToolDefinition or FunctionToolDefinition), and pass the options to the client.createAgent method.
- “How do I run an agent on a specific thread?”
- Use client.createRun with the thread ID and agent ID, then implement a loop to poll the run status until it is no longer QUEUED or IN_PROGRESS.
- “How can I clean up agent resources?”
- Call client.deleteThread(threadId) and client.deleteAgent(agentId) to remove the resources from the service.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/microsoft/azure-ai-agents-persistent-java/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip azure-ai-agents-persistent-java.zip -d .agents/skills
Documentation by Microsoft
Azure AI Agents Persistent SDK for Java
Low-level SDK for creating and managing persistent AI agents with threads, messages, runs, and tools.
Installation
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-ai-agents-persistent</artifactId>
<version>1.0.0-beta.1</version>
</dependency>Environment Variables
PROJECT_ENDPOINT=https://<resource>.services.ai.azure.com/api/projects/<project> # Required for project configuration
MODEL_DEPLOYMENT_NAME=gpt-4o-mini # Required for agent model selection
AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in productionAuthentication
import com.azure.ai.agents.persistent.PersistentAgentsClient;
import com.azure.ai.agents.persistent.PersistentAgentsClientBuilder;
import com.azure.core.credential.TokenCredential;
import com.azure.identity.AzureIdentityEnvVars;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.identity.ManagedIdentityCredentialBuilder;
String endpoint = System.getenv("PROJECT_ENDPOINT");
TokenCredential credential = new DefaultAzureCredentialBuilder()
.requireEnvVars(AzureIdentityEnvVars.AZURE_TOKEN_CREDENTIALS)
.build();
// Or use a specific credential directly in production:
// See https://learn.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable#credential-classes
// TokenCredential credential = new ManagedIdentityCredentialBuilder().build();
PersistentAgentsClient client = new PersistentAgentsClientBuilder()
.endpoint(endpoint)
.credential(credential)
.buildClient();Key Concepts
The Azure AI Agents Persistent SDK provides a low-level API for managing persistent agents that can be reused across sessions.
Client Hierarchy
| Client | Purpose |
|---|---|
PersistentAgentsClient | Sync client for agent operations |
PersistentAgentsAsyncClient | Async client for agent operations |
Core Workflow
1. Create Agent
// Create agent with tools
PersistentAgent agent = client.createAgent(
modelDeploymentName,
"Math Tutor",
"You are a personal math tutor."
);2. Create Thread
PersistentAgentThread thread = client.createThread();3. Add Message
client.createMessage(
thread.getId(),
MessageRole.USER,
"I need help with equations."
);4. Run Agent
ThreadRun run = client.createRun(thread.getId(), agent.getId());
// Poll for completion
while (run.getStatus() == RunStatus.QUEUED || run.getStatus() == RunStatus.IN_PROGRESS) {
Thread.sleep(500);
run = client.getRun(thread.getId(), run.getId());
}5. Get Response
PagedIterable<PersistentThreadMessage> messages = client.listMessages(thread.getId());
for (PersistentThreadMessage message : messages) {
System.out.println(message.getRole() + ": " + message.getContent());
}6. Cleanup
client.deleteThread(thread.getId());
client.deleteAgent(agent.getId());Best Practices
Use DefaultAzureCredential for production authentication
Poll with appropriate delays — 500ms recommended between status checks
Clean up resources — Delete threads and agents when done
Handle all run statuses — Check for RequiresAction, Failed, Cancelled
Use async client for better throughput in high-concurrency scenarios
Error Handling
import com.azure.core.exception.HttpResponseException;
try {
PersistentAgent agent = client.createAgent(modelName, name, instructions);
} catch (HttpResponseException e) {
System.err.println("Error: " + e.getResponse().getStatusCode() + " - " + e.getMessage());
}Reference Links
Files
- ATTRIBUTION.mdAdded by AutoGineer1000 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md4.3 KiB
- references/examples.md22.2 KiB
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Microsoft
- Publisher
- Microsoft (Official)
- Source
- microsoft/skills · .github/plugins/azure-sdk-java/skills/azure-ai-agents-persistent-java · commit 0696600
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Microsoft or Microsoft.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download azure-ai-agents-persistent-java.zip