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

@JS-banana JS-banana commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Since #652 (first released in v0.10.0), Antigravity requests fail with HTTP 400 when a loaded tool uses a TypeBox literal union. The in-tree example is subagent_check.evidence: anyOf branches contain const, which Cloud Code Assist rejects:

Invalid JSON payload received. Unknown name "const" at
'request.tools[0].function_declarations[8].parameters.properties[2].value.any_of[0]'

Setup role/browser literal unions expose the same failure. Related to #465 (the adjacent $ref problem, which this PR does not resolve).

Value

Restore the existing Antigravity tool path at the provider boundary, without rewriting each extension's schema or bypassing ordinary Pi tools.

Approach

  • Rewrite a schema's const to a singleton enum inside sanitizeSchemaForCca, shared by Gemini and Claude request routes.
  • A sibling enum is an additional constraint: retain only the constant, rather than unioning in other choices. Reject conflicting const/enum constraints locally with a clear error instead of advertising impossible choices.
  • Treat enum values as literal data, preserving object values instead of recursively interpreting their keys as schemas.
  • Preserve parameter names that match schema keywords. No dependency or host-version change.
  • Rebased onto upstream main 0addb73963a924ee6daa5568151cd890b34e2999. Broader sanitization hardening remains in fix(ai-providers): harden CCA schema projection with safe literal handling #906.

Validation

Current head: dba602e9e5ab065699d0fdc3ae217b743bb83053. The 2026-11-03 CI refresh preserves exactly the source tree of ed55c898789168488cc59d7502960f483bae30b9; only commit metadata changed. The local results below were recorded on 2026-11-02 and are reused by identical tree identity, not presented as new local runs.

  • node --test --experimental-strip-types tests/extensions/ai-providers/antigravity.test.ts: 63 passed. The corrected const/enum regression failed before the fix and passes afterward; includes contradictory constraints and structural object equality.
  • bun run check: passed. Existing bundle-size warnings remain.
  • bun run test: Node 2,455 tests, 2,445 passed / 8 skipped / 2 failed. Both failures are in tests/extensions/code-mode/index.test.ts.
  • Baseline control: that exact Code Mode file on a clean detached upstream main@0addb739, using the same locked dependencies, reproduces the same two failures at the same assertions (1 passed / 2 failed). The full suite is therefore not reported as green.
  • bun run test ui: 108 files, 1,632 tests passed (run separately because the normal command stops after Node failures).
  • Real Pi 1.4.0, explicit source loading with -ne -a -e ./extensions/ai-providers/index.ts -e ./extensions/subagents/index.ts, ephemeral Session, built-in tools retained: google-antigravity/gemini-3.8-flash-high returned OK. without the schema 400. Installed npm OpenPI was not loaded into that run.
  • git diff --check: passed.

Historical before/after request evidence in the original report remains historical; the real request does not establish that every literal kind or provider model was live-tested.

Previous-head CI run 41386858096 passed all runtime jobs and Web E2E shards but had one Windows UI 5-second timeout. The integration cannot rerun upstream Actions, so the author refreshed the unchanged branch tip with an explicit expected-SHA lease to request a fresh run. Current-head CI run 41610705003 completed successfully on 2026-11-03: all 17 jobs passed, including Windows UI, runtime, both Web E2E shards, and aggregate gates. No test was skipped, weakened, or given retries to obtain this result.

Impact

  • User-visible: affected string-literal tools no longer cause the const-keyword 400.
  • Model-visible: const becomes a singleton enum with the original allowed value; conflicting const/enum constraints fail locally.
  • Runtime: no new tools, permissions, endpoint route, cache or lifecycle.
  • Persisted config/data: none.
  • Compatibility/risk: no dependency changes. This is not general JSON Schema validation or $ref support; broader wire projection is separately reviewed in fix(ai-providers): harden CCA schema projection with safe literal handling #906.

…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.
@JS-banana
JS-banana force-pushed the fix/antigravity-const-schema-minimal branch from ed55c89 to dba602e Compare November 3, 2026 09:23

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