Add logging to FunctionInvokingChatClient for approval flow, error handling, and loop control#7228
Merged
stephentoub merged 10 commits intomainfrom Jan 26, 2026
Conversation
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add logging for missing areas in FunctionInvokingChatClient
Add logging to FunctionInvokingChatClient for approval flow, error handling, and loop control
Jan 24, 2026
Member
|
…ests - Suppressed SA1204 StyleCop diagnostic instead of reordering methods - Reverted FunctionInvokingChatClient to original method order - Added logging implementation without method reordering - Added 6 comprehensive tests for logging functionality - Tests cover: function not found, non-invocable function, termination, approval flow, rejection Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Contributor
Author
Done in commit 1d28363:
|
Member
|
@copilot fix the test failures |
- Added logging for early termination path in ShouldTerminateForFunctionCall method - Fixed LogsFunctionNotFound test to use correct error message format - Fixed LogsNonInvocableFunction test with proper expected output - Fixed LogsFunctionRequestedTermination test to use FunctionInvokingChatClient.CurrentContext - Simplified LogsProcessingApprovalResponse and LogsFunctionRejected tests to use direct client calls - Fixed LogsFunctionRequiresApproval test to include user message in expected output - All 85 FunctionInvokingChatClient tests now passing (79 existing + 6 new) Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Contributor
Author
stephentoub
reviewed
Jan 24, 2026
Member
stephentoub
left a comment
There was a problem hiding this comment.
@copilot please re-review the whole class... Any other conditions that would be valuable to log?
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs
Outdated
Show resolved
Hide resolved
This was referenced Feb 16, 2026
Merged
Open
Open
Merged
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.
Implementation: Add Logging to FunctionInvokingChatClient ✅
Changes Made
#pragma warning disable SA1204instead of reordering methods ✅LogsFunctionNotFound- Validates logging when unknown functions are requestedLogsNonInvocableFunction- Validates logging for declaration-only functionsLogsFunctionRequestedTermination- Validates logging when functions request terminationLogsFunctionRequiresApproval- Validates logging for approval-required functionsLogsProcessingApprovalResponse- Validates logging when processing approval responsesLogsFunctionRejected- Validates logging when functions are rejectedLogMaxConsecutiveErrorsExceededcovered by existingContinuesWithFailingCallsUntilMaximumConsecutiveErrorstestTest Results
Logging Coverage
Approval Flow (Debug): approval requests, response processing, rejections
Error Handling (Warning): max consecutive errors exceeded, function not found
Loop Control (Debug): non-invocable functions, termination requests, max iterations
Original prompt
This pull request was created from Copilot chat.
✨ 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