.NET: [BREAKING] Rename AgentThread to AgentSession (#3430)

* Rename AgentThread to AgentSession

* Add more renames

* Update readme files

* Revert nullable variable change and further fixes.

* Revert change in header name

* Fix some comments and tests

* Update changelog.

* Address PR feedback.

* Fixing code review comments.

* Fix new errors after merging latest code.
This commit is contained in:
westey
2026-01-26 16:30:25 +00:00
committed by GitHub
parent bbe096a764
commit a3a9147e61
223 changed files with 2529 additions and 2542 deletions
@@ -42,8 +42,8 @@ AIAgent agent = await persistentAgentsClient.CreateAIAgentAsync(
});
// You can then invoke the agent like any other AIAgent.
AgentThread thread = await agent.GetNewThreadAsync();
Console.WriteLine(await agent.RunAsync("Please summarize the Azure AI Agent documentation related to MCP Tool calling?", thread));
AgentSession session = await agent.GetNewSessionAsync();
Console.WriteLine(await agent.RunAsync("Please summarize the Azure AI Agent documentation related to MCP Tool calling?", session));
// Cleanup for sample purposes.
await persistentAgentsClient.Administration.DeleteAgentAsync(agent.Id);
@@ -75,8 +75,8 @@ AIAgent agentWithRequiredApproval = await persistentAgentsClient.CreateAIAgentAs
});
// You can then invoke the agent like any other AIAgent.
var threadWithRequiredApproval = await agentWithRequiredApproval.GetNewThreadAsync();
var response = await agentWithRequiredApproval.RunAsync("Please summarize the Azure AI Agent documentation related to MCP Tool calling?", threadWithRequiredApproval);
var sessionWithRequiredApproval = await agentWithRequiredApproval.GetNewSessionAsync();
var response = await agentWithRequiredApproval.RunAsync("Please summarize the Azure AI Agent documentation related to MCP Tool calling?", sessionWithRequiredApproval);
var userInputRequests = response.UserInputRequests.ToList();
while (userInputRequests.Count > 0)
@@ -98,7 +98,7 @@ while (userInputRequests.Count > 0)
.ToList();
// Pass the user input responses back to the agent for further processing.
response = await agentWithRequiredApproval.RunAsync(userInputResponses, threadWithRequiredApproval);
response = await agentWithRequiredApproval.RunAsync(userInputResponses, sessionWithRequiredApproval);
userInputRequests = response.UserInputRequests.ToList();
}
@@ -37,8 +37,8 @@ AIAgent agent = new AzureOpenAIClient(
tools: [mcpTool]);
// You can then invoke the agent like any other AIAgent.
AgentThread thread = await agent.GetNewThreadAsync();
Console.WriteLine(await agent.RunAsync("Please summarize the Azure AI Agent documentation related to MCP Tool calling?", thread));
AgentSession session = await agent.GetNewSessionAsync();
Console.WriteLine(await agent.RunAsync("Please summarize the Azure AI Agent documentation related to MCP Tool calling?", session));
// **** MCP Tool with Approval Required ****
// *****************************************
@@ -64,8 +64,8 @@ AIAgent agentWithRequiredApproval = new AzureOpenAIClient(
tools: [mcpToolWithApproval]);
// You can then invoke the agent like any other AIAgent.
var threadWithRequiredApproval = await agentWithRequiredApproval.GetNewThreadAsync();
var response = await agentWithRequiredApproval.RunAsync("Please summarize the Azure AI Agent documentation related to MCP Tool calling?", threadWithRequiredApproval);
var sessionWithRequiredApproval = await agentWithRequiredApproval.GetNewSessionAsync();
var response = await agentWithRequiredApproval.RunAsync("Please summarize the Azure AI Agent documentation related to MCP Tool calling?", sessionWithRequiredApproval);
var userInputRequests = response.UserInputRequests.ToList();
while (userInputRequests.Count > 0)
@@ -87,7 +87,7 @@ while (userInputRequests.Count > 0)
.ToList();
// Pass the user input responses back to the agent for further processing.
response = await agentWithRequiredApproval.RunAsync(userInputResponses, threadWithRequiredApproval);
response = await agentWithRequiredApproval.RunAsync(userInputResponses, sessionWithRequiredApproval);
userInputRequests = response.UserInputRequests.ToList();
}