Skip to content

fix(oci): preserve all parallel tool results in OCI GenAI messages - #6594

Draft
bigfish-emily wants to merge 1 commit into
google:mainfrom
bigfish-emily:fix/oci-parallel-tool-results
Draft

fix(oci): preserve all parallel tool results in OCI GenAI messages#6594
bigfish-emily wants to merge 1 commit into
google:mainfrom
bigfish-emily:fix/oci-parallel-tool-results

Conversation

@bigfish-emily

Copy link
Copy Markdown

Link to Issue or Description of Change

Closes: #6589

Problem:

When an agent backed by OCIGenAILlm issues two or more parallel tool calls in
a 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 every function_response part into
tool_results but builds only a single ToolMessage from
tool_results[0], and _build_chat_details() maps each Content to exactly
one message without flattening.

Solution:

Mirror the LiteLLM path (_content_to_message_param in
models/lite_llm.py): when a Content carries multiple function_response
parts, return one ToolMessage per result, and flatten the returned messages
in _build_chat_details() so parallel tool results are all preserved.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
    • test_content_to_oci_message_multiple_function_responses: two
      function_response parts yield two ToolMessages with the correct tool
      call ids.
    • test_build_chat_details_flattens_multiple_tool_messages: a single
      Content with two parallel tool results produces two flattened messages
      in the outgoing chat request.
  • All unit tests pass locally (the new tests are stub-verified against the
    real module in this sandbox; the full suite runs in CI).

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.
@google-cla

google-cla Bot commented Aug 5, 2026

Copy link
Copy Markdown

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.

@adk-bot adk-bot added the models [Component] This issue is related to model support label Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

models [Component] This issue is related to model support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OCIGenAILlm silently drops all but the first tool result when multiple tools are called in parallel

3 participants