You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: Foundry reasoning replay data attaches to the wrong message for multi-message responses #9930
The Foundry chat client's reasoning replay attachment assumes a single-message response, which #9768 broke open: responses can now produce multiple assistant messages (one per provider output message, e.g. preamble + follow-up), and a trailing reasoning item is parsed into the last message.
_parse_response_from_openai in python/packages/foundry/agent_framework_foundry/_chat_client.py only calls _attach_foundry_reasoning_replay_item(chat_response.messages[0].contents, item):
if the reasoning content actually lives in a later message, the id lookup in messages[0] misses and the miss branch appends a duplicate empty text_reasoning content to the first message
the real reasoning content in the later message keeps no replay payload
stateless replay then groups two contents under the same provider reasoning id, and the visible transcript gains a spurious empty reasoning item attached to the wrong message
Verified on main: the replay-grouped contents for rs_1 contain the duplicate first, and the owning content has no __foundry_reasoning_replay_item__ metadata. The streaming path attaches per update and is not affected.
Expected
The attachment should search all messages for the reasoning content that owns the id (most recent first) and only fall back to appending on the last message — where trailing reasoning items are parsed in the first place.
changed the title [-]Foundry reasoning replay data attaches to the wrong message for multi-message responses[/-][+]Python: Foundry reasoning replay data attaches to the wrong message for multi-message responses[/+]on Nov 1, 2026
I went through the issue, and the reasoning replay mismatch across multiple assistant messages looks like an important problem to address.
I'd be happy to work on updating the attachment logic so it finds the matching reasoning content across messages instead of assuming it belongs to the first one. I can also add regression tests for multi-message responses, the fallback behavior, and stateless replay.
Is anyone already working on this? If not, would you be open to me preparing a PR?
Activity
[-]Foundry reasoning replay data attaches to the wrong message for multi-message responses[/-][+]Python: Foundry reasoning replay data attaches to the wrong message for multi-message responses[/+]nikhilred2619 commentedon Nov 1, 2026
Hi Wilson_Jiang (@Wilson0511), thanks for reporting this.
I went through the issue, and the reasoning replay mismatch across multiple assistant messages looks like an important problem to address.
I'd be happy to work on updating the attachment logic so it finds the matching reasoning content across messages instead of assuming it belongs to the first one. I can also add regression tests for multi-message responses, the fallback behavior, and stateless replay.
Is anyone already working on this? If not, would you be open to me preparing a PR?
Thanks!