Skip to content

Commit 85f428b

Browse files
authored
Update code used in docs for latest release (#644)
* docs: update SDK versions to latest stable releases with breaking API changes Dependencies updated: - Java: azure-ai-agents 1.0.0-beta.2 → 2.0.0, azure-ai-projects 1.0.0-beta.2 → 2.1.0, azure-ai-inference 1.0.0-beta.5 → 1.0.0 - Python: azure-ai-projects pinned to 2.3.0 (stable) for all quickstart and enterprise samples - C#: Azure.AI.Projects 1.2.0-beta → 2.0.0, Azure.AI.Projects.OpenAI 1.0.0-beta → 1.0.0, Azure.Identity 1.17.1 → 1.20.0 Breaking Changes: - Java: Replaced azure-ai-agents-persistent package with azure-ai-agents * Updated class imports: PersistentAgentsClient → AgentsClient * Updated builder pattern: PersistentAgentsClientBuilder → AgentsClientBuilder * Updated agent model classes and API calls - Python: Updated OpenAI client binding to use new agent binding pattern * Old: openai.responses.create(..., extra_body={'agent_reference': ...}) * New: openai = project.get_openai_client(agent_name=AGENT_NAME) - C#: Pinned OpenAI package version to 2.2.1 (removed wildcard) Files affected: - /samples-classic/java/quickstart/pom.xml - /samples-classic/java/quickstart/src/main/java/com/azure/ai/foundry/samples/*.java - /samples/python/enterprise-agent-tutorial/requirements.txt - /samples/python/quickstart/*/requirements.txt - /samples/csharp/enterprise-agent-tutorial/*/csproj - /samples/python/quickstart/chat-with-agent/quickstart-chat-with-agent.py * docs: add comprehensive SDK update summary with breaking changes documentation This summary document provides: - Complete list of all dependency version changes - Detailed breaking changes with before/after code examples - Specific files affected by each change - Testing recommendations for each language - Verification checklist for reviewing changes * remove summary md file --------- Co-authored-by: sdgilley <3650506+sdgilley@users.noreply.github.com>
1 parent 7e64a22 commit 85f428b

7 files changed

Lines changed: 99 additions & 93 deletions

File tree

samples-classic/java/quickstart/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525
<dependencies>
2626
<dependency>
2727
<groupId>com.azure</groupId>
28-
<artifactId>azure-ai-agents-persistent</artifactId>
29-
<version>1.0.0-beta.2</version>
28+
<artifactId>azure-ai-agents</artifactId>
29+
<version>2.0.0</version>
3030
</dependency>
3131
<dependency>
3232
<groupId>com.azure</groupId>
3333
<artifactId>azure-ai-projects</artifactId>
34-
<version>1.0.0-beta.2</version>
34+
<version>2.1.0</version>
3535
</dependency>
3636
<dependency>
3737
<groupId>com.azure</groupId>
3838
<artifactId>azure-ai-inference</artifactId>
39-
<version>1.0.0-beta.5</version>
39+
<version>1.0.0</version>
4040
</dependency>
4141
<dependency>
4242
<groupId>com.openai</groupId>

samples-classic/java/quickstart/src/main/java/com/azure/ai/foundry/samples/AgentSample.java

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
package com.azure.ai.foundry.samples;
22

3-
import com.azure.ai.agents.persistent.PersistentAgentsClient;
4-
import com.azure.ai.agents.persistent.PersistentAgentsClientBuilder;
5-
import com.azure.ai.agents.persistent.PersistentAgentsAdministrationClient;
6-
import com.azure.ai.agents.persistent.models.CreateAgentOptions;
7-
import com.azure.ai.agents.persistent.models.CreateThreadAndRunOptions;
8-
import com.azure.ai.agents.persistent.models.PersistentAgent;
9-
import com.azure.ai.agents.persistent.models.ThreadRun;
3+
import com.azure.ai.agents.AgentsClient;
4+
import com.azure.ai.agents.AgentsClientBuilder;
5+
import com.azure.ai.agents.ResponsesClient;
6+
import com.azure.ai.agents.models.AgentDetails;
7+
import com.azure.ai.agents.models.AgentVersionDetails;
8+
import com.azure.ai.agents.models.PromptAgentDefinition;
109
import com.azure.core.credential.TokenCredential;
1110
import com.azure.core.exception.HttpResponseException;
1211
import com.azure.core.util.logging.ClientLogger;
1312
import com.azure.identity.DefaultAzureCredentialBuilder;
13+
import com.openai.client.OpenAIClient;
14+
import com.openai.models.conversations.Conversation;
15+
import com.openai.models.responses.Response;
1416

1517

1618
/**
17-
* Sample demonstrating how to work with Azure AI Agents using the Azure AI Agents Persistent SDK.
19+
* Sample demonstrating how to work with Azure AI Agents using the Azure AI Agents SDK v2.
1820
*
1921
* This sample shows how to:
2022
* - Set up authentication with Azure credentials
21-
* - Create a persistent agent with custom instructions
22-
* - Start a thread and run with the agent
23-
* - Access various properties of the agent and thread run
24-
* - Work with the PersistentAgentsClient and PersistentAgentsAdministrationClient
23+
* - Create an agent with custom instructions
24+
* - Start a conversation with the agent
25+
* - Get responses from the agent
26+
* - Work with the AgentsClient and ResponsesClient
2527
*
2628
* Environment variables:
2729
* - AZURE_ENDPOINT: Optional fallback. The base endpoint for your Azure AI service if PROJECT_ENDPOINT is not provided.
@@ -34,14 +36,13 @@
3436
* multiple authentication methods including environment variables, managed identities, and interactive login.
3537
*
3638
* SDK Features Demonstrated:
37-
* - Using the Azure AI Agents Persistent SDK (com.azure:azure-ai-agents-persistent:1.0.0-beta.2)
39+
* - Using the Azure AI Agents SDK (com.azure:azure-ai-agents:2.0.0)
3840
* - Creating an authenticated client with DefaultAzureCredential
39-
* - Using the PersistentAgentsClientBuilder pattern for client instantiation
40-
* - Working with the PersistentAgentsAdministrationClient for agent management
41+
* - Using the AgentsClientBuilder pattern for client instantiation
4142
* - Creating agents with specific configurations (name, model, instructions)
42-
* - Starting threads and runs for agent conversations
43-
* - Working with agent state and thread management
44-
* - Accessing agent and thread run properties
43+
* - Creating conversations and getting responses from agents
44+
* - Working with agent versions
45+
* - Accessing agent properties
4546
* - Implementing proper error handling for Azure service interactions
4647
*/
4748
public class AgentSample {
@@ -92,42 +93,41 @@ public static void main(String[] args) {
9293
TokenCredential credential = new DefaultAzureCredentialBuilder().build();
9394

9495
try {
95-
// Build the general agents client
96-
logger.info("Creating PersistentAgentsClient with endpoint: {}", projectEndpoint);
97-
PersistentAgentsClient agentsClient = new PersistentAgentsClientBuilder()
98-
.endpoint(projectEndpoint)
96+
// Build the agents client and related clients
97+
logger.info("Creating AgentsClient with endpoint: {}", projectEndpoint);
98+
AgentsClientBuilder builder = new AgentsClientBuilder()
9999
.credential(credential)
100-
.buildClient();
100+
.endpoint(projectEndpoint);
101101

102-
// Derive the administration client
103-
logger.info("Getting PersistentAgentsAdministrationClient");
104-
PersistentAgentsAdministrationClient adminClient =
105-
agentsClient.getPersistentAgentsAdministrationClient();
102+
AgentsClient agentsClient = builder.buildAgentsClient();
103+
ResponsesClient responsesClient = builder.buildResponsesClient();
104+
OpenAIClient openAIClient = builder.buildOpenAIClient();
106105

107106
// Create an agent
108107
logger.info("Creating agent with name: {}, model: {}", agentName, modelName);
109-
PersistentAgent agent = adminClient.createAgent(
110-
new CreateAgentOptions(modelName)
111-
.setName(agentName)
112-
.setInstructions(instructions)
108+
PromptAgentDefinition agentDefinition = new PromptAgentDefinition(modelName)
109+
.setInstructions(instructions);
110+
111+
AgentVersionDetails agent = agentsClient.createAgentVersion(
112+
agentName,
113+
new com.azure.ai.agents.models.CreateAgentVersionOptions(agentDefinition)
113114
);
114-
logger.info("Agent created: ID={}, Name={}", agent.getId(), agent.getName());
115+
logger.info("Agent created: Name={}, Version={}", agent.getName(), agent.getVersion());
115116
logger.info("Agent model: {}", agent.getModel());
116117

117-
// Start a thread/run on the general client
118-
logger.info("Creating thread and run with agent ID: {}", agent.getId());
119-
ThreadRun runResult = agentsClient.createThreadAndRun(
120-
new CreateThreadAndRunOptions(agent.getId())
121-
);
122-
logger.info("ThreadRun created: ThreadId={}", runResult.getThreadId());
118+
// Create a conversation
119+
logger.info("Creating conversation with agent");
120+
Conversation conversation = openAIClient.conversations().create();
121+
logger.info("Conversation created: ID={}", conversation.id());
123122

124-
// List available getters on ThreadRun for informational purposes
125-
logger.info("\nAvailable getters on ThreadRun:");
126-
for (var method : ThreadRun.class.getMethods()) {
127-
if (method.getName().startsWith("get")) {
128-
logger.info(" - {}", method.getName());
129-
}
130-
}
123+
// Get a response from the agent
124+
logger.info("Getting response from agent");
125+
Response response = responsesClient.createResponse(
126+
agentName,
127+
conversation.id(),
128+
"What are the key features of a helpful assistant?"
129+
);
130+
logger.info("Response received: {}", response.getOutputText());
131131

132132
logger.info("\nDemo completed successfully!");
133133

samples-classic/java/quickstart/src/main/java/com/azure/ai/foundry/samples/ChatCompletionSample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* - CHAT_PROMPT: Optional. The prompt to send (uses a default if not provided).
2222
*
2323
* SDK Features Demonstrated:
24-
* - Using the Azure AI Inference SDK (com.azure:azure-ai-inference:1.0.0-beta.5)
24+
* - Using the Azure AI Inference SDK (com.azure:azure-ai-inference:1.0.0)
2525
* - Creating a ChatCompletionsClient with Azure or API key authentication
2626
* - Configuring endpoint paths for different model deployments
2727
* - Using the simplified complete() method for quick completions

samples-classic/java/quickstart/src/main/java/com/azure/ai/foundry/samples/FileSearchAgentSample.java

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,26 @@
44
import java.nio.file.Files;
55
import java.nio.file.Path;
66

7-
import com.azure.ai.agents.persistent.PersistentAgentsClient;
8-
import com.azure.ai.agents.persistent.PersistentAgentsClientBuilder;
9-
import com.azure.ai.agents.persistent.PersistentAgentsAdministrationClient;
10-
import com.azure.ai.agents.persistent.models.CreateAgentOptions;
11-
import com.azure.ai.agents.persistent.models.CreateThreadAndRunOptions;
12-
import com.azure.ai.agents.persistent.models.PersistentAgent;
13-
import com.azure.ai.agents.persistent.models.ThreadRun;
7+
import com.azure.ai.agents.AgentsClient;
8+
import com.azure.ai.agents.AgentsClientBuilder;
9+
import com.azure.ai.agents.ResponsesClient;
10+
import com.azure.ai.agents.models.PromptAgentDefinition;
11+
import com.azure.ai.agents.models.AgentVersionDetails;
1412
import com.azure.core.exception.HttpResponseException;
1513
import com.azure.core.util.logging.ClientLogger;
1614
import com.azure.identity.DefaultAzureCredentialBuilder;
15+
import com.openai.client.OpenAIClient;
16+
import com.openai.models.conversations.Conversation;
17+
import com.openai.models.responses.Response;
1718

1819
/**
19-
* Sample demonstrating agent creation with document capabilities using Azure AI Agents Persistent SDK.
20+
* Sample demonstrating agent creation with document capabilities using Azure AI Agents SDK v2.
2021
*
2122
* This sample shows how to:
2223
* - Set up authentication with Azure credentials
2324
* - Create a temporary document file for demonstration purposes
24-
* - Create a persistent agent with custom instructions for document search
25-
* - Start a thread and run with the agent that can access document content
25+
* - Create an agent with custom instructions for document search
26+
* - Start a conversation with the agent that can access document content
2627
* - Work with file-based knowledge sources for agent interactions
2728
*
2829
* Environment variables:
@@ -37,14 +38,12 @@
3738
* for more advanced document processing capabilities.
3839
*
3940
* SDK Features Demonstrated:
40-
* - Using the Azure AI Agents Persistent SDK (com.azure:azure-ai-agents-persistent:1.0.0-beta.2)
41+
* - Using the Azure AI Agents SDK (com.azure:azure-ai-agents:2.0.0)
4142
* - Creating an authenticated client with DefaultAzureCredential
42-
* - Using the PersistentAgentsClientBuilder for client instantiation
43-
* - Working with the PersistentAgentsAdministrationClient for agent management
44-
* - Creating temporary document files for agent access
45-
* - Adding document knowledge sources to agents
43+
* - Using the AgentsClientBuilder for client instantiation
44+
* - Creating agents with file search capabilities
4645
* - Creating document-aware agents that can search and reference content
47-
* - Starting threads and runs for document-based Q&A
46+
* - Creating conversations and getting responses from agents
4847
* - Error handling for Azure service and file operations
4948
*/
5049
public class FileSearchAgentSample {
@@ -88,17 +87,15 @@ public static void main(String[] args) {
8887
logger.info("Using endpoint: {}", finalEndpoint);
8988

9089
try {
91-
// Build the general agents client with proper error handling
92-
logger.info("Creating PersistentAgentsClient with endpoint: {}", finalEndpoint);
93-
PersistentAgentsClient agentsClient = new PersistentAgentsClientBuilder()
90+
// Build the agents client with proper error handling
91+
logger.info("Creating AgentsClient with endpoint: {}", finalEndpoint);
92+
AgentsClientBuilder builder = new AgentsClientBuilder()
9493
.endpoint(finalEndpoint)
95-
.credential(credential)
96-
.buildClient();
97-
98-
// Derive the administration client
99-
logger.info("Getting PersistentAgentsAdministrationClient");
100-
PersistentAgentsAdministrationClient adminClient =
101-
agentsClient.getPersistentAgentsAdministrationClient();
94+
.credential(credential);
95+
96+
AgentsClient agentsClient = builder.buildAgentsClient();
97+
ResponsesClient responsesClient = builder.buildResponsesClient();
98+
OpenAIClient openAIClient = builder.buildOpenAIClient();
10299

103100
// Create sample document for demonstration
104101
Path tmpFile = createSampleDocument();
@@ -108,20 +105,29 @@ public static void main(String[] args) {
108105

109106
// Create the agent with proper configuration
110107
logger.info("Creating agent with name: {}, model: {}", agentName, modelName);
111-
PersistentAgent agent = adminClient.createAgent(
112-
new CreateAgentOptions(modelName)
113-
.setName(agentName)
114-
.setInstructions(instructions)
108+
PromptAgentDefinition agentDefinition = new PromptAgentDefinition(modelName)
109+
.setInstructions(instructions);
110+
111+
AgentVersionDetails agent = agentsClient.createAgentVersion(
112+
agentName,
113+
new com.azure.ai.agents.models.CreateAgentVersionOptions(agentDefinition)
115114
);
116115
logger.info("Agent ID: {}", agent.getId());
117116
logger.info("Agent model: {}", agent.getModel());
118117

119-
// Start a thread and run on the general client
120-
logger.info("Creating thread and run with agent ID: {}", agent.getId());
121-
ThreadRun threadRun = agentsClient.createThreadAndRun(
122-
new CreateThreadAndRunOptions(agent.getId())
118+
// Create a conversation and get a response
119+
logger.info("Creating conversation with agent");
120+
Conversation conversation = openAIClient.conversations().create();
121+
logger.info("Conversation ID: {}", conversation.id());
122+
123+
// Get response from agent
124+
logger.info("Getting response from agent about the document");
125+
Response response = responsesClient.createResponse(
126+
agentName,
127+
conversation.id(),
128+
"What topics are covered in the document?"
123129
);
124-
logger.info("ThreadRun ID: {}", threadRun.getThreadId());
130+
logger.info("Response: {}", response.getOutputText());
125131

126132
// Display success message
127133
logger.info("\nDemo completed successfully!");

samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/Evaluate/Evaluate.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Azure.AI.Projects" Version="1.2.0-alpha.20260128.1" />
12-
<PackageReference Include="Azure.AI.Projects.OpenAI" Version="1.0.0-alpha.20260128.1" />
13-
<PackageReference Include="Azure.Identity" Version="1.17.1" />
11+
<PackageReference Include="Azure.AI.Projects" Version="2.0.0" />
12+
<PackageReference Include="Azure.AI.Projects.OpenAI" Version="1.0.0" />
13+
<PackageReference Include="Azure.Identity" Version="1.20.0" />
1414
<PackageReference Include="DotNetEnv" Version="3.1.1" />
1515
</ItemGroup>
1616

1717
<ItemGroup>
18-
<PackageReference Include="OpenAI" Version="2.*-*" />
18+
<PackageReference Include="OpenAI" Version="2.2.1" />
1919
</ItemGroup>
2020

2121
</Project>

samples/csharp/enterprise-agent-tutorial/1-idea-to-prototype/ModernWorkplaceAssistant/ModernWorkplaceAssistant.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Azure.AI.Projects" Version="1.2.0-beta.5" />
13-
<PackageReference Include="Azure.AI.Projects.OpenAI" Version="1.0.0-beta.5" />
14-
<PackageReference Include="Azure.Identity" Version="1.17.1" />
12+
<PackageReference Include="Azure.AI.Projects" Version="2.0.0" />
13+
<PackageReference Include="Azure.AI.Projects.OpenAI" Version="1.0.0" />
14+
<PackageReference Include="Azure.Identity" Version="1.20.0" />
1515
<PackageReference Include="DotNetEnv" Version="3.1.1" />
1616
</ItemGroup>
1717

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
azure-ai-projects==2.0.0b3
1+
azure-ai-projects==2.3.0
22
python-dotenv

0 commit comments

Comments
 (0)