Skip to content

[Fix] parser: Accept whole-number floats for integer tool arguments - #43941

Merged
Jiminator merged 3 commits into
sgl-project:mainfrom
yonigozlan:coerce-integral-floats
Oct 21, 2026
Merged

Jiminator merged 3 commits into
sgl-project:mainfrom
yonigozlan:coerce-integral-floats

Conversation

@yonigozlan

@yonigozlan yonigozlan commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

When tool schemas are passed to the response parser, an integer argument written as a whole-number float like "3.0" is now cast to 3 instead of being left as the raw string.

  • JSON Schema (draft 6 onward, including 2020-12) defines integer as any number with a zero fractional part, so 3.0 is a valid integer value. jsonschema (Draft 7 and 2020-12 validators) and Pydantic v2 both accept it, and Pydantic returns 3.
  • Models do sometimes write integer arguments this way, and the tool then receives a string where its schema declares an integer.
  • Values with a fractional part ("3.5"), inf and NaN still fail the integer cast, so they fall through to the next declared type or stay raw, as before.
  • Adds a unit test next to the existing argument coercion tests.
  • Same change as in Transformers: Accept whole-number floats for integer tool arguments in parse_response huggingface/transformers#49547.

CI States

Latest PR Test (Base): ✅ Run #39535859047
Latest PR Test (Extra): ❌ Run #39535858929
Latest PR Test (AMD ROCm 10): ❌ Run #39535858894

JustinTong0323

This comment was marked as outdated.

@JustinTong0323 JustinTong0323 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Jiminator Jiminator added run-ci CI: run the baseline test suite on this PR bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) labels Oct 19, 2026
@github-actions

This comment has been minimized.

Jiminator added a commit that referenced this pull request Oct 21, 2026
@Jiminator
Jiminator merged commit a2e4ffb into sgl-project:main Oct 21, 2026
265 of 277 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants