fix(provider): expand $ref/$defs for DeepSeek compatibility - #32955
fix(provider): expand $ref/$defs for DeepSeek compatibility#32955lexlian 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
|
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.
|
same issue here. how do we get it merged? |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
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