Skip to content

fix(oci): preserve all tool results for parallel function calls - #6595

Open
Harshitmishra001 wants to merge 2 commits into
google:mainfrom
Harshitmishra001:fix-oci-parallel-tool-results
Open

fix(oci): preserve all tool results for parallel function calls#6595
Harshitmishra001 wants to merge 2 commits into
google:mainfrom
Harshitmishra001:fix-oci-parallel-tool-results

Conversation

@Harshitmishra001

Copy link
Copy Markdown

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

2. Or, if no issue exists, describe the change:

If applicable, please follow the issue templates to provide as much detail as
possible.

Problem:
When an agent backed by OCIGenAILlm has two or more tools called in parallel in a single turn, only the result of the first tool is forwarded to the OCI model API on the next request. All other tool results are silently dropped because _content_to_oci_message previously only extracted tool_results[0].

Solution:
Refactored _content_to_oci_message in src/google/adk/integrations/oci/_oci_genai_llm.py to return a list of ToolMessage objects when multiple tool results are present. Updated _build_chat_details to properly flatten this list into the messages array payload sent to the OCI API. This maps parallel function responses exactly as expected by the underlying model and mirrors the correct behavior in other integrations (like LiteLLM).

Testing Plan

Please describe the tests that you ran to verify your changes. This is required
for all PRs that are not small documentation or typo fixes.

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Please include a summary of passed pytest results.

============================= test session starts =============================
platform win32 -- Python 3.11.9, pytest-9.1.1, pluggy-1.6.0
rootdir: C:\Users\hmhar\Google_PR\adk-python
configfile: pyproject.toml
plugins: anyio-4.10.0, langsmith-0.10.15, asyncio-1.4.0, mock-3.15.1, xdist-3.8.0
asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=function, asyncio_default_test_loop_scope=function
collected 53 items

tests\unittests\integrations\oci\test_oci_genai_llm.py ................. [ 32%]
....................................                                     [100%]

============================= 53 passed in 2.09s ==============================

Manual End-to-End (E2E) Tests:

This was manually reproduced using the multi-tool parallel calling framework provided in issue #6589. Verified that all parallel function responses generated by merge_parallel_function_response_events are properly surfaced to the model without truncation.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

This addresses the exact root cause identified in issue #6589. My Contributor License Agreement (CLA) is signed and verified.

…tool execution

This commit systematically removes the hardcoded assumption across the framework that parts[0] holds the unction_response. When parallel tool results are received, the contents' indices are dynamic. This replaces parts[0] with loop matching to find the correct unction_response.
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