Look at https://github.com/moltis-org/moltis/issues/760 add a test to detect the issue,…
- User
Look at https://github.com/moltis-org/moltis/issues/760 add a test to detect the issue, then fix it
Assistant
Let me read the key source files to understand the exact issue.
Assistant
Now I understand the full picture. Let me look at the provider.rs to understand the call sites.
Assistant
Now I have a clear understanding. The issue has two parts:
-
Root cause:
canonicalize_schema_for_openai_compatonly strips$schemafrom the top level. If a nested schema (e.g., insidedefinitions) also has$schema,json_schema_astrejects it. More broadly, even with root stripping, thewarn!fires for every schema on every call. -
Log level: The
warn!level is wrong for an expected fallback that works correctly. CLAUDE.md saysdebug!for expected-but-not-configured states.
Let me write a failing test first, then fix.
-
Assistant
Now I'll add the test and fix. The key insight:
canonicalize_schema_for_openai_compatonly strips$schemafrom the root, butjson_schema_ast'svalidate_schema_dialectsrecursively validates$schemaat all levels. I also need to verify that draft-07 schemas actually get canonicalized (not just fallback-processed).Assistant
Now let's run the new tests to confirm they fail (detecting the issue):
Assistant
Good, the tests are found. Now let me run them to confirm they fail:
Assistant
Both tests pass — the root-only stripping already works for simple cases. But the output is correct via the fallback path, not canonicalization. The WARN is still being logged. Let me modify the nested definitions test to prove it uses fallback (not canonicalization) by checking for the boolean-enum canonicalization side-effect:
Assistant
The test fails as expected — the nested
$schemacauses canonicalization to fail and fall through to the WARN-logging fallback path. Now let me apply the fix.Assistant
Now downgrade the
warn!calls todebug!since the fallback is an expected path for non-standard schemas:Assistant
Now let's run the tests:
Assistant
All 3 draft-07 tests pass. Now let's run the full test suite to make sure nothing is broken:
Assistant
All 134 tests pass. Let me also check formatting and lint:
Assistant
Let me verify the final state of the changed files while the builds run:
Assistant
Good. Let me check on the background builds:
Assistant
All 367 tests pass. Let me check the lint result:
Assistant
All clean. Let me now create the beads issue and prepare to commit:
Assistant
Now let me verify the diff and commit:
Assistant
Clean diff. Let me commit:
Assistant
Done. Here's a summary of the changes:
Issue:
schema_normalizationloggedWARN1000+ times per session for every tool schema with a non-Draft-2020-12$schemaURI (like draft-07 from Attio MCP tools).Root causes:
$schemawas only stripped from the root of the parameters object.json_schema_astvalidates$schemarecursively at every nesting level, so schemas with$schemainside nesteddefinitions/$defsstill failed canonicalization.- The fallback was logged at
warn!level, but it's an expected state (not an error) since the fallback works correctly.
Fix (
schema_normalization.rs):- Added
strip_schema_keyword_recursive()that removes$schemafrom all levels of the JSON tree, not just the root - Downgraded all three fallback log statements from
warn!todebug!
Tests (
tests.rs):