Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

FunctionInvokingChatClient: default rejection message causes models to re-request approval for an already-rejected tool call

Open Beginner friendly
#7,783 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp

Research direction

Locate FunctionInvokingChatClient.GenerateRejectedFunctionResults and inspect how it builds the result when an approval is rejected without a Reason. Update the default wording to identify the approver and state that the decision must not be retried, then add or update regression coverage for the no-reason path and verify that one rejection does not prompt another approval round.

Written by the indexing model from the issue text.

Description

area-ai untriaged
Description

FunctionInvokingChatClient.GenerateRejectedFunctionResults returns "Tool call invocation rejected." to the model when an approval is rejected without a Reason. That sentence says neither who rejected the call nor that the decision is final, so models read it as a transient or technical failure and request approval for the same tool call again.

The end user is then re-prompted to approve a tool they have already denied. Nothing on the library side bounds this: MaximumIterationsPerRequest limits iterations within one GetResponseAsync call, but each approval round-trip is a separate call, so the retries are bounded only by whatever the host application happens to do.

Reproduction Steps

Wrap a function in ApprovalRequiredAIFunction, reject the approval with CreateResponse(false) and no reason, and count how many times the model asks again.

using var client = new FunctionInvokingChatClient(inner);
var tool = new ApprovalRequiredAIFunction(AIFunctionFactory.Create(
    (string city) => $"22C and sunny in {city}", "get_weather", "Gets the current weather for a city."));
var options = new ChatOptions { Tools = [tool] };
List<ChatMessage> messages = [new(ChatRole.User, "What is the weather in Paris? Use the get_weather tool.")];

int rounds = 0;
for (int i = 0; i < 5; i++)
{
    var response = await client.GetResponseAsync(messages, options);
    messages.AddRange(response.Messages);
    var requests = response.Messages.SelectMany(m => m.Contents).OfType<ToolApprovalRequestContent>().ToList();
    if (requests.Count == 0) break;
    rounds++;
    messages.Add(new ChatMessage(ChatRole.User, requests.Select(r => (AIContent)r.CreateResponse(false)).ToList()));
}
Expected behavior

One approval round. Once rejected, the call is settled and the model should answer without asking again, whether or not an optional Reason was supplied.

Actual behavior

Approval rounds, three runs per model, rejection with no reason, against Azure OpenAI:

model rounds
gpt-4o 1, 1, 1
gpt-5.5 1, 1, 2
gpt-5-mini 2, 3, 2
gpt-5.6-terra 5, 2, 5 (5 = my loop cap; it had not stopped)

Supplying a Reason gives exactly 1 round on every model. The rejected function is never executed in any run, so this costs round-trips and repeated user prompts rather than incorrect execution.

Regression?

Yes, in effect. Before #7140 the message was "Error: Tool call invocation was rejected by user.", which stated who rejected the call. #7139 asked only for the ability to supply a custom rejection message; #7140 added the Reason property and, as a side effect, shortened the default to "Tool call invocation rejected.", dropping the attribution. Newer models are noticeably more likely to retry on the shortened form.

Known Workarounds

Always pass a reason: CreateResponse(false, "..."). That reliably gives one round. But Reason is documented as "An optional reason", so correctness of the human-in-the-loop flow should not depend on supplying it.

Configuration
  • Microsoft.Extensions.AI at main (890988e), .NET 10, Windows x64
  • Azure OpenAI deployments of gpt-4o, gpt-5.5, gpt-5-mini and gpt-5.6-terra
Other information

Restoring the missing information fixes it. With the default changed to "Tool call invocation was rejected by the approver and must not be retried." all four models return exactly 1 round in 3/3 runs, including gpt-4o, which was already correct and does not regress.

Two details worth noting from testing:

  • "approver" rather than "user", because ToolApprovalRequestContent documents the approval as possibly coming from "a user prompt, a policy decision, or any other approver", so attributing it to a user would be wrong for policy-driven rejections.
  • The finality clause is load-bearing. With attribution alone ("...was rejected by the approver.") gpt-5-mini still retried in 1 of 3 runs.

This is a deliberate change to an observable string, so it is a behavioral change even though no public API moves. I am happy to adjust the wording to whatever you prefer, or to leave it with you if you would rather own the phrasing. I will open a PR with the change and the updated tests shortly.

Dominant language
C#
Stars
3.2k
Forks
895
Avg merge
2d 12h
Merged PRs (30d)
24

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/extensions

All issues in dotnet/extensions

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.