.NET: add workflow agent tool call message filtering#6882
Open
Oxygen56 wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in switch to the .NET workflow-hosted agent surface to filter tool-call transcript content (function call/result contents) from surfaced messages, with unit coverage to validate default vs filtered behavior.
Changes:
- Introduces
filterToolCallMessagesoption onWorkflow.AsAIAgent(...)and threads it throughWorkflowHostAgent→WorkflowSession. - Implements filtering in
WorkflowSessionsoFunctionCallContent/FunctionResultContentare removed from streamed updates and message-derived updates. - Adds smoke tests covering default behavior (preserves tool call contents) and filtered behavior (removes tool call contents while preserving text).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs | Adds test workflows and assertions validating tool-call content preservation vs filtering in both streaming and non-streaming runs. |
| dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowSession.cs | Implements the core filtering logic and applies it when yielding AgentResponseUpdates from workflow events. |
| dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowHostingExtensions.cs | Adds a new AsAIAgent overload exposing the filterToolCallMessages toggle. |
| dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowHostAgent.cs | Propagates filterToolCallMessages into created/deserialized WorkflowSessions. |
| dotnet/src/Microsoft.Agents.AI.Workflows/Futures.cs | Updates XML doc cref to a specific AsAIAgent overload signature. |
| /// </para> | ||
| /// <para> | ||
| /// <b>Interaction with <see cref="WorkflowHostingExtensions.AsAIAgent"/>.</b> When this flag | ||
| /// <b>Interaction with <see cref="WorkflowHostingExtensions.AsAIAgent(Workflow, string?, string?, string?, IWorkflowExecutionEnvironment?, bool, bool)"/>.</b> When this flag |
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 & Context
Fixes #6874.
When a workflow is hosted as an
AIAgent, internal tool-call messages from nested agent execution can be surfaced in the hosted agent response. If that response is passed to another agent, the downstream provider can receiveFunctionCallContent/FunctionResultContentfor tool calls it did not issue and reject the request.Description & Review Guide
AsAIAgent(filterToolCallMessages: true, ...)overload.WorkflowHostAgent/WorkflowSession.FunctionCallContentandFunctionResultContentfrom streamed agent response updates, aggregated agent response messages, and workflow output chat messages before they are surfaced by the hosted workflow agent.AgentResponseUpdateEventpath.Related Issue
Fixes #6874
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.