Document strategies for handling invalid AI function call input#50896
Merged
BillWagner merged 8 commits intomainfrom Feb 26, 2026
Merged
Document strategies for handling invalid AI function call input#50896BillWagner merged 8 commits intomainfrom
BillWagner merged 8 commits intomainfrom
Conversation
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Document strategies to handle invalid tool input
Document strategies for handling invalid AI function call input
Jan 5, 2026
gewarren
approved these changes
Jan 7, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive documentation on handling invalid tool input from AI models when using Microsoft.Extensions.AI. It addresses common scenarios where AI models provide malformed function call arguments and presents three mitigation strategies.
- Documents three strategies:
IncludeDetailedErrorsproperty, customFunctionInvokerdelegates, and OpenAI's strict schema mode - Includes security guidance for production environments about exposing error details
- Provides four compilable code examples demonstrating each strategy
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/ai/how-to/handle-invalid-tool-input.md | New documentation article covering error handling strategies with security considerations |
| docs/ai/how-to/snippets/handle-invalid-tool-input/csharp/IncludeDetailedErrors.cs | Code example demonstrating the IncludeDetailedErrors property for AI self-correction |
| docs/ai/how-to/snippets/handle-invalid-tool-input/csharp/FunctionInvoker.cs | Code example showing custom error handling with FunctionInvoker delegate |
| docs/ai/how-to/snippets/handle-invalid-tool-input/csharp/StrictSchema.cs | Code example demonstrating OpenAI strict JSON schema mode |
| docs/ai/how-to/snippets/handle-invalid-tool-input/csharp/HandleInvalidToolInput.csproj | Project file with .NET 10 target and required package references |
| docs/ai/toc.yml | Adds navigation entry under "Call functions" section |
| docs/ai/quickstarts/use-function-calling.md | Links to new article from "Next steps" section |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
AI models can provide malformed function call arguments (wrong types, missing fields, invalid JSON). This documents three mitigation strategies using Microsoft.Extensions.AI.
Changes
New article:
docs/ai/how-to/handle-invalid-tool-input.mdIncludeDetailedErrorsproperty - sends full exception details to enable model self-correctionFunctionInvokerdelegate - catch exceptions, return descriptive errors to guide retry attemptsStrictadditional propertyCode examples (4 compilable snippets demonstrating each strategy)
Navigation: Added to TOC under "Call functions", linked from function calling quickstart
Example: Custom Error Handling
Addresses dotnet/extensions#7110 discussion points.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Internal previews