Repository navigation
Description
Observed Behavior
A FunctionTool declared with a JSON schema (input_model given as a mapping) validates the provider's arguments with _validate_arguments_against_schema, whose check for "integer" is
case "integer":
return isinstance(value, int) and not isinstance(value, bool)(python/packages/core/agent_framework/_tools.py, _matches_json_schema_type, lines 1601-1602 on main at 9ef8672; the same lines ship in 1.22.0 and 1.23.0). A value of 3.0 fails with Invalid type for 'count' in 'count_things': expected integer, got float. In the automatic function-calling loop the model receives Error: Argument parsing failed. (with that detail when include_detailed_errors is on) and spends one more round trip and one of max_iterations to retry with 3.
The same arguments through a Pydantic input_model (count: int) are accepted: 3.0 arrives as 3. So whether 3.0 is a valid integer depends on how the tool was declared, not on the schema the model was shown. Tools taken from MCP servers arrive as schemas, so this is their path.
Seen live on 2026-10-29: Qwen3.5-122B behind vLLM 0.32.0 sent num_results: 3.0 on its first web-search call in 2 of 2 turns that used the tool. Each cost one extra model call and one iteration of the loop; the retry with 3 succeeded.
Expected Behavior
3.0 passes the integer check and reaches the function as 3, as the Pydantic path already delivers it. JSON Schema Validation 2020-12, section 6.1.1, defines integer as matching "any number with a zero fractional part" (https://json-schema.org/draft/2020-12/json-schema-validation.html). 2.5 and True keep failing.
Steps to Reproduce
- Install
agent-framework-core==1.22.0or==1.23.0(Python 3.12). - Run the script below.
- Observe the second line of each block: the schema-declared tool rejects
3.0, the Pydantic-declared tool accepts it.
Minimal Reproduction
import asyncio
from pydantic import BaseModel
from agent_framework import FunctionTool
schema = {"type": "object", "properties": {"count": {"type": "integer"}}, "required": ["count"]}
class Args(BaseModel):
count: int
async def count_things(count):
return f"received {count!r} ({type(count).__name__})"
async def main():
for label, model in (("schema dict", schema), ("pydantic model", Args)):
tool = FunctionTool(name="count_things", description="counts", func=count_things, input_model=model)
for value in (3, 3.0, 2.5, True):
try:
result = await tool.invoke(arguments={"count": value})
print(f"{label:14} {value!r:5} -> {result[0].text}")
except Exception as exc:
print(f"{label:14} {value!r:5} -> {type(exc).__name__}: {str(exc).splitlines()[0]}")
asyncio.run(main())Error Messages and Stack Traces
agent-framework-core 1.23.0
schema dict 3 -> received 3 (int)
schema dict 3.0 -> _FunctionArgumentValidationError: Invalid type for 'count' in 'count_things': expected integer, got float
schema dict 2.5 -> _FunctionArgumentValidationError: Invalid type for 'count' in 'count_things': expected integer, got float
schema dict True -> _FunctionArgumentValidationError: Invalid type for 'count' in 'count_things': expected integer, got bool
pydantic model 3 -> received 3 (int)
pydantic model 3.0 -> received 3 (int)
pydantic model 2.5 -> _FunctionArgumentValidationError: Invalid arguments for 'count_things': 1 validation error for Args
pydantic model True -> received 1 (int)
The output on 1.22.0 is identical.
Package Versions
agent-framework-core: 1.22.0 and 1.23.0 (both run); main at 9ef8672 carries the same check
Python Version
Python 3.12
Operating System
macOS (reproduction); Linux (the live loop)
Regression
Unknown
Additional Context
A fix that follows the schema: in _matches_json_schema_type, count a float with a zero fractional part (value.is_integer()) as an integer, booleans still excluded, and have _validate_arguments_against_schema hand the function int(value) for an integer property, so both declaration paths deliver the same Python type. Tests worth having: 3.0 accepted as 3; 2.5 and True rejected; 3.0 accepted for "type": ["integer", "null"].
Until a release carries a fix we bridge with function middleware that repairs the value before the final check, the path _tools.py itself points to ("Install argument-repair middleware before security middleware").
Acknowledgements
- I searched existing issues and did not find a duplicate.
- I personally verified this behavior and the reproduction details are authentic.
- I will wait for explicit maintainer agreement before starting implementation of a non-trivial change.
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
github-actions commentedon Oct 29, 2026
🤖 Automated triage reproduction notes (agent-authored — trust but verify)
Agent analysis
The bug occurs in
python/packages/core/agent_framework/_tools.py::_matches_json_schema_type, reached through_validate_arguments_against_schema, when a schema-supplied integer receives a whole-number float such as3.0. Minimal repro: construct aFunctionToolwith mapping input schema{"count": {"type": "integer"}}and invoke it with{"count": 3.0}; validation raises_FunctionArgumentValidationErrorbefore execution.python/packages/core/tests/core/test_tools.py::test_function_tool_with_json_schema_accepts_whole_number_float_for_integeragent-framework-core 1.22.0 and 1.23.0agent-framework-core 1.23.0danielquintas8 commentedon Oct 29, 2026
I'll take on implementing this as described under Expected Behavior. A float with a zero fractional part would pass the
integercheck and reach the function as anint, the value the Pydantic path already delivers. Fractional values and booleans would still be rejected, and type lists such as["integer", "null"]would get the same treatment.Eduard van Valkenburg (@eavanvalkenburg), before I open a PR, can you confirm that the function should receive an
int? If the check only accepted3.0and passed it on unchanged, a tool that callsrange(count)or indexes a list withcountwould still raiseTypeError.This is the change I have in mind, against
mainat 4d28d0a:A type list that also allows
numberkeeps the float, because the value is already valid there as it is. I ran this on 1.23.0, whose two functions are identical tomain's.3.0reaches the function as3forinteger, for["integer", "null"]and with anenum, and a tool that callsrange(count)works.2.5,Trueandinfare still rejected. The PR would add tests for these cases, including one that a schema-declared tool and a Pydantic-declared tool hand the function the same3for3.0.eavanvalkenburg commentedon Nov 2, 2026
/plan Plan the schema-supplied FunctionTool whole-number-float integer mismatch, coordinating existing #9852 and the reporter proposal rather than starting competing implementations. Current validation rejects 3.0 despite JSON Schema integer semantics; accepting it alone does not settle the Python type passed to a callable such as range(count). Decide and document the callable-observable normalization contract versus acceptance-only behavior, including integer/null and integer/number unions, enums, booleans, fractional/nonfinite values and Pydantic-path differences. Preserve already-valid number values and intentional boolean rejection; keep scope to the existing supported top-level mapping-schema checks rather than introduce a general schema/coercion engine. Cross-check the function-calling-loop contract and argument-repair/security middleware ordering; test actual FunctionTool invocation, not only the primitive predicate, including schema-derived MCP tools where applicable. Existing PR currently addresses acceptance but not the reporter requested int delivery, so do not mark it minor-ready or assign until this behavior is agreed.
fix(core): hand schema-supplied tools an int when the schema asks for…
danielquintas8 commentedon Nov 2, 2026
Eduard van Valkenburg (@eavanvalkenburg), I want to raise a concern about the contribution process. This is the second issue I’ve reported where someone opened a PR before maintainer agreement was recorded on the issue.
On 22 October, the author of #9573 acknowledged that neither it nor their other two PRs had maintainer agreement. On 28 October, you also asked the author of #9852 for an agreed issue or a justified trivial-change exception on #9547, before #9852 opened.
I asked for confirmation before opening my own PR. If another implementation proceeds while I wait and becomes the basis for further work, it becomes hard to justify offering fixes through the issue-first process. It makes me less willing to report issues.
Your plan already withholds readiness and assignment while the behavior is agreed. Could you clarify how PRs opened before that agreement will be handled? I’d like to see the requirement applied consistently before implementation review, so contributors who wait are not disadvantaged by following the process.
eavanvalkenburg commentedon Nov 3, 2026
Maintainer decision for #9843: accept whole-number floats as JSON Schema integers and normalize them to Python
intbefore invocation for integer-only andinteger | nullschemas. Preserve the float whennumberis also allowed, and continue rejecting booleans, fractional values, and non-finite values. Keep scope to the existing top-level mapping-schema validation. #9852 matches this contract. Daniel Quintas (@danielquintas8), thank you for reporting the issue and waiting for direction; this comment records the agreed behavior and coordination decision.Python: fix(core): accept whole-number floats for JSON Schema integer…