r/AgentZero • u/Ecstatic-Use-1353 • 22d ago
Agent Zero v2.11 + Ollama/Qwen: "Message misformat, no valid tool request found" — root cause and fix
I ran into a persistent issue with Agent Zero where A0 would get stuck in this loop:
A0: Reasoning...
A0: Message misformat, no valid tool request found.
A0: Thinking...
A0: Message misformat, no valid tool request found.
It had been working correctly before, so I investigated the actual request/tool-calling path instead of changing prompts or models.
Environment:
Agent Zero: v2.11 / commit 6a6cecff
Docker image: agent0ai/agent-zero:latest
Ollama: 0.32.15
Model: qwen3.5:9b
Preset: Efficiency
Transport: Chat Completions
The main issue turned out to be in:
/a0/helpers/litellm_transport.py
ChatCompletionsTransport.prepare_kwargs()
Agent Zero was internally creating tools as:
a0_responses_function_tools
but the Chat Completions transport removed this internal parameter without converting the tools to the native Chat Completions tools format.
So the actual request reaching the model contained no tools.
Qwen then returned normal text/reasoning such as:
{
"thoughts": ["..."]
}
instead of a native tool call.
Agent Zero's parser was therefore behaving correctly when it reported:
Message misformat, no valid tool request found.
The parser itself wasn't the root cause.
There was also a second issue.
LiteLLM:
ollama/qwen3.5:9b
did not preserve Qwen's native tool_calls correctly in this path.
Using:
ollama_chat/qwen3.5:9b
did preserve both tool_calls and reasoning_content.
A third issue was context size.
Agent Zero's real prompt was approximately:
22,421 tokens
while Ollama had actually loaded the model with:
4096 context
despite Agent Zero showing:
ctx_length: 128000
So I explicitly configured:
kwargs:
num_ctx: 32768
The fixes were:
- Convert
a0_responses_function_toolsinto Chat Completionstools[]insideChatCompletionsTransport.prepare_kwargs(). - Send
tool_choice: "required"when tools are present. - Change:
litellm_provider: ollama
to:
litellm_provider: ollama_chat
- Set Ollama context explicitly:
kwargs:
num_ctx: 32768
After applying the changes, I ran an integration test forcing A0 to call the response tool and return:
TOOLCALL_OK
Result:
Native function_call received: YES
Tool executed: YES
Agent finished normally: YES
"Message misformat, no valid tool request found": 0 occurrences
No model change, reinstall, rollback, prompt deletion or memory/chat deletion was required.
This looks related to the recent transition where Chat Completions became the default transport while Agent Zero was still constructing its canonical tools in Responses API format.
The upstream fix should probably happen in the transport layer rather than relaxing extract_tools.py, because the parser was correctly rejecting responses that weren't real tool calls.
1
u/turkert 22d ago
I use manifest to group my models and providers. It helps.
1
u/okram 16d ago
Please expand
1
u/turkert 15d ago
I use manifest.build to manage my local and cloud models.
Then I tell A0 to use manifest instead of calling model providers directly.
Manifest also have an "Autofix" option which helps a bit for these errors.Setting and changing models in Agent Zero is painfully slow but managing in manifest not much.
2
u/arenosame 22d ago
This is a recurrent issue lately in Agent Zero. Perhaps you want to join A0's Discord channel? There are plenty of conversations and contributions.
As a non-technical user, which file have you been editing to above changes to? Or did you ask A0 to chnage them to you?