[Bug] Ollama json.loads empty tool arguments abort request assembly
Author: MohammadHijjawi97Created Sep 17, 2026Updated Sep 17, 2026
Description
Ollama request assembly calls json.loads on tool-call arguments whenever they are a string. Empty strings and invalid JSON raise JSONDecodeError and abort the request. None is passed through as None instead of {}.
Steps to Reproduce
from agno.models.message import Message
from agno.models.ollama.chat import Ollama
model = Ollama()
assistant = Message(
role="assistant",
content=None,
tool_calls=[{
"id": "call_1",
"type": "function",
"function": {"name": "get_weather", "arguments": ""},
}],
)
model._format_message(assistant)Expected Behavior
Empty, null, or invalid JSON arguments become {}. A dict is passed through. Request assembly succeeds.
Actual Behavior
json.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Environment
- OS: Windows 11
- Agno Version: current main
- Additional Environment Details: Python 3.13
Possible Solutions (optional)
Parse string arguments with a try/except. Treat None or blank strings as {}. Pass dicts through.
Source: agno-agi/agno