fix(provider): expand $ref/$defs for DeepSeek compatibility#32955
Open
lexlian wants to merge 2 commits into
Open
fix(provider): expand $ref/$defs for DeepSeek compatibility#32955lexlian wants to merge 2 commits into
lexlian wants to merge 2 commits into
Conversation
DeepSeek API rejects JSON Schema 2020-12 \$ref pointers in MCP tool schemas, causing AttributeError: 'NoneType' object has no attribute 'lookup' when using MCP servers with \$defs references (Asana, Notion). Adds expandRefs() that inlines \$ref targets from \$defs/definitions before sending schemas to DeepSeek. Handles nested \$refs, preserves override fields on referencing nodes, and guards against circular refs. Closes anomalyco#32829 Closes anomalyco#29220 (duplicate) fix: expand \$ref references in JSON Schema for DeepSeek compatibility
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Resolve conflict in transform.ts: keep both expandRefs (DeepSeek) and sanitizeOpenAISchema (OpenAI) sanitization functions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #32829
Closes #29220
Type of change
What does this PR do?
DeepSeek API rejects JSON Schema 2020-12
$refpointers in MCP tool schemas, causingAttributeError: 'NoneType' object has no attribute 'lookup'when using MCP servers with$defsreferences (Asana, Notion).This PR adds
expandRefs()toProviderTransform.schema()that inlines$reftargets from$defs/definitionsbefore sending schemas to DeepSeek. It handles nested$refreferences, preserves override fields on referencing nodes (e.g. adescriptionon the$refnode wins over the definition's description), and guards against circular references via a seen set.The approach mirrors PR #12292 (closed, not merged) which proposed the same fix for Gemini.
How did you verify your code works?
bun typecheck— pass (full repo typecheck via turbo)bun test test/provider/transform.test.ts— 255 pass, 0 fail (7 new tests added)Tests added:
$refwith$defs$refreferences$ref$refdefinitions(legacy format)$reffor non-DeepSeek providers$refin array itemsScreenshots / recordings
N/A — non-UI change.
Checklist