hermes - ✅(Solved) Fix Kimi K2-6 with chat_template_kwargs.thinking: true returns content: null, reasoning_content not displayed in Telegram [1 pull requests, 2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#22949Fetched 2026-05-11 03:32:12
View on GitHub
Comments
2
Participants
2
Timeline
12
Reactions
0
Author
Participants
Timeline (top)
labeled ×7commented ×2referenced ×2cross-referenced ×1

Root Cause

Root Cause Analysis (by line number reference)

Looking at gateway/run.py:

  • Line 10478: reasoning_content=msg.get("reasoning_content") — extracted from message
  • Lines 13765-13768: Comment notes "The agent's _build_api_kwargs converts these to the provider-specific format (reasoning_content, etc.)"
  • Line 13770-13773: Preserves reasoning, reasoning_details, codex_reasoning_items on assistant messages for multi-turn context

Fix Action

Workaround

Disable thinking mode (thinking: false) to get normal content responses.

PR fix notes

PR #23039: fix(agent): fallback to reasoning_content when content is null

Description (problem / solution / changelog)

Problem

When using Kimi K2-6 with chat_template_kwargs.thinking: true, the model returns content: null but reasoning_content contains the actual response text. The current code at line 14563 does:

final_response = assistant_message.content or ""

This results in an empty final_response, losing the model output entirely.

Solution

After the initial content check, add a fallback to self._extract_reasoning(assistant_message) which already handles reasoning_content, reasoning, and reasoning_details fields across multiple providers.

Changes

  • Line 14563: Added fallback chain: content_extract_reasoning() → empty string
  • No changes to _extract_reasoning() itself (already supports all provider formats)

Testing

  • Verified with Kimi K2-6 thinking mode
  • Response correctly falls back to reasoning_content

Fixes #22949

Changed files

  • run_agent.py (modified, +8/-1)

Code Example

custom_providers:
  - provider: nvidia
    name: "NVIDIA AI"
    api_key: "..."
    api_base: "https://integrate.api.nvidia.com/v1"
    models:
      "moonshotai/kimi-k2.6":
        max_tokens: 4096
        chat_template_kwargs:
          thinking: true

---

curl -X POST "https://integrate.api.nvidia.com/v1/chat/completions" \
  -H "Authorization: Bearer <key>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "moonshotai/kimi-k2.6",
    "messages": [{"role": "user", "content": "1+1=?"}],
    "chat_template_kwargs": {"thinking": true},
    "max_tokens": 50
  }'

---

{
  "choices": [{
    "message": {
      "role": "assistant",
      "content": null,
      "reasoning_content": "...thinking text...",
      "tool_calls": null
    }
  }],
  "usage": {
    "prompt_tokens": 17,
    "completion_tokens": 50,
    "reasoning_tokens": 50
  }
}
RAW_BUFFERClick to expand / collapse

Environment

  • Hermes commit: e493b1c48
  • Model: moonshotai/kimi-k2.6 (NVIDIA)
  • Platform: Telegram
  • Config:
custom_providers:
  - provider: nvidia
    name: "NVIDIA AI"
    api_key: "..."
    api_base: "https://integrate.api.nvidia.com/v1"
    models:
      "moonshotai/kimi-k2.6":
        max_tokens: 4096
        chat_template_kwargs:
          thinking: true

Problem Description

When using Kimi K2-6 with chat_template_kwargs.thinking: true on NVIDIA API:

  • Telegram receives a response with content: null
  • The thinking/reasoning content is not displayed
  • Manually calling the API confirms reasoning_content IS returned by NVIDIA

Manual API Verification (curl)

curl -X POST "https://integrate.api.nvidia.com/v1/chat/completions" \
  -H "Authorization: Bearer <key>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "moonshotai/kimi-k2.6",
    "messages": [{"role": "user", "content": "1+1=?"}],
    "chat_template_kwargs": {"thinking": true},
    "max_tokens": 50
  }'

Response includes:

{
  "choices": [{
    "message": {
      "role": "assistant",
      "content": null,
      "reasoning_content": "...thinking text...",
      "tool_calls": null
    }
  }],
  "usage": {
    "prompt_tokens": 17,
    "completion_tokens": 50,
    "reasoning_tokens": 50
  }
}

Root Cause Analysis (by line number reference)

Looking at gateway/run.py:

  • Line 10478: reasoning_content=msg.get("reasoning_content") — extracted from message
  • Lines 13765-13768: Comment notes "The agent's _build_api_kwargs converts these to the provider-specific format (reasoning_content, etc.)"
  • Line 13770-13773: Preserves reasoning, reasoning_details, codex_reasoning_items on assistant messages for multi-turn context

However, when displaying the response to the user, only content seems to be used, resulting in an empty message when content: null.

Proposed Fix

When content is null but reasoning_content exists, display the reasoning content instead. Alternatively, add a display.show_reasoning config option to prepend or display reasoning alongside the final answer.

Workaround

Disable thinking mode (thinking: false) to get normal content responses.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING