hermes - 💡(How to fix) Fix Bug: moonshot_schema._fill_missing_type crashes on JSON Schema union types (list type)

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…

Error Message

TypeError: unhashable type: 'list' File "agent/moonshot_schema.py", line 138, in _fill_missing_type if "type" in node and node["type"] not in {None, ""}:

Root Cause

In agent/moonshot_schema.py, the _fill_missing_type() function at line 138:

if "type" in node and node["type"] not in {None, ""}:
    return node

When node["type"] is a list (valid JSON Schema for union types, e.g. ["number", "string"]), Python cannot hash the list to check membership in the set {None, ""}, raising TypeError: unhashable type: 'list'.

A similar issue exists at line 125:

if node_type in {"string", "integer", "number", "boolean"}:

Code Example

if "type" in node and node["type"] not in {None, ""}:
    return node

---

if node_type in {"string", "integer", "number", "boolean"}:

---

{
  "time_from": {
    "type": ["number", "string"],
    "description": "Optional timestamp"
  }
}

---

TypeError: unhashable type: 'list'
  File "agent/moonshot_schema.py", line 138, in _fill_missing_type
    if "type" in node and node["type"] not in {None, ""}:

---

if "type" in node:
    t = node["type"]
    if isinstance(t, list):
        return node  # union type is a valid type declaration
    if t not in {None, ""}:
        return node

---

if isinstance(node_type, str) and node_type in {"string", "integer", "number", "boolean"}:
RAW_BUFFERClick to expand / collapse

Bug Description

sanitize_moonshot_tools() raises TypeError: unhashable type: 'list' when a tool parameter uses JSON Schema union types like "type": ["number", "string"].

Root Cause

In agent/moonshot_schema.py, the _fill_missing_type() function at line 138:

if "type" in node and node["type"] not in {None, ""}:
    return node

When node["type"] is a list (valid JSON Schema for union types, e.g. ["number", "string"]), Python cannot hash the list to check membership in the set {None, ""}, raising TypeError: unhashable type: 'list'.

A similar issue exists at line 125:

if node_type in {"string", "integer", "number", "boolean"}:

Reproduction

Any tool with a parameter using union types triggers this. Example from the lcm_grep tool:

{
  "time_from": {
    "type": ["number", "string"],
    "description": "Optional timestamp"
  }
}

The model kimi-k2.6 (detected as moonshot via is_moonshot_model()) triggers sanitize_moonshot_tools() which hits this code path.

Error Log

TypeError: unhashable type: 'list'
  File "agent/moonshot_schema.py", line 138, in _fill_missing_type
    if "type" in node and node["type"] not in {None, ""}:

Suggested Fix

Line 138:

if "type" in node:
    t = node["type"]
    if isinstance(t, list):
        return node  # union type is a valid type declaration
    if t not in {None, ""}:
        return node

Line 125:

if isinstance(node_type, str) and node_type in {"string", "integer", "number", "boolean"}:

Environment

  • Hermes Agent v0.14.0
  • OpenAI SDK 2.24.0
  • Provider: ollama-cloud (ollama.com/v1)
  • Model: kimi-k2.6

Impact

This is a non-retryable error that completely blocks any conversation when:

  1. The model name matches is_moonshot_model() (any kimi-* model)
  2. Any tool in the toolset uses JSON Schema union types for parameters

Affects: interactive sessions, cron jobs, curator reviews — any agent run using kimi models with the standard toolset.

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