Skip to content

Auto-mark server-handled FunctionCallContent as InformationalOnly#7314

Merged
stephentoub merged 7 commits intomainfrom
copilot/fix-function-call-content-handling
Feb 20, 2026
Merged

Auto-mark server-handled FunctionCallContent as InformationalOnly#7314
stephentoub merged 7 commits intomainfrom
copilot/fix-function-call-content-handling

Conversation

Copy link
Contributor

Copilot AI commented Feb 16, 2026

  • Implement MarkServerHandledFunctionCalls helper that scans content for FCC/FRC pairs and marks matching FCCs as InformationalOnly = true
  • Non-streaming path: Call the helper after receiving the inner client response, before CopyFunctionCalls
  • Streaming path: Buffer updates once an FCC is encountered, then after the stream ends, check for FCC/FRC matches before yielding buffered updates
  • Add tests for non-streaming and streaming: server returns FCC+FRC pair, FCC gets marked InformationalOnly
  • Add test for mixed scenario: server-handled FCC+FRC alongside local tool calls
  • Add test for no-match scenario: FCC without FRC still gets invoked locally
  • Rename FunctionCallContentIsYieldedImmediatelyIfNoApprovalRequiredWhenStreamingAsync to FunctionCallContentIsBufferedUntilEndOfStreamWhenStreamingAsync with updated summary
  • Remove unused fcc/frc variables in ServerHandledFunctionCalls_MarkedAsInformationalOnly
  • Update streaming comment block to document both server-handled FCC/FRC detection and approval buffering
  • All 447 AI library tests pass
  • Code review and security checks

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Microsoft Reviewers: Open in CodeFlow

Copilot AI and others added 2 commits February 16, 2026 23:48
…ching FunctionResultContent exists

For non-streaming: scan response messages for FCC/FRC pairs by CallId before processing function calls.
For streaming: buffer updates once FCC is encountered, then check for FCC/FRC matches after stream ends.
Both paths mark matched FCCs as InformationalOnly so they won't be invoked locally.

Co-authored-by: stephentoub <[email protected]>
Copilot AI changed the title [WIP] Fix handling of FunctionCallContent and FunctionResultContent Auto-mark server-handled FunctionCallContent as InformationalOnly Feb 16, 2026
Copilot AI requested a review from stephentoub February 16, 2026 23:54
@stephentoub stephentoub requested a review from jozkee February 16, 2026 23:59
@github-actions github-actions bot added area-ai Microsoft.Extensions.AI libraries and removed needs-area-label labels Feb 16, 2026
@stephentoub
Copy link
Member

Related to #7307 (comment) and microsoft/agent-framework#3967

@stephentoub stephentoub marked this pull request as ready for review February 17, 2026 00:00
@stephentoub stephentoub requested a review from a team as a code owner February 17, 2026 00:00
Copilot AI review requested due to automatic review settings February 17, 2026 00:00
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

Updates FunctionInvokingChatClient to detect server-executed tool calls (FCC/FRC pairs) and avoid re-invoking those tools locally by auto-marking the matching FunctionCallContent as InformationalOnly, including for streaming scenarios.

Changes:

  • Non-streaming: scan ChatResponse.Messages for matching FunctionResultContent.CallId and mark corresponding FunctionCallContent as InformationalOnly before local invocation is considered.
  • Streaming: buffer updates after the first FCC, then after end-of-stream match FCC/FRC pairs across all updates, mark matched FCCs as InformationalOnly, and remove them from the pending invocation list.
  • Add/update tests covering server-handled calls (pure server-handled, mixed server/local, and no-matching-FRC cases) and adjust an existing streaming-yield expectation.

Reviewed changes

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

File Description
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs Adds FCC/FRC matching logic and adjusts streaming buffering to enable server-handled detection.
test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientTests.cs Adds new test coverage validating server-handled FCCs are marked InformationalOnly and skipped locally.
test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientApprovalsTests.cs Updates a streaming-yield assertion to reflect new buffering behavior once FCCs appear.

… comments

- Rename FunctionCallContentIsYieldedImmediatelyIfNoApprovalRequiredWhenStreamingAsync
  to FunctionCallContentIsBufferedUntilEndOfStreamWhenStreamingAsync with updated summary
- Remove unused fcc/frc local variables in ServerHandledFunctionCalls_MarkedAsInformationalOnly
- Update streaming comment block to explain both server-handled FCC/FRC detection
  and approval buffering reasons for buffering after first FCC

Co-authored-by: stephentoub <[email protected]>
Copy link
Member

@jozkee jozkee left a comment

Choose a reason for hiding this comment

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

Way cleaner than #7141.

@stephentoub stephentoub merged commit 7f155ad into main Feb 20, 2026
6 checks passed
@stephentoub stephentoub deleted the copilot/fix-function-call-content-handling branch February 20, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-ai Microsoft.Extensions.AI libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants