Skip to content

.NET: Pass AdditionalProperties from parent to child when exposing an agent as a FunctionTool - #3219

Merged
westey (westey-m) merged 5 commits into
microsoft:mainfrom
westey-m:asaifunction-additionalproperties
Jan 20, 2026
Merged

.NET: Pass AdditionalProperties from parent to child when exposing an agent as a FunctionTool#3219
westey (westey-m) merged 5 commits into
microsoft:mainfrom
westey-m:asaifunction-additionalproperties

Conversation

@westey-m

Copy link
Copy Markdown
Contributor

Motivation and Context

#3127

Description

  • Pass AdditionalProperties from parent to child when exposing an agent as a FunctionTool

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 January 14, 2026 17:19
@markwallace-microsoftMark Wallace (markwallace-microsoft) added the .NET Usage: [Issues, PRs], Target: .Net label Jan 14, 2026
@github-actionsgithub-actionsBot changed the title Pass AdditionalProperties from parent to child when exposing an agent as a FunctionTool.NET: Pass AdditionalProperties from parent to child when exposing an agent as a FunctionToolJan 14, 2026

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 enables the propagation of AdditionalProperties from a parent agent to a child agent when the child is exposed as a FunctionTool. This allows custom properties set on the parent agent's run context to flow through to nested agent invocations.

Changes:

  • Modified AgentExtensions.AsAIFunction to extract AdditionalProperties from the parent agent's FunctionInvokingChatClient context and pass them to the child agent via AgentRunOptions
  • Added a comprehensive unit test to verify that AdditionalProperties are correctly passed from parent to child agent
  • Added a helper method in the test class to use reflection for setting the FunctionInvokingChatClient's CurrentContext for testing purposes

Reviewed changes

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

FileDescription
dotnet/src/Microsoft.Agents.AI/AgentExtensions.csModified InvokeAgentAsync to propagate AdditionalProperties from FunctionInvokingChatClient.CurrentContext to child agent options
dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentExtensionsTests.csAdded test for AdditionalProperties propagation and helper method for setting CurrentContext via reflection; enhanced TestAgent to track received AgentRunOptions

Comment threaddotnet/src/Microsoft.Agents.AI/AgentExtensions.cs Outdated
Comment threaddotnet/tests/Microsoft.Agents.AI.UnitTests/AgentExtensionsTests.cs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment threaddotnet/src/Microsoft.Agents.AI/AgentExtensions.cs
@moetarhinikaseya

Copy link
Copy Markdown

I tried this westey (@westey-m) and the E2E Scenario is working perfectly. Please try to merge it ASAP :)

@westey-m

Copy link
Copy Markdown
ContributorAuthor

I tried this westey (@westey-m) and the E2E Scenario is working perfectly. Please try to merge it ASAP :)

Thanks for verifying moetarhinikaseya. I'm waiting to get some further input from key individuals, which should happen tomorrow.

@moetarhinikaseya

Copy link
Copy Markdown

westey (@westey-m) Still on track for merging this today ?

@westey-m
westey (westey-m) added this pull request to the merge queueJan 20, 2026
Merged via the queue into microsoft:main with commit 73761aaJan 20, 2026
14 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NETUsage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

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