Skip to content

.NET: [BREAKING] Introduce Core implementation methods for session methods on AIAgent - #3699

Merged
westey (westey-m) merged 5 commits into
microsoft:mainfrom
westey-m:aiagent-core-session-methods
Feb 6, 2026
Merged

.NET: [BREAKING] Introduce Core implementation methods for session methods on AIAgent#3699
westey (westey-m) merged 5 commits into
microsoft:mainfrom
westey-m:aiagent-core-session-methods

Conversation

@westey-m

Copy link
Copy Markdown
Contributor

Motivation and Context

For all run methods on AIAgent we currently have public and protected abstract Core methods for doing the main implementation.
This allows us to do some common work in AIAgent that should apply to all agents.
Extending this pattern to the session methods as well.

Description

  • Add Core methods for CreateSession, SerializeSession and DeserializeSession

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

CopilotAI review requested due to automatic review settings February 5, 2026 14:50
@markwallace-microsoftMark Wallace (markwallace-microsoft) added .NET Usage: [Issues, PRs], Target: .Net workflows Usage: [Issues, PRs], Target: Workflows labels Feb 5, 2026
@github-actionsgithub-actionsBot changed the title Introduce Core implementation methods for session methods on AIAgent.NET: Introduce Core implementation methods for session methods on AIAgentFeb 5, 2026
@westey-mwestey (westey-m) mentioned this pull request Feb 5, 2026
61 tasks

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a consistent pattern for session management methods in the AIAgent base class by adding "Core" implementation methods. The changes extend an existing architectural pattern where public methods delegate to protected abstract Core methods, allowing AIAgent to perform common work before delegating to specific implementations.

Changes:

  • Added public wrapper methods (CreateSessionAsync, SerializeSession, DeserializeSessionAsync) and corresponding protected abstract Core methods in AIAgent base class
  • Updated all agent implementations to override the new protected Core methods instead of public abstract methods
  • Updated test mocks to properly mock the protected Core methods

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 4 comments.

Show a summary per file
FileDescription
dotnet/src/Microsoft.Agents.AI.Abstractions/AIAgent.csAdded public wrapper methods and protected abstract Core methods for session management
dotnet/src/Microsoft.Agents.AI.Abstractions/DelegatingAIAgent.csUpdated to override Core methods and delegate to inner agent
dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.csChanged session methods from public override to protected override Core methods
dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowHostAgent.csChanged session methods from public override to protected override Core methods
dotnet/src/Microsoft.Agents.AI.Purview/PurviewAgent.csChanged session methods from public override to protected override Core methods
dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.csChanged session methods from public override to protected override Core methods
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgentProxy.csChanged session methods from public override to protected override Core methods
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgent.csChanged session methods from public override to protected override Core methods
dotnet/src/Microsoft.Agents.AI.CopilotStudio/CopilotStudioAgent.csChanged session methods from public override to protected override Core methods
dotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.csChanged session methods from public override to protected override Core methods
dotnet/samples/GettingStarted/AgentProviders/Agent_With_CustomImplementation/Program.csUpdated sample code to override Core methods
dotnet/tests/* (multiple test files)Updated all test agent implementations to override Core methods and fixed mock setups

Comment threaddotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgent.cs
Comment threaddotnet/src/Microsoft.Agents.AI.Purview/PurviewAgent.cs
@markwallace-microsoftMark Wallace (markwallace-microsoft) added the documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs label Feb 5, 2026
@westey-m
westey (westey-m) added this pull request to the merge queueFeb 6, 2026
Merged via the queue into microsoft:main with commit ac17adbFeb 6, 2026
15 of 17 checks passed
@rwjdk

Copy link
Copy Markdown

westey (@westey-m) : This is actually a breaking change (but not marked as such in the release notes) for those of us who make our own inherited agents.

@westey-mwestey (westey-m) changed the title .NET: Introduce Core implementation methods for session methods on AIAgent.NET: [BREAKING] Introduce Core implementation methods for session methods on AIAgentFeb 10, 2026
@westey-m

Copy link
Copy Markdown
ContributorAuthor

westey (@westey-m) : This is actually a breaking change (but not marked as such in the release notes) for those of us who make our own inherited agents.

Thanks Rasmus Wulff Jensen (@rwjdk), you are absolutely right. I've updated the title to reflect this.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationUsage: [Issues, PRs], Target: documentation in the code base and learn docs.NETUsage: [Issues, PRs], Target: .NetworkflowsUsage: [Issues, PRs], Target: Workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@westey-m@rwjdk@rogerbarreto@SergeyMenshykh@markwallace-microsoft