Skip to content

fix(provider): avoid incompatible GPT-5 defaults and sanitize Gemini tool schemas#18915

Open
Haohao-end wants to merge 1 commit intoanomalyco:devfrom
Haohao-end:fix/opencode-18882-openai-compatible-gpt5-gemini-schema
Open

fix(provider): avoid incompatible GPT-5 defaults and sanitize Gemini tool schemas#18915
Haohao-end wants to merge 1 commit intoanomalyco:devfrom
Haohao-end:fix/opencode-18882-openai-compatible-gpt5-gemini-schema

Conversation

@Haohao-end
Copy link
Copy Markdown

@Haohao-end Haohao-end commented Mar 24, 2026

Issue for this PR

Closes #18882

Type of change

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

What does this PR do?

This fixes two compatibility problems from #18882.

ProviderTransform.options() was applying GPT-5 default request fields too broadly based on the model ID. That caused generic @ai-sdk/openai-compatible providers or proxies using models like gpt-5.4 to receive fields such as reasoningSummary, reasoningEffort, textVerbosity, and include, even when the backend did not support them. This change limits those defaults to transports/providers that explicitly support them.

This PR also tightens Gemini tool schema sanitization. The Gemini schema path now inlines local refs and recursively removes unsupported keys such as $schema, additionalProperties, $ref, ref, $defs, and definitions. Structured output now reuses the same sanitization path so it does not bypass the Gemini-specific cleanup.

How did you verify your code works?

I added regression tests covering:

  • generic @ai-sdk/openai-compatible gpt-5.4 models no longer receiving OpenAI-only defaults
  • opencode* GPT-5 providers still keeping supported defaults
  • recursive Gemini schema sanitization, including local ref inlining
  • structured output using the same Gemini schema sanitization path

I also ran:

  • git diff --check
  • cd packages/opencode && bun run typecheck
  • bunx turbo typecheck

Screenshots / recordings

Not a UI change.

Checklist

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

If you do not follow this template your PR will be automatically rejected.

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 24, 2026
@Haohao-end Haohao-end force-pushed the fix/opencode-18882-openai-compatible-gpt5-gemini-schema branch from cd702f5 to b9d0041 Compare March 24, 2026 10:11
@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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.

GPT5.4 Error: Unknown parameter: 'reasoningSummary', Gemini3.1 Error: Invalid JSON payload received. Unknown name "$schema" at

1 participant