fix(oci): preserve all parallel tool results in OCI GenAI messages - #6594
Draft
bigfish-emily wants to merge 1 commit into
Draft
fix(oci): preserve all parallel tool results in OCI GenAI messages#6594bigfish-emily wants to merge 1 commit into
bigfish-emily wants to merge 1 commit into
Conversation
Closes google#6589. _content_to_oci_message only forwarded tool_results[0] to OCI GenAI, silently dropping every other parallel tool result. Return one ToolMessage per function_response part (mirroring _content_to_message_param in lite_llm.py) and flatten the messages in _build_chat_details. Adds regression tests for the multi-result path.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Link to Issue or Description of Change
Closes: #6589
Problem:
When an agent backed by
OCIGenAILlmissues two or more parallel tool calls ina single turn, only the first tool result is forwarded to the OCI model API on
the next request; all other results are silently dropped. Root cause:
_content_to_oci_message()collects everyfunction_responsepart intotool_resultsbut builds only a singleToolMessagefromtool_results[0], and_build_chat_details()maps eachContentto exactlyone message without flattening.
Solution:
Mirror the LiteLLM path (
_content_to_message_paraminmodels/lite_llm.py): when aContentcarries multiplefunction_responseparts, return one
ToolMessageper result, and flatten the returned messagesin
_build_chat_details()so parallel tool results are all preserved.Testing Plan
Unit Tests:
test_content_to_oci_message_multiple_function_responses: twofunction_responseparts yield twoToolMessages with the correct toolcall ids.
test_build_chat_details_flattens_multiple_tool_messages: a singleContentwith two parallel tool results produces two flattened messagesin the outgoing chat request.
real module in this sandbox; the full suite runs in CI).