azure-ai-agents-persistent-java
What it does
This is a toolkit for Java programmers to create and manage AI agents that remember past conversations. It allows agents to have 'memory' and continue dialogues.
When to use it
- ✓When you want a chatbot to remember what was said before.
- ✓When creating a virtual assistant that needs to maintain conversation context.
- ✓For developing applications where AI needs to interact continuously.
Skill link
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-ai-agents-persistent-java/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“How do I create an AI agent that remembers our past conversations in Java?”
5 new skills a week. 1 minute to read.
How it works
You use special code (SDK) in Java to tell the system how to create an agent, start a conversation (thread), send messages, and get responses. The system manages the agent's 'memory' for you.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
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.2</version>
</dependency>
Environment Variables
export PROJECT_ENDPOINT="https://<resource>.services.ai.azure.com/api/projects/<project>"
export MODEL_DEPLOYMENT_NAME="gpt-4o-mini"
Authentication
import com.azure.ai.agents.persistent.PersistentAgentsClient;
import com.azure.ai.agents.persistent.PersistentAgentsClientBuilder;
import com.azure.ai.agents.persistent.*;
import com.azure.ai.agents.persistent.models.*;
import com.azure.core.http.rest.PagedIterable;
import com.azure.identity.DefaultAzureCredentialBuilder;
String endpoint = System.getenv("PROJECT_ENDPOINT");
PersistentAgentsClient client = new PersistentAgentsClientBuilder()
.endpoint(endpoint)
.credential(new DefaultAzureCredentialBuilder().build())
.buildClient();
String modelDeploymentName = System.getenv("MODEL_DEPLOYMENT_NAME");
PersistentAgentsAdministrationClient administration = client.getPersistentAgentsAdministrationClient();
ThreadsClient threads = client.getThreadsClient();
MessagesClient messageClient = client.getMessagesClient();
RunsClient runs = client.getRunsClient();
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 = administration.createAgent(
new CreateAgentOptions(modelDeploymentName)
.setName("Math Tutor")
.setInstructions("You are a personal math tutor.")
);
2. Create Thread
PersistentAgentThread thread = threads.createThread();
3. Add Message
messageClient.createMessage(
thread.getId(),
MessageRole.USER,
"I need help with equations."
);
4. Run Agent
ThreadRun run = runs.createRun(new CreateRunOptions(thread.getId(), agent.getId()));
// Bound polling; a terminal non-success state is not a completed answer.
long deadline = System.nanoTime() + java.util.concurrent.TimeUnit.SECONDS.toNanos(60);
while (run.getStatus() == RunStatus.QUEUED || run.getStatus() == RunStatus.IN_PROGRESS) {
if (System.nanoTime() > deadline) {
throw new IllegalStateException("Run polling timed out; inspect/cancel the owned run separately");
}
Thread.sleep(500);
run = runs.getRun(thread.getId(), run.getId());
}
Check the resulting status before reading a final response: requires_action needs an authorized tool-output handler; failed, cancelled, expired or other non-success states must be reported explicitly. A polling timeout does not cancel the cloud run.
5. Get Response
PagedIterable<ThreadMessage> messages = messageClient.listMessages(thread.getId());
for (ThreadMessage message : messages) {
System.out.println(message.getRole() + ": " + message.getContent());
}
6. Cleanup
threads.deleteThread(thread.getId());
administration.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 exampleAgent = administration.createAgent(
new CreateAgentOptions(modelDeploymentName).setName("Example").setInstructions("Answer briefly"));
} catch (HttpResponseException e) {
System.err.println("Error: " + e.getResponse().getStatusCode() + " - " + e.getMessage());
}
Reference Links
| Resource | URL |
|---|---|
| Maven Package | https://central.sonatype.com/artifact/com.azure/azure-ai-agents-persistent |
| GitHub Source | https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/ai/azure-ai-agents-persistent |
…
FAQ
What are 'threads', 'messages', and 'runs'?
'Threads' are the conversations. 'Messages' are what you and the agent say. 'Runs' are the times the agent processes messages to generate a response.
Do I need to know a lot about AI to use this?
This toolkit is for programmers. It simplifies AI usage, but you still need to know how to program in Java.
What happens if the program encounters an error?
The system might show error messages. It's important to check the status of each action and clean up created resources to avoid unnecessary costs.
Details
Original description by the author
Azure AI Agents Persistent SDK for Java. Low-level SDK for creating and managing AI agents with threads, messages, runs, and tools.
Popularity
- GitHub stars
- 48k
- Ranking position
- #3878
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
00-andruia-consultant
48kHelps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
007
48kLets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
10-andruia-skill-smith
48kHelps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
20-andruia-niche-intelligence
48kLets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
Similar skills
add-model-provider
394kLets your agent connect a new AI model provider to OpenClaw using safe setup commands, keep API keys out of plain text, and run a live test.
acp-router
394kHelps your agent send a task to a coding assistant such as Claude Code or Cursor through OpenClaw, so the work runs in that tool.
browser-automation
394kTeaches your agent to control web pages step by step, including logins, tabs, and recovery when a page stops responding.