.NET: Add Missing CreateSessionAsync(conversationId) to FoundryAgent#5144
Merged
rogerbarreto merged 1 commit intomicrosoft:mainfrom Apr 7, 2026
Conversation
Adds a public CreateSessionAsync(string conversationId, CancellationToken) method to FoundryAgent that delegates to the inner ChatClientAgent, allowing users to create sessions with existing server-side conversation IDs. Fixes microsoft#5138
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a FoundryAgent.CreateSessionAsync(string conversationId, CancellationToken) convenience overload so callers can resume/attach to an existing server-side Foundry conversation without needing to downcast or access the inner ChatClientAgent.
Changes:
- Add
FoundryAgent.CreateSessionAsync(string conversationId, CancellationToken)that delegates to the innerChatClientAgent. - Add unit tests asserting the returned session type and that
ConversationIdis set (or null for the parameterless overload).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.Foundry/FoundryAgent.cs | Adds CreateSessionAsync(conversationId) overload delegating to the inner ChatClientAgent. |
| dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/FoundryAgentTests.cs | Adds unit tests for creating sessions with/without a conversation ID. |
SergeyMenshykh
approved these changes
Apr 7, 2026
westey-m
approved these changes
Apr 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Users who already have a server-side conversation ID (e.g., created via \ProjectConversationsClient) cannot pass it to \FoundryAgent.CreateSessionAsync\ because the overload accepting a \conversationId\ parameter only exists on \ChatClientAgent.
Description
Adds a public \CreateSessionAsync(string conversationId, CancellationToken)\ method to \FoundryAgent\ that delegates to the inner \ChatClientAgent, allowing users to create sessions with existing server-side conversation IDs directly from the \FoundryAgent\ type.
Usage
\\csharp
// Create or obtain an existing conversation ID
ProjectConversation conversation = await conversationsClient.CreateProjectConversationAsync();
// Now directly usable on FoundryAgent
AgentSession session = await foundryAgent.CreateSessionAsync(conversation.Id);
\\
Changes
Checklist
et48\ and
et10.0\