Skip to content

Bug: moonshot_schema._fill_missing_type crashes on JSON Schema union types (list type) #28291

@yazan1991

Description

@yazan1991

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existscomp/agentCore agent loop, run_agent.py, prompt buildertype/bugSomething isn't working

    Type

    No type
    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