Skip to content

fix(microsoft-extensions-ai): pass chat options to the IChatClient - #1503

Open
pcbeingused333 wants to merge 1 commit into
SciSharp:masterfrom
pcbeingused333:fix/msext-ai-chat-options
Open

pcbeingused333 wants to merge 1 commit into
SciSharp:masterfrom
pcbeingused333:fix/msext-ai-chat-options

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

No linked issue (sibling of the provider-state fixes in #1486/#1488: found by comparing what each chat provider does with the conversation state).

MicrosoftExtensionsAIChatCompletionProvider.GetChatCompletions builds a ChatOptions from the conversation state (temperature, max_tokens) and adds every rendered agent function to options.Tools, but then calls _client.GetResponseAsync(messages) without it. The options are silently discarded: the client always runs with its own defaults, and the model never receives the function definitions, so agents cannot call functions through this provider.

Fix: pass options to GetResponseAsync.

Test: MicrosoftExtensionsAIChatOptionsTests runs the provider against a capturing IChatClient and checks that temperature and max output tokens from the state, and a rendered function as a tool, reach the client. Both tests fail on main (the client receives null options) and pass with the change. Adds a project reference to the Microsoft.Extensions.AI plugin in BotSharp.Core.UnitTests.

This change was prepared with the assistance of an AI coding tool (Claude Code); the author is responsible for the submission.

GetChatCompletions built ChatOptions (temperature, max output tokens and
the rendered function tools) but called GetResponseAsync(messages)
without them, so the client always used its own defaults and the model
never received the tool definitions.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant