Repository navigation
Conversation
|
The following comment was made by an LLM, it may be inaccurate: POTENTIAL DUPLICATE FOUND: PR #23707 - "fix(provider): sanitize xAI tool schemas for OpenRouter"
Note: PR #23706 is the current PR you're analyzing, so #23707 is a potential duplicate that should be reviewed for consolidation or coordination. |
…i provider Strip additionalProperties: false from tool/input JSON schemas when targeting xAI models via OpenRouter or the native xai provider. xAI rejects this keyword while their validator already defaults to false. Fixes anomalyco#23704
5bd4988 to
c8692ce
Compare
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
1 similar comment
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Closing this PR after extensive investigation. The issue is not fixable at the OpenCode level. Investigation SummaryWe spent significant time debugging why xAI/Grok rejects tool schemas with Root CauseThe Vercel AI SDK intentionally adds xAI's validator explicitly rejects
Why OpenCode Can't Fix This
Where This Needs To Be Fixed
Workarounds
|
1 similar comment
|
Closing this PR after extensive investigation. The issue is not fixable at the OpenCode level. Investigation SummaryWe spent significant time debugging why xAI/Grok rejects tool schemas with Root CauseThe Vercel AI SDK intentionally adds xAI's validator explicitly rejects
Why OpenCode Can't Fix This
Where This Needs To Be Fixed
Workarounds
|
Investigation SummaryAfter extensive debugging, this issue is not fixable at the OpenCode level. Here's what we found: Root CauseThe Vercel AI SDK intentionally adds xAI's validator explicitly rejects
Why OpenCode Can't Fix This
Where This Needs To Be Fixed
Workarounds
|
Issue for this PR
Closes #23704
Type of change
What does this PR do?
Tool calling fails for xAI models (e.g.
grok-4.1-fast) when used through OpenRouter or the nativexaiprovider. The error is:xAI structured output docs state:
additionalPropertiesdefaults tofalsealreadyfalseare rejectedSo the fix strips
additionalProperties: falsefrom tool/input JSON schemas before sending to xAI. This preserves the intended strictness (since false is the default) while avoiding the validator rejection.The change is scoped to:
providerID === "xai"(native xAI provider)providerID === "openrouter"withmodel.api.id.startsWith("x-ai/")(xAI models via OpenRouter)Non-xAI models are unaffected.
How did you verify your code works?
Added unit tests in
packages/opencode/test/provider/transform.test.ts:additionalProperties: falsefor both OpenRouter xAI and native xai providertrueadditionalPropertiesare preservedScreenshots / recordings
N/A — no UI changes.
Checklist