Skip to content

[BUG] Ollama provider: premature context condensing and incorrect tool result handling #847

Description

@navedmerchant

Describe the bug

The native Ollama provider has three issues that degrade tool-calling behavior and context management:

  1. Premature context condensing: parseOllamaModel sets maxTokens to the full contextWindow. Since getModelMaxOutputTokens reserves 20% of the window for output, this causes the context to be condensed far earlier than necessary.
  2. Tool results sent as user messages: convertToOllamaMessages always sends tool results with the "user" role, so the model cannot distinguish tool results from actual user messages.
  3. additionalProperties in tool schema: The tool parameter schema includes additionalProperties, which is not part of Ollama's tool schema definition and breaks tool-calling templates on some models.

To Reproduce
Steps to reproduce the behavior:

  1. Configure a native Ollama model with a large context window.
  2. Use a tool-calling workflow with the model.
  3. Observe premature condensing and/or malformed tool-call behavior.

Expected behavior

  • maxTokens should reflect max output tokens (not the full context window), inheriting the sane default (4096).
  • Tool results should use Ollama's native "tool" role with tool_name when the corresponding tool_use block is known.
  • additionalProperties should be stripped from tool parameter schemas.

What version of zoo are you running
latest

Additional context
The fix tracks tool_use IDs to tool names so tool results can be sent with the correct role, inherits the default maxTokens, and strips additionalProperties from tool schemas.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions