-
-
Notifications
You must be signed in to change notification settings - Fork 68.9k
[Bug]: Ollama responses have empty content array after multiple tool results (tokens generated but not captured) #9900
Description
Summary
When using Ollama via OpenAI-compatible API (api: "openai-completions"), responses after multiple tool call/result cycles return with content: [] (empty array) despite generating output tokens. The model IS responding (token count shows 53 output tokens), but the content is not being captured.
Steps to Reproduce
- Configure Ollama provider with explicit model:"ollama": {
"baseUrl": "http://ollama-host:11434/v1",
"apiKey": "ollama-local",
"api": "openai-completions",
"models": [{
"id": "qwen2.5:7b-instruct",
"contextWindow": 32768,
"maxTokens": 8192
}]
} - Spawn a subagent task that requires tool use
- Have the tool return an error
- Model makes another tool call (retry)
- Tool returns error again
- Model's final response has content: [] but output: 53 tokens
Expected Behavior
The 53 generated tokens should appear in the content array as a text block.
Actual Behavior
{
"role": "assistant",
"content": [],
"usage": {
"input": 3343,
"output": 53
},
"stopReason": "stop"
}
Verification
Raw Ollama API works correctly — tested the exact same conversation via curl with streaming enabled, and content is returned properly. The bug is in the response parsing layer.
This works fine:
curl http://ollama-host:11434/v1/chat/completions
-d '{"model":"qwen2.5:7b-instruct","messages":[...same history...],"tools":[...],"stream":true}'
Returns proper content deltas
Environment
• OpenClaw version: 2026.1.24-3
• Provider: Ollama (qwen2.5:7b-instruct)
• API mode: openai-completions
• OS: Ubuntu 24.04 (arm64)
Suspected Location
@mariozechner/pi-ai/dist/providers/openai-completions.js — streaming content deltas may not be captured correctly after tool result messages in certain scenarios.