Skip to content

Remove backward-compat InformationalOnly case from FICC; suggest middleware workaround#7538

Open
jozkee wants to merge 2 commits into
dotnet:mainfrom
jozkee:agents/i-m-having-second-thoughts-on-https-github-27472a3e
Open

Remove backward-compat InformationalOnly case from FICC; suggest middleware workaround#7538
jozkee wants to merge 2 commits into
dotnet:mainfrom
jozkee:agents/i-m-having-second-thoughts-on-https-github-27472a3e

Conversation

@jozkee
Copy link
Copy Markdown
Member

@jozkee jozkee commented May 27, 2026

Summary

Removes the backward-compat special case in ExtractAndRemoveApprovalRequestsAndResponses (added in #7468) that handled ToolApprovalResponseContent with InformationalOnly: true for sessions serialized before the fix.

Instead, a middleware workaround (ApprovalHistoryNormalizingChatClient) is provided in the test project as a sample that normalizes InformationalOnly flags on TARC/TAResp pairs before FICC processes them. This keeps FICC simpler and pushes the legacy compat concern to the consumer.

Changes

  • FunctionInvokingChatClient.cs: Removed the ToolApprovalResponseContent with InformationalOnly: true case from the switch in ExtractAndRemoveApprovalRequestsAndResponses.
  • ApprovalHistoryNormalizingChatClient.cs (new, test-only): Middleware that uses LINQ to find TAResp call IDs where InformationalOnly is already true, then sets the matching TARC FCCs to true as well.
  • FunctionInvokingChatClientApprovalsTests.cs: Updated test to use the middleware workaround, proving the approach works across all TFMs (streaming and non-streaming).

Ref: #7468 (comment)

cc @westey-m

Copilot AI review requested due to automatic review settings May 27, 2026 21:22
@jozkee jozkee requested a review from a team as a code owner May 27, 2026 21:22
@github-actions github-actions Bot added the area-ai Microsoft.Extensions.AI libraries label May 27, 2026
Copy link
Copy Markdown
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 removes legacy backward-compat handling from FunctionInvokingChatClient for mixed InformationalOnly approval history and demonstrates a test-only middleware workaround for normalizing old serialized sessions before FICC processes them.

Changes:

  • Removed the special ToolApprovalResponseContent / InformationalOnly: true validation case from FICC.
  • Added ApprovalHistoryNormalizingChatClient test middleware to normalize matching approval request flags.
  • Updated the mixed InformationalOnly approval test to use the middleware workaround.

Reviewed changes

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

File Description
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs Removes the legacy validation bypass for processed approval responses.
test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/ApprovalHistoryNormalizingChatClient.cs Adds test-only middleware that marks matching approval requests as informational.
test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientApprovalsTests.cs Updates the legacy mixed-state test to exercise the middleware workaround.

…leware workaround

Remove the special case in ExtractAndRemoveApprovalRequestsAndResponses that
handled ToolApprovalResponseContent with InformationalOnly=true for sessions
serialized before PR dotnet#7468. Instead, provide a middleware workaround
(ApprovalHistoryNormalizingChatClient) that normalizes the InformationalOnly
flags on TARC/TAResp pairs before FICC processes them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jozkee jozkee force-pushed the agents/i-m-having-second-thoughts-on-https-github-27472a3e branch from 40436b6 to 283dde9 Compare May 28, 2026 14:30
@jozkee jozkee closed this May 28, 2026
@jozkee jozkee deleted the agents/i-m-having-second-thoughts-on-https-github-27472a3e branch May 28, 2026 14:35
@jozkee jozkee restored the agents/i-m-having-second-thoughts-on-https-github-27472a3e branch May 28, 2026 14:37
@jozkee jozkee reopened this May 28, 2026
@jozkee jozkee requested a review from jeffhandley May 28, 2026 16:20
@dotnet-comment-bot
Copy link
Copy Markdown
Collaborator

‼️ Found issues ‼️

Project Coverage Type Expected Actual
Microsoft.Extensions.Diagnostics.Testing Line 99 98.65 🔻
Microsoft.Extensions.Telemetry Line 93 91.95 🔻
Microsoft.Extensions.AI Line 89 88.51 🔻
Microsoft.Extensions.AI Branch 89 88.53 🔻
Microsoft.Extensions.AI.OpenAI Line 75 62.62 🔻
Microsoft.Extensions.AI.OpenAI Branch 75 49.63 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Line 75 4.46 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Branch 75 0 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Line 99 96.03 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Branch 99 94.39 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Kubernetes Line 99 97.73 🔻
Microsoft.Extensions.ServiceDiscovery.Dns Line 75 68.32 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Line 75 42.11 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Branch 75 42.86 🔻
Microsoft.Extensions.ServiceDiscovery Line 75 67.81 🔻
Microsoft.Extensions.ServiceDiscovery Branch 75 71.43 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Line 75 73.85 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Branch 75 70 🔻
Microsoft.Extensions.VectorData.Abstractions Line 75 37.39 🔻
Microsoft.Extensions.VectorData.Abstractions Branch 75 22.73 🔻

🎉 Good job! The coverage increased 🎉
Update MinCodeCoverage in the project files.

Project Expected Actual
Microsoft.Gen.BuildMetadata 97 100
Microsoft.Gen.MetadataExtractor 57 73
Microsoft.Gen.MetricsReports 67 69
Microsoft.Extensions.AI.Abstractions 82 85
Microsoft.Extensions.AI.Evaluation.NLP 0 78
Microsoft.Extensions.Caching.Hybrid 82 85
Microsoft.Extensions.DataIngestion 75 89
Microsoft.Extensions.DataIngestion.Markdig 75 90
Microsoft.Extensions.Http.Resilience 97 100

Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1439185&view=codecoverage-tab

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.

3 participants