-
Notifications
You must be signed in to change notification settings - Fork 1.1k
.NET: Pass AdditionalProperties from parent to child when exposing an agent as a FunctionTool #3219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET: Pass AdditionalProperties from parent to child when exposing an agent as a FunctionTool #3219
Conversation
… as a FunctionTool
There was a problem hiding this 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.AsAIFunctionto 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 |
dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentExtensionsTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
I tried this @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. |
|
@westey-m Still on track for merging this today ? |
Motivation and Context
#3127
Description
Contribution Checklist