Skip to content

Conversation

@westey-m
Copy link
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.

Copilot AI review requested due to automatic review settings January 14, 2026 17:19
@github-actions github-actions bot 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 FunctionTool Jan 14, 2026
Copy link
Contributor

Copilot AI left a comment

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.

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

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants