Python: fix(core): conversation_id not updated in options during tool invocation loop#3664
Open
moonbox3 wants to merge 2 commits intomicrosoft:mainfrom
Open
Python: fix(core): conversation_id not updated in options during tool invocation loop#3664moonbox3 wants to merge 2 commits intomicrosoft:mainfrom
moonbox3 wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a tool-invocation loop bug where a newly returned conversation_id (from hosted/server-managed conversations such as OpenAI Responses) was applied to kwargs but not propagated into the options dict used for subsequent API calls, which could break multi-turn tool execution in checkpoint/resume workflows.
Changes:
- Update
options["conversation_id"]whenever a response returns a newconversation_id(non-streaming + streaming tool loops). - Add a regression test that verifies the updated
conversation_idis used on the next iteration for both non-streaming and streaming flows.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
python/packages/core/agent_framework/_tools.py |
Ensures conversation_id updates are applied to options between tool-loop iterations so subsequent API calls remain on the correct server-side response chain. |
python/packages/core/tests/core/test_function_invocation_logic.py |
Adds coverage proving the next API call receives the updated conversation_id after a tool-call response (streaming and non-streaming). |
Member
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
eavanvalkenburg
added a commit
to eavanvalkenburg/agent-framework
that referenced
this pull request
Feb 4, 2026
…ations Port test from PR microsoft#3664 with updates for new streaming API pattern. Tests that conversation_id is properly updated in options dict during function invocation loop iterations.
eavanvalkenburg
added a commit
to eavanvalkenburg/agent-framework
that referenced
this pull request
Feb 4, 2026
When tool_choice is 'required', the user's intent is to force exactly one tool call. After the tool executes, return immediately with the function call and result - don't continue to call the model again. This fixes integration tests that were failing with empty text responses because with tool_choice=required, the model would keep returning function calls instead of text. Also adds regression tests for: - conversation_id propagation between tool iterations (from PR microsoft#3664) - tool_choice=required returns after tool execution
eavanvalkenburg
added a commit
to eavanvalkenburg/agent-framework
that referenced
this pull request
Feb 4, 2026
…ations Port test from PR microsoft#3664 with updates for new streaming API pattern. Tests that conversation_id is properly updated in options dict during function invocation loop iterations.
eavanvalkenburg
added a commit
to eavanvalkenburg/agent-framework
that referenced
this pull request
Feb 4, 2026
When tool_choice is 'required', the user's intent is to force exactly one tool call. After the tool executes, return immediately with the function call and result - don't continue to call the model again. This fixes integration tests that were failing with empty text responses because with tool_choice=required, the model would keep returning function calls instead of text. Also adds regression tests for: - conversation_id propagation between tool iterations (from PR microsoft#3664) - tool_choice=required returns after tool execution
markwallace-microsoft
approved these changes
Feb 4, 2026
TaoChenOSU
approved these changes
Feb 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
When using the OpenAI Responses API with tool calls, the framework would fail with:
No tool call found for function call output with call_id <call_id>This occurred in checkpoint/resume scenarios with handoff workflows, but could affect any multi-turn tool invocation.
In
_tools.py, bothfunction_invocation_wrapperandstreaming_function_invocation_wrapperupdatekwargswith the new conversation_id after each API response, but the options dict (which is passed to subsequent API calls) was not being updated.The flow:
The fix:
Update options["conversation_id"] alongside kwargs when a new conversation_id is received:
Description
Contribution Checklist