hermes - ✅(Solved) Fix TypeError: unhashable type: 'list' on kimi-k2.6:cloud via Ollama AND direct cloud — response parsing bug [2 pull requests, 1 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#28787Fetched 2026-05-20 04:02:00
View on GitHub
Comments
0
Participants
1
Timeline
9
Reactions
0
Participants
Timeline (top)
labeled ×5cross-referenced ×2referenced ×1renamed ×1

Error Message

TypeError: unhashable type: 'list'

Root Cause

The kimi-k2.6 model returns response fields (specifically the reasoning field as a top-level message property) that the OpenAI SDK (v2.24.0) cannot properly deserialize/hash. When the SDK encounters the response, it attempts to construct hashable objects from the response data, and the reasoning field (or another model-specific field) causes a TypeError: unhashable type: 'list' in the SDK's internal processing.

Other models work fine through identical provider configurations because they don't return these problematic fields.

Fix Action

Workaround

Use a different model, which doesn't trigger this error.

PR fix notes

PR #8: fix(kimi): extend _is_kimi detection to model name via is_moonshot_model() (#28787)

Description (problem / solution / changelog)

🟡 Merge order: 10 / 12 — 2 lines but wide blast radius

Closes #28787 (P2)

Problem

When kimi models are accessed via Ollama or other non-Moonshot base URLs, _is_kimi was False because it only checked base_url. Kimi-specific extra_body (thinking) and reasoning_effort were not set.

Fix

Add is_moonshot_model(agent.model) as a fallback to _is_kimi detection.

Risk assessment

FactorRating
Lines changed2
New code1 import + 1 condition
Side effects⚠️ _is_kimi now True for any model name matching kimi-*, regardless of base_url. This changes extra_body.thinking and reasoning_effort for Ollama-hosted kimi models. Ollama may ignore these params, but verify.
Revert complexityEasy

Testing notes

  • hermes chat -m kimi-k2.6:cloud --provider ollama → confirm no TypeError
  • Non-kimi models via Ollama → confirm _is_kimi is still False

Files changed

  • agent/chat_completion_helpers.py (+2)

Changed files

  • agent/chat_completion_helpers.py (modified, +2/-0)

PR #28879: fix(moonshot): flatten union types before set check to avoid TypeError (#28787, #28291)

Description (problem / solution / changelog)

Summary

Fix TypeError: unhashable type: 'list' in Moonshot schema sanitizer when tool parameters use JSON Schema union types ("type": ["number", "string"]).

Fixes #28787. Fixes #28291.

Problem

When a tool parameter schema contains a union type (e.g., "type": ["number", "string"]), the _fill_missing_type() function in moonshot_schema.py crashes at the set-membership check:

if "type" in node and node["type"] not in {None, ""}:  # TypeError!

Python cannot hash a list, so checking list membership in a set raises TypeError: unhashable type: 'list'.

This makes kimi-k2.6 completely unusable through Ollama providers, as every API call triggers this crash and falls back to the configured fallback model.

Root Cause

_fill_missing_type() assumes node["type"] is always a scalar (string or None). JSON Schema allows type to be an array of types (union type), but Moonshot only accepts scalar types.

Fix

Added an isinstance(node["type"], list) guard before the set check. If type is a list:

  • Non-empty list: take the first element as the scalar type
  • Empty list: fall back to "string"

Testing

  • 2 new tests in tests/agent/test_moonshot_schema.py:
    • test_union_type_list_flattened_to_first: ["number", "string"]"number"
    • test_empty_union_type_defaults_to_string: []"string"
  • 44 total tests passed (2 new + 42 existing moonshot schema tests)

Changed files

  • agent/moonshot_schema.py (modified, +8/-0)
  • tests/agent/test_moonshot_schema.py (modified, +24/-0)

Code Example

TypeError: unhashable type: 'list'

---

curl -s http://127.0.0.1:11434/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"kimi-k2.6:cloud","messages":[{"role":"user","content":"say hello"}],"max_tokens":16384,"stream":true}'

---

client = openai.OpenAI(base_url='http://127.0.0.1:11434/v1', api_key='ollama')
stream = client.chat.completions.create(
    model='kimi-k2.6:cloud',
    messages=[{"role": "user", "content": "say hello"}],
    tools=[{"type": "function", "function": {"name": "test_tool", ...}}],
    max_tokens=16384,
    stream=True,
)
# SUCCESS — receives all chunks correctly

---

{
  "details": {
    "parent_model": "kimi-k2.6",
    "family": "kimi-k2",
    "families": null,
    "parameter_size": "1042000000000",
    "quantization_level": "INT4"
  },
  "capabilities": ["vision", "thinking", "completion", "tools"]
}

---

{"role": "assistant", "content": "Hello! How can I help you today?", "reasoning": "The user wants me to say hello..."}

---

# KimiProfile.build_api_kwargs_extras() adds:
extra_body["thinking"] = {"type": "enabled"}     # Kimi's official param name
top_level["reasoning_effort"] = "medium"            # Top-level param

# Plus is_moonshot_model() triggers sanitize_moonshot_tools()
# which cleans tool schemas for Kimi's stricter JSON Schema subset
RAW_BUFFERClick to expand / collapse

Bug Report: kimi-k2.6:cloud fails with TypeError: unhashable type: 'list'

Hermes Version: v2.6.x (git: 39c41d0f2) Provider: Ollama Cloud and Ollama local proxy (127.0.0.1:11434/v1) Model: kimi-k2.6:cloud (Moonshot AI Kimi K2.6, 1T parameters, INT4) Python OpenAI SDK: 2.24.0 Related: #28291

Problem

Every API call to kimi-k2.6:cloud immediately fails with:

TypeError: unhashable type: 'list'

This triggers fallback on every single request, making kimi-k2.6:cloud completely unusable.

Investigation

1. Direct Ollama API works fine

curl -s http://127.0.0.1:11434/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"kimi-k2.6:cloud","messages":[{"role":"user","content":"say hello"}],"max_tokens":16384,"stream":true}'

Returns valid SSE chunks with no errors. Non-streaming calls also succeed.

2. OpenAI SDK streaming works for basic calls (no extra_body)

client = openai.OpenAI(base_url='http://127.0.0.1:11434/v1', api_key='ollama')
stream = client.chat.completions.create(
    model='kimi-k2.6:cloud',
    messages=[{"role": "user", "content": "say hello"}],
    tools=[{"type": "function", "function": {"name": "test_tool", ...}}],
    max_tokens=16384,
    stream=True,
)
# SUCCESS — receives all chunks correctly

3. Ollama model metadata

{
  "details": {
    "parent_model": "kimi-k2.6",
    "family": "kimi-k2",
    "families": null,
    "parameter_size": "1042000000000",
    "quantization_level": "INT4"
  },
  "capabilities": ["vision", "thinking", "completion", "tools"]
}

5. Response structure differs from other models

The kimi-k2.6 response includes a top-level reasoning field alongside content and role:

{"role": "assistant", "content": "Hello! How can I help you today?", "reasoning": "The user wants me to say hello..."}

This reasoning field is model-specific and not present in other responses (e.g. glm-5.1, qwen3-coder), which explains why those models work fine.

Root Cause Analysis

The kimi-k2.6 model returns response fields (specifically the reasoning field as a top-level message property) that the OpenAI SDK (v2.24.0) cannot properly deserialize/hash. When the SDK encounters the response, it attempts to construct hashable objects from the response data, and the reasoning field (or another model-specific field) causes a TypeError: unhashable type: 'list' in the SDK's internal processing.

Other models work fine through identical provider configurations because they don't return these problematic fields.

Expected Behavior

kimi-k2.6:cloud should work as model via Ollama providers.

Additional Analysis: Kimi Provider Pathway Processes Differently

The dedicated kimi-coding provider profile (KimiProfile in plugins/model-providers/kimi-coding/__init__.py) handles kimi models completely differently from the generic Ollama/custom path.

What the Kimi Profile Path Does (api.moonshot.ai)

# KimiProfile.build_api_kwargs_extras() adds:
extra_body["thinking"] = {"type": "enabled"}     # Kimi's official param name
top_level["reasoning_effort"] = "medium"            # Top-level param

# Plus is_moonshot_model() triggers sanitize_moonshot_tools()
# which cleans tool schemas for Kimi's stricter JSON Schema subset

What the Generic/Ollama Path Does (127.0.0.1:11434)

Because _is_kimi = False (base URL doesn't match api.kimi.com / moonshot.ai / moonshot.cn):

  1. Wrong param name: Sends extra_body = {"reasoning": {"enabled": True, "effort": "medium"}} instead of thinking — a completely different field name that Ollama/Kimi doesn't expect via this route
  2. No tool schema sanitization: is_moonshot_model() matches kimi-k2.6:cloud by name, but sanitize_moonshot_tools() only runs inside the KimiProfile profile path (line 438 of chat_completions.py). The legacy code path at line 337 also checks _is_kimi but this flag is False for local Ollama, so the sanitization is skipped.
  3. No reasoning_effort top-level param: The Kimi profile adds this; the legacy path doesn't.
  4. Response deserialization mismatch: The kimi-k2.6 response includes a top-level reasoning field at the message level that the OpenAI SDK's generic deserializer can't handle, causing TypeError: unhashable type: 'list'. The Kimi profile pathway presumably handles this field correctly.

Why Direct Cloud Also Fails

Even bypassing Ollama and hitting Kimi's cloud directly, the model identification still resolves to provider=custom (not kimi-coding), so the same legacy code path runs. The KimiProfile only activates when the provider is explicitly configured as kimi-coding in Hermes config — it's not triggered by model name alone.

Suggested Fix

The cleanest fix would be model-name-based profile resolution: when a model name matches is_moonshot_model(), route it through the KimiProfile regardless of which provider/base_url is configured. This would ensure:

  • Correct thinking param (not reasoning)
  • Tool schema sanitization for Kimi's stricter requirements
  • Proper reasoning_effort top-level param
  • Correct response deserialization for the reasoning field

This aligns with the existing pattern where sanitize_moonshot_tools() is already called by model name in the profile path (line 438) — it just needs to extend to the response handling layer as well.

Workaround

Use a different model, which doesn't trigger this error.

Environment

  • OS: Linux (Debian 13)
  • Ollama: v0.9.x (local, port 11434)
  • Model: kimi-k2.6:cloud (Moonshot AI, 1T params, INT4 quantization)
  • Hermes config: provider ollama-launch with custom_providers entry pointing to http://127.0.0.1:11434/v1
  • Also confirmed failing on direct cloud (no Ollama proxy)

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

hermes - ✅(Solved) Fix TypeError: unhashable type: 'list' on kimi-k2.6:cloud via Ollama AND direct cloud — response parsing bug [2 pull requests, 1 participants]