Skip to content

fix(tools): strip default from $ref nodes in tool schemas - #44676

Merged
OutThisLife merged 1 commit into
mainfrom
bb/fix-schema-ref-default
Jun 12, 2026
Merged

fix(tools): strip default from $ref nodes in tool schemas#44676
OutThisLife merged 1 commit into
mainfrom
bb/fix-schema-ref-default

Conversation

@OutThisLife

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes HTTP 400 JSON Schema not supported: keyword(s) ['default'] not allowed at the same level as $ref on every agent turn when using strict backends (reported on Fireworks-hosted Kimi K2 with MCP tools enabled).
  • The global schema sanitizer now recursively strips default from any node that carries $ref, and nullable anyOf collapse no longer copies default onto $ref branches.

Root cause

MCP/Pydantic tool schemas commonly express optional fields as anyOf: [{$ref: ...}, {type: null}] with default: null. Hermes already collapses those unions for backend compatibility, but the collapse was leaving {"$ref": "#/$defs/Foo", "default": null} — which Fireworks (and other draft-07-strict validators) reject outright.

Test plan

  • scripts/run_tests.sh tests/tools/test_schema_sanitizer.py (43 passed)
  • Reproduce on affected setup: Fireworks Kimi + MCP server with $ref-based schemas; confirm gateway/CLI messages succeed after upgrade

Fireworks-hosted Kimi rejects tool requests when nullable MCP/Pydantic
schemas collapse to {"$ref": "...", "default": null}. Strip that sibling
during global schema sanitization so gateway and CLI calls succeed again.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: bb/fix-schema-ref-default 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: 10772 on HEAD, 10772 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5648 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/tools Tool registry, model_tools, toolsets tool/mcp MCP client and OAuth provider/kimi Kimi / Moonshot labels Jun 12, 2026
@OutThisLife
OutThisLife merged commit d810f2b into main Jun 12, 2026
28 checks passed
@OutThisLife
OutThisLife deleted the bb/fix-schema-ref-default branch June 12, 2026 06:21
AIalliAI added a commit to AIalliAI/Hermes that referenced this pull request Jun 14, 2026
Applied from upstream merge d810f2b (PR NousResearch#44676, bb/fix-schema-ref-default).
Fixes HTTP 400 on strict draft-07 backends (Fireworks Kimi) when MCP tool
schemas leave default alongside $ref after nullable-union collapse.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
AIalliAI pushed a commit to AIalliAI/Hermes that referenced this pull request Jun 14, 2026
…-ref-default

fix(tools): strip default from $ref nodes in tool schemas
T02200059 pushed a commit to T02200059/hermes-agent that referenced this pull request Jun 18, 2026
…-ref-default

fix(tools): strip default from $ref nodes in tool schemas
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…-ref-default

fix(tools): strip default from $ref nodes in tool schemas
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
…-ref-default

fix(tools): strip default from $ref nodes in tool schemas
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
…-ref-default

fix(tools): strip default from $ref nodes in tool schemas
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
…-ref-default

fix(tools): strip default from $ref nodes in tool schemas
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
…-ref-default

fix(tools): strip default from $ref nodes in tool schemas
melon-xf added a commit to melon-xf/hermes-agent that referenced this pull request Sep 3, 2026
…-ref-default

fix(tools): strip default from $ref nodes in tool schemas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists provider/kimi Kimi / Moonshot tool/mcp MCP client and OAuth type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants