Skip to content

fix(moonshot): handle union type arrays in tool schemas#45579

Merged
teknium1 merged 1 commit into
mainfrom
fix/moonshot-union-type-arrays
Jun 13, 2026
Merged

fix(moonshot): handle union type arrays in tool schemas#45579
teknium1 merged 1 commit into
mainfrom
fix/moonshot-union-type-arrays

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Moonshot/Kimi tool schema sanitization now accepts JSON Schema union type arrays instead of crashing before the request is sent.

Changes

  • Normalize type: [...] to the first concrete non-null type in the Moonshot schema repair path.
  • Preserve existing enum cleanup and input immutability behavior.
  • Add regression coverage for concrete unions, nullable unions, and enum-bearing union schemas.

Validation

Check Result
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python3 -m pytest tests/agent/test_moonshot_schema.py::TestUnionTypeList -q 3 passed
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python3 -m pytest tests/agent/test_moonshot_schema.py -q 37 passed
scripts/run_tests.sh tests/agent/test_moonshot_schema.py 37 passed
Moonshot transport kwargs E2E passed
python3 -m py_compile agent/moonshot_schema.py tests/agent/test_moonshot_schema.py && git diff --check passed

Salvages #30226 by @Tranquil-Flow with authorship preserved.
Closes #30095.

Infographic

Moonshot Union Types

@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: fix/moonshot-union-type-arrays vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 10887 on HEAD, 10887 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5710 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder provider/kimi Kimi / Moonshot labels Jun 13, 2026
@teknium1 teknium1 merged commit 5acd185 into main Jun 13, 2026
28 checks passed
@teknium1 teknium1 deleted the fix/moonshot-union-type-arrays branch June 13, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists provider/kimi Kimi / Moonshot type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kimi-k2.6: TypeError: unhashable type 'list' in sanitize_moonshot_tools when tool has union type parameter

3 participants