Skip to content

fix(provider): inline openai-compatible tool refs#29295

Open
YOMXXX wants to merge 1 commit into
anomalyco:devfrom
YOMXXX:fix/mcp-openai-compatible-tool-ref-schema
Open

fix(provider): inline openai-compatible tool refs#29295
YOMXXX wants to merge 1 commit into
anomalyco:devfrom
YOMXXX:fix/mcp-openai-compatible-tool-ref-schema

Conversation

@YOMXXX
Copy link
Copy Markdown

@YOMXXX YOMXXX commented May 26, 2026

Issue for this PR

Closes #29220

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Custom OpenAI-compatible providers can fail while resolving MCP tool schemas that contain local $ref values, especially recursive schemas from tools like Canva. This change inlines local JSON Schema refs for @ai-sdk/openai-compatible tool schemas before they reach the provider layer. Recursive local refs are replaced with permissive {} nodes to avoid infinite expansion while still preserving the non-recursive shape of the tool schema.

The transform is scoped to OpenAI-compatible providers so native provider behavior is unchanged.

How did you verify your code works?

  • bun test test/provider/transform.test.ts -t "openai-compatible local refs"
  • bun test test/provider/transform.test.ts
  • bun typecheck
  • PATH="$HOME/.bun/bin:$PATH" .husky/pre-push

Screenshots / recordings

Not applicable; provider schema transform only.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

ghost commented May 26, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error resolving schema reference '$ref' in Canva MCP tool when using custom API provider

1 participant