Skip to content

fix(ai-providers): rewrite const schema literals as enum for Cloud Code Assist - #905

Open
JS-banana wants to merge 1 commit into
openpi-dev:mainfrom
JS-banana:fix/antigravity-const-schema-minimal
Open

JS-banana wants to merge 1 commit into
openpi-dev:mainfrom
JS-banana:fix/antigravity-const-schema-minimal

Conversation

@JS-banana

Copy link
Copy Markdown
Contributor

Problem

Since #652 (first released in v0.10.0), every Antigravity request fails with a 400 as soon as a session loads a tool whose TypeBox schema contains a literal union — subagent_check's evidence parameter being the in-tree instance (Type.Union([Type.Literal("transcript"), ...]), serialized as anyOf branches carrying "const"). Cloud Code Assist validates function declarations against OpenAPI 3.0, which has no const, and protojson rejects the whole request:

Error: Cloud Code Assist API error (400): Invalid JSON payload received.
Unknown name "const" at
'request.tools[0].function_declarations[8].parameters.properties[2].value.any_of[0]': Cannot find field.

This affects every google-antigravity user on v0.10.0–v1.1.0 with the subagents extension loaded (i.e. the default surface). Setup's role/browser literal unions trigger the same 400 when that extension's tools are registered. No issue exists for it yet; the verbatim error above is included so it is searchable.

Value

Restores Antigravity usability for all affected users; the fix is contained in the provider's existing schema sanitizer rather than requiring schema changes in every extension that uses literal unions.

Approach

sanitizeSchemaForCca already strips OpenAPI-rejected keywords on the wire path shared by the Gemini and Claude routes (buildTools); this adds a rewrite of const: X into a single-value enum: [X], merging with any sibling enum without duplicates. enum is proven accepted: enum-carrying parameters (subagent_spawn.agent_type, intercom.action) pass in the exact payloads that 400 on const. The advertised value set is unchanged, so the model-visible semantics are identical.

Relates to #465 (same sanitizer, adjacent failure class — does not address the $ref drop described there).

Validation

  • node --test --experimental-strip-types tests/extensions/ai-providers/antigravity.test.ts: all pass, including new cases for anyOf-branch literals, enum merging, and a property named const.
  • Live A/B against google-antigravity/gemini-3.8-flash-high with pi -ne -a -e ./extensions/ai-providers/index.ts -e ./extensions/subagents/index.ts -p "Reply with exactly: OK": before (main@ea4dfb99) reproduces the verbatim 400; after, the model replies OK.
  • bun run check: clean (biome format/lint, tsc --noEmit).
  • Full suite (node scripts/run-tests.mjs): 2 failures in tests/extensions/code-mode/index.test.ts that fail identically on clean main (pre-existing, unrelated).

Impact

Model-visible context/tools: subagent_check.evidence is now advertised as anyOf of singleton enum branches instead of const literals — the same value set. No user-visible, config, persistence, or lifecycle change. Out-of-tree tools carrying const schemas stop 400ing the session.

…de Assist

TypeBox serializes Type.Union([Type.Literal(...)]) tool parameters as
anyOf branches carrying "const". Cloud Code Assist validates function
declarations against OpenAPI 3.0, which has no "const", so every request
from a session with such a tool 400s with "Unknown name \"const\" at
...parameters.properties[N].value.any_of[M]" (e.g. subagent_check.evidence
since openpi-dev#652; setup's role/browser unions are affected too). enum-carrying
parameters in the same payload pass, so rewrite const to a single-value
enum in sanitizeSchemaForCca instead of dropping the constraint.

Verified live: pi -ne -a -e ai-providers -e subagents against
google-antigravity/gemini-3.8-flash-high 400s before, replies after the
rewrite; broader load with workflows+setup passes as well. Unit tests
cover anyOf-branch literals, enum merging, and a property named const.

This branch has not been deployed

No deployments
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