Skip to content

fix(antigravity-direct): fold anyOf to oneOf for Claude targets (opencode#1550) - #5110

Merged
dezren39 merged 1 commit into
mainfrom
fix/1550-antigravity-anyof-claude
Nov 3, 2026
Merged

dezren39 merged 1 commit into
mainfrom
fix/1550-antigravity-anyof-claude

Conversation

@dezren39

@dezren39 dezren39 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

What broke

workhorse attempts on antigravity-direct/claude-sonnet-5-5 400'd on a ~30-minute cadence all day 2026-11-03 (route ledger 17:34 / 18:04 / 18:34 / 19:34Z). Upstream error, Anthropic-shaped:

tools.9.custom.input_schema: JSON schema is invalid. It must match JSON Schema draft 2020-12 (https://json-schema.org/draft/2020-12).

Tracked as developing-today-forks/opencode#1550. This is the door half of the fix; the fork twin lands in developing-today/opencode (same title).

Root cause (probed live against the door, 2026-11-03)

For Claude models the upstream re-serializes the v1internal proto Schema into an Anthropic input_schema — and Anthropic's validator rejects anyOf outright: any branch count (even one), any position (root, property, nested in items). Every other probed shape passes on the Claude leaf: no tools, minimal tools, bare array properties, type-array null unions (the converter collapses those to nullable), additionalProperties, inlined $refs, oneOf (2- and 3-branch, object branches), allOf. Gemini models accept anyOf verbatim. Any real tool whose zod schema carries a union (.nullable(), type unions) therefore 400s every Claude attempt while Gemini sails through.

Fix

At the translation boundary only: convertSchema/convertSchemaNode take an anthropic flag (from buildV1Request: the resolved base model starts with claude), and for Anthropic targets anyOf is emitted as oneOf, recursively (properties, items, prefixItems, composition branches, not). A node carrying both keywords merges both branch sets into the single oneOf. Tool unions are disjoint alternatives in practice (type unions, nullable encodings), where exactly-one is the faithful reading, and oneOf is the only union keyword the Anthropic side takes. Gemini conversion is byte-identical to before.

Tests

node --test bin/antigravity-direct.test.mjs — 19/19 (17 pre-existing + 2 new, following the #1548 pattern of asserting on the payload recorded by a stub upstream):

  • Claude: union-shaped tools reach upstream with oneOf everywhere and no anyOf key anywhere in the parameters.
  • Gemini control: the same tools keep anyOf verbatim.

No restructuring, no config changes, no Gemini-path changes.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 3, 2026 20:08
@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 19 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6fa9f6cb-d3ea-465b-8f41-0774ea08a327
Commits

Reviewing files that changed from the base of the PR and between d6bf024 and c9da9f1.

Files selected for processing: 2
  • bin/antigravity-direct.mjs
  • bin/antigravity-direct.test.mjs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T20:11:41.461125Z c9da9f1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 merged commit 32d47f7 into main Nov 3, 2026
1 check passed
@dezren39
dezren39 deleted the fix/1550-antigravity-anyof-claude branch November 3, 2026 20:10

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9da9f16b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// anyOf folds into oneOf for Anthropic targets (see the header
// probe note); a node carrying both keywords merges both branch
// sets into the single oneOf the Anthropic side accepts.
else if (k === 'oneOf' || anthropic) out.oneOf = out.oneOf ? [...out.oneOf, ...branches] : branches;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve conjunction when folding sibling union keywords

For a Claude tool property containing both anyOf and oneOf, concatenating their branches changes the original conjunction into a single exclusive union. For example, if both keywords contain [{type: "string"}, {type: "number"}], the original schema permits strings and numbers, but the emitted four-branch oneOf rejects every value because each valid value matches twice. Preserve the two converted groups separately under allOf, which the upstream accepts, rather than merging their alternatives.

Useful? React with 👍 / 👎.

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.

1 participant