-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Python: fix(core): conversation_id not updated in options during tool invocation loop #3664
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
base: main
Are you sure you want to change the base?
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
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). |
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
…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.
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
…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.
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
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