You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error is cause by pydantic that tool expect string but received int.
Description
Change in ticket #28225 cause that simple argument like string with only digits only are convert to int and because it's long string with digits part of value is lost.
After commenting changes from related ticket:
def _parse_arguments_from_tool_call(
raw_tool_call: dict[str, Any],
) -> Optional[dict[str, Any]]:
"""Parse arguments by trying to parse any shallowly nested string-encoded JSON.
Band-aid fix for issue in Ollama with inconsistent tool call argument structure.
Should be removed/changed if fixed upstream.
See https://github.com/ollama/ollama/issues/6155
"""
if "function" not in raw_tool_call:
return None
arguments = raw_tool_call["function"]["arguments"]
parsed_arguments = {}
if isinstance(arguments, dict):
for key, value in arguments.items():
# if isinstance(value, str):
# parsed_arguments[key] = _parse_json_string(
# value, skip=True, raw_tool_call=raw_tool_call
# )
# else:
parsed_arguments[key] = value
else:
parsed_arguments = _parse_json_string(
arguments, skip=False, raw_tool_call=raw_tool_call
)
return parsed_arguments
problem doesn't exists. When debugging noticed that llm result (tools argument) are converted to dict and in dict I have 'value': '12345678901234567890' but after parsing '12345678901234567890' to json (method) _parse_json_string it's converted to int even if tool expected argument is string.
Two potential solutions:
1. check expected type by tool and if it's match doesn't parse as json
2. Parse only as JSON if at least basic json pattern is matched and it's no value only
### System Info
System Information
------------------
> OS: Darwin
> OS Version: Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:24 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6030
> Python Version: 3.13.2 (main, Feb 4 2025, 14:51:09) [Clang 16.0.0 (clang-1600.0.26.6)]
Package Information
-------------------
> langchain_core: 0.3.34
> langchain: 0.3.17
> langchain_community: 0.3.16
> langsmith: 0.3.6
> langchain_azure_ai: 0.1.0
> langchain_experimental: 0.3.4
> langchain_ollama: 0.2.3
> langchain_openai: 0.3.4
> langchain_text_splitters: 0.3.6
> langgraph_sdk: 0.1.51
Optional packages not installed
-------------------------------
> langserve
Other Dependencies
------------------
> aiohttp: 3.11.12
> async-timeout: Installed. No version info available.
> azure-ai-inference[opentelemetry]: Installed. No version info available.
> azure-core: 1.32.0
> azure-identity: 1.19.0
> azure-monitor-opentelemetry: Installed. No version info available.
> dataclasses-json: 0.6.7
> httpx: 0.28.1
> httpx-sse: 0.4.0
> jsonpatch<2.0,>=1.33: Installed. No version info available.
> langchain-core<1.0.0,>=0.3.34: Installed. No version info available.
> langsmith-pyo3: Installed. No version info available.
> langsmith<0.4,>=0.1.125: Installed. No version info available.
> numpy: 2.2.2
> ollama: 0.4.7
> openai<2.0.0,>=1.58.1: Installed. No version info available.
> opentelemetry-instrumentation-threading: Installed. No version info available.
> opentelemetry-semantic-conventions-ai: Installed. No version info available.
> orjson: 3.10.15
> packaging<25,>=23.2: Installed. No version info available.
> pydantic: 2.10.6
> pydantic-settings: 2.7.1
> pydantic<3.0.0,>=2.5.2;: Installed. No version info available.
> pydantic<3.0.0,>=2.7.4;: Installed. No version info available.
> pytest: Installed. No version info available.
> PyYAML: 6.0.2
> PyYAML>=5.3: Installed. No version info available.
> requests: 2.32.3
> requests-toolbelt: 1.0.0
> rich: 13.9.4
> SQLAlchemy: 2.0.38
> tenacity: 9.0.0
> tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available.
> tiktoken<1,>=0.7: Installed. No version info available.
> typing-extensions>=4.7: Installed. No version info available.
> zstandard: 0.23.0
The text was updated successfully, but these errors were encountered:
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Error is cause by pydantic that tool expect string but received int.
Description
Change in ticket #28225 cause that simple argument like string with only digits only are convert to int and because it's long string with digits part of value is lost.
After commenting changes from related ticket:
The text was updated successfully, but these errors were encountered: