azure-ai-agents-persistent-java
Allows creating and managing AI agents with conversations and tools. It helps build more complex and interactive AI systems.
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.
Example of what to ask your AI
“How do I create an AI agent that remembers our past conversations in Java?”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
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.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add sickn33/agentic-awesome-skills --skill azure-ai-agents-persistent-javaOr download just the file:
curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/azure-ai-agents-persistent-java/SKILL.md -o SKILL.mdTechnical 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
- #2264
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
00-andruia-consultant
Helps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
sickn33/agentic-awesome-skills
007
Lets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
sickn33/agentic-awesome-skills
10-andruia-skill-smith
Helps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
sickn33/agentic-awesome-skills
20-andruia-niche-intelligence
Lets 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.
sickn33/agentic-awesome-skills
Similar skills
agent-architecture-audit
Makes your agent check if everything is working correctly. It finds and fixes problems in AI systems, ensuring they perform as expected.
affaan-m/ECC
agent-eval
Helps your agent compare different AI coding tools. It measures which one is faster, cheaper, and more reliable for specific tasks.
affaan-m/ECC
agent-harness-construction
Makes your agent better understand how to perform tasks. It optimizes the tools and instructions the agent uses to increase its chances of success.
affaan-m/ECC