Skip to content

fix: widen Integer to Long in castValue() for boxed Long parameter#1290

Open
jjhz wants to merge 1 commit into
google:mainfrom
jjhz:fix/function-tool-boxed-long-cast
Open

fix: widen Integer to Long in castValue() for boxed Long parameter#1290
jjhz wants to merge 1 commit into
google:mainfrom
jjhz:fix/function-tool-boxed-long-cast

Conversation

@jjhz

@jjhz jjhz commented Jun 20, 2026

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):

Testing Plan

Unit Tests:

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

Two new tests added to FunctionToolTest:

  • call_withPrimitiveLongParam_whenModelProvidesInteger_succeeds — confirms primitive long was never broken (Java reflection auto-widens intlong); serves as a regression guard.
  • call_withBoxedLongParam_whenModelProvidesInteger_succeeds — directly reproduces the bug: passes Integer(42) as the arg for a boxed Long parameter (exactly what Jackson produces when deserializing the model's small integer), and asserts the tool returns 42L correctly.
Tests run: 60, Failures: 0, Errors: 0, Skipped: 0

Manual End-to-End (E2E) Tests:

The bug is fully exercised by the unit tests above, which simulate exactly what the ADK framework does at runtime: Jackson deserializes a small JSON integer as Integer, the framework passes it unchanged into tool.runAsync(), and castValue() must widen it to Long before reflection invokes the tool method. No additional E2E setup is required to observe the fix.

Checklist

  • I have read the CONTRIBUTING.md document.
  • My pull request contains a single commit.
  • 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.

@google-cla

google-cla Bot commented Jun 20, 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.

@hemasekhar-p

Copy link
Copy Markdown
Contributor

Hi @jjhz, thank you for your contribution! We appreciate you taking the time to submit this pull request. Currently this PR is under review by our team, we will keep you posted if any additional information is required. thank you.

@hemasekhar-p

Copy link
Copy Markdown
Contributor

@krwc, Could you please review this PR.

@hemasekhar-p hemasekhar-p self-assigned this Jun 22, 2026
@jjhz jjhz force-pushed the fix/function-tool-boxed-long-cast branch 4 times, most recently from 7d6b79f to 7644a17 Compare June 25, 2026 11:10
@jjhz jjhz force-pushed the fix/function-tool-boxed-long-cast branch from 7644a17 to bc32948 Compare June 25, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: FunctionTool silently returns generic error when tool has a boxed Long parameter and model returns a small integer

2 participants