Problem
When a user message includes multiple tool results in the same turn, images from an earlier tool result are incorrectly included in subsequent tool result messages sent to Ollama.
Context (who is affected and when)
Affects any Ollama conversation where the model uses tools and returns multiple tool results in a single turn, and at least one of those results contains an image (e.g. a screenshot tool result).
Reproduction steps
- Configure Zoo Code with the Ollama provider (any vision-capable model, e.g. llava)
- Run a task that causes multiple tool calls to fire in the same turn
- Ensure at least one tool result contains an image
- Inspect the outgoing Ollama API request payload (or observe model confusion/hallucinations referencing the wrong image)
Expected result
Each tool result message is sent to Ollama with only its own images attached.
Actual result
The second (and any subsequent) tool result messages include images from all previous tool results in the same turn, leading to redundant context, higher token consumption, and potential model confusion.
Root cause
src/api/providers/native-ollama.ts:53 — toolResultImages: string[] is declared outside the toolMessages.forEach loop, so images accumulate across iterations. Each subsequent ollamaMessages.push inherits all images pushed by earlier iterations.
Fix: Move the declaration inside the loop so each tool result message gets its own isolated image array.
App Version
Post-#832 (current HEAD)
API Provider
Ollama
Problem
When a user message includes multiple tool results in the same turn, images from an earlier tool result are incorrectly included in subsequent tool result messages sent to Ollama.
Context (who is affected and when)
Affects any Ollama conversation where the model uses tools and returns multiple tool results in a single turn, and at least one of those results contains an image (e.g. a screenshot tool result).
Reproduction steps
Expected result
Each tool result message is sent to Ollama with only its own images attached.
Actual result
The second (and any subsequent) tool result messages include images from all previous tool results in the same turn, leading to redundant context, higher token consumption, and potential model confusion.
Root cause
src/api/providers/native-ollama.ts:53—toolResultImages: string[]is declared outside thetoolMessages.forEachloop, so images accumulate across iterations. Each subsequentollamaMessages.pushinherits all images pushed by earlier iterations.Fix: Move the declaration inside the loop so each tool result message gets its own isolated image array.
App Version
Post-#832 (current HEAD)
API Provider
Ollama