Skip to content

Conversation

stephentoub
Copy link
Member

@stephentoub stephentoub commented Oct 5, 2025

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

@stephentoub stephentoub requested a review from a team as a code owner October 5, 2025 15:07
@Copilot Copilot AI review requested due to automatic review settings October 5, 2025 15:07
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Oct 5, 2025
Copy link
Contributor

@Copilot 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 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

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.
@stephentoub stephentoub force-pushed the fixassistantshistory branch from d52009a to 0590e3b Compare October 5, 2025 15:13
This was referenced Oct 22, 2025
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.

2 participants