Skip to content

docs(helpers): note that whole numbers in a data Part come back as floats - #1373

Open
carstenpiepel wants to merge 2 commits into
a2aproject:mainfrom
carstenpiepel:docs/data-part-whole-numbers
Open

carstenpiepel wants to merge 2 commits into
a2aproject:mainfrom
carstenpiepel:docs/data-part-whole-numbers

Conversation

@carstenpiepel

@carstenpiepel carstenpiepel commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Whole numbers placed in a data Part come back as floats. For example, 4326 becomes 4326.0. This happens because google.protobuf.Value stores every number as a double. It affects every transport and is not a spec violation, since JSON does not distinguish the two.

As agreed in #1328, this PR documents the behavior and does not change it.

  • Add a short note to the docstrings of new_data_part and get_data_parts.

  • Add one bullet to the v1.0 migration guide with the client-side workaround.

  • Add a strict xfail test that expects integers to stay integers, so CI flags it when the behavior changes.

  • Follow the CONTRIBUTING Guide.

  • Make your Pull Request title in the https://www.conventionalcommits.org/ specification.

  • Ensure the tests and linter pass (Run bash scripts/format.sh from the repository root to format)

  • Appropriate docs were updated (if necessary)

Refs #1328 🦕

🤖 Generated with Claude Code

…oats

google.protobuf.Value stores every number as a double, so an integer
placed in a data Part is read back as a float on every transport.
Document this on new_data_part and get_data_parts, add a bullet to the
v1.0 migration guide with the client-side workaround, and pin the
behavior with a test.

Fixes a2aproject#1328

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

No coverage changes.

Generated by coverage-comment.yml

@Iwaniukooo11 Iwaniukooo11 self-assigned this Oct 23, 2026
@@ -471,6 +471,14 @@ def test_get_data_parts_empty() -> None:
assert get_data_parts(parts) == []


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please "invert" the tests logic. Assuring that int is converted to float marks it as expected behaviour in SDK (but it isn't)

Instead, write a test which ensures that int is converted to int and mark it as @pytests.mark.xfail (we expect it to fail) with strict flag set to True

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The test now asserts that integers stay integers and is marked xfail with strict=True, with the issue URL as the reason. I also changed the PR body from Fixes to Refs, since the test treats the issue as still open.

…il strict

Review feedback: a passing test that asserts int becomes float would
record the conversion as intended. Assert the desired behavior instead
and mark it strict xfail, so CI flags the moment it starts passing.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@carstenpiepel

Copy link
Copy Markdown
Contributor Author

@Iwaniukooo11 the requested change is pushed: the test now expects integers to stay integers and is marked xfail with strict=True.

@Iwaniukooo11 Iwaniukooo11 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants