Skip to content

Fix: Ollama reasoning models return empty content — send reasoning_effort to disable thinking #46131

Description

@OneByJorah

Problem

When using Ollama as a local LLM backend with Hermes Agent, reasoning/thinking models (e.g. sorc/qwen3.5-claude-4.6-opus-q4:9b, deepseek-r1) return empty responses.

Root Cause

Ollama's OpenAI-compatible API handles reasoning models differently from other providers:

  1. Reasoning models return content: (empty string) in the chat completion response
  2. The actual model output is placed in a separate reasoning field
  3. Hermes Agent's chat_completions transport only reads content, so it silently drops the response
  4. The agent appears to hang or return blank answers

This affects all reasoning/thinking models on Ollama, including:

  • sorc/qwen3.5-claude-4.6-opus-q4:9b
  • deepseek-r1 (all sizes)
  • qwen3.5 with thinking enabled
  • Any model with thinking support in Ollama

Solution

Two changes are needed:

1. Config change (~/.hermes/config.yaml)

Add reasoning_effort: none to the agent section:

agent:
  reasoning_effort: none

2. Transport layer patch

The file agent/transports/chat_completions.py needs an Ollama-specific block in the build_kwargs function (after the LM Studio block, before extra_body assembly):

# Ollama: send reasoning_effort to disable thinking for reasoning models
# that return empty content (Ollama puts reasoning in separate field)
_base_url = params.get("base_url") or ""
_is_local = "127.0.0.1" in _base_url or "localhost" in _base_url or "::1" in _base_url
if _is_local and reasoning_config is not None and isinstance(reasoning_config, dict):
    _ollama_effort = reasoning_config.get("effort", "none") or "none"
    if _ollama_effort in {"none", "minimal", "low", "medium", "high"}:
        api_kwargs["reasoning_effort"] = _ollama_effort

This detects local Ollama endpoints and sends reasoning_effort: "none" which tells Ollama to disable the thinking/reasoning mode and return normal content responses.

Verification

After applying both changes:

  • Reasoning models return proper content instead of empty strings
  • The reasoning field in the response is empty (as expected with reasoning_effort: none)
  • All existing non-reasoning models continue to work unchanged

Environment

  • Ollama: Latest (local, http://127.0.0.1:11434/v1)
  • Hermes Agent: Latest
  • Hardware: RTX 3060 12GB
  • Models tested: sorc/qwen3.5-claude-4.6-opus-q4:9b, granite-code:8b

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointprovider/ollamaOllama / local modelstype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions