-
Notifications
You must be signed in to change notification settings - Fork 840
Fix Assistants IChatClient handling of unrelated tool calls in history #6891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 fixes a bug in the OpenAI Assistants IChatClient implementation where it incorrectly assumed that any tool results in message history required a thread ID. The fix addresses scenarios where message history contains historical function calls/responses (like in agent scenarios) rather than active tool calls requiring a thread.
Key changes:
- Removes validation that incorrectly throws when tool results are present without a thread ID
- Updates logic to only process function results when the message role is Tool
- Improves comments to clarify the distinction between active and historical tool results
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIAssistantsChatClient.cs
Show resolved
Hide resolved
The implementation is assuming that any tool results in the incoming message history mean a thread ID is required, which would be necessary if those tool results were for an active run. But that's not the case if the history just contains historical function calls/responses, as is the case in agent scenarios where the message history from one agent is passed to another. The fix is to just stop throwing based on this incorrect assumption.
d52009a
to
0590e3b
Compare
The implementation is assuming that any tool results in the incoming message history mean a thread ID is required, which would be necessary if those tool results were for an active run. But that's not the case if the history just contains historical function calls/responses, as is the case in agent scenarios where the message history from one agent is passed to another. The fix is to just stop throwing based on this incorrect assumption.
Microsoft Reviewers: Open in CodeFlow