fix(pi-stack): replace Type.Union/Literal with Type.String for JSON Schema 2020-12 compat#6
Open
chico-piaba wants to merge 1 commit intoaretw0:mainfrom
Open
Conversation
…chema 2020-12 compat
Type.Union([Type.Literal(...)]) generates anyOf+const schemas that are
incompatible with OpenAPI 3.03 (used by Cloud Code Assist for Claude
models via google-antigravity provider).
This caused a 400 error on claude-opus-4-6-thinking:
tools.N.custom.input_schema: JSON schema is invalid.
It must match JSON Schema draft 2020-12.
Replaced with Type.String({ description }) which is universally
compatible across all providers and schema formats.
Affected extensions:
- session-analytics.ts (query_type field)
- governance-profiles.ts (action field)
- safe-boot.ts (action field)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When using
claude-opus-4-6-thinkingvia thegoogle-antigravityprovider, the pi agent returns:Root Cause
Three pi-stack extensions used
Type.Union([Type.Literal(...)])from@sinclair/typeboxto define string enum parameters. This generatesanyOf+constschemas.The
google-antigravityprovider routes Claude models through Cloud Code Assist using the legacyparametersfield (OpenAPI 3.03 Schema), which does not supportanyOf+constpatterns. ThesanitizeSchemaForAntigravity()function convertsconst→enum, but the outeranyOfwrapper remains invalid.Serialization chain
Fix
Replaced
Type.Union([Type.Literal(...)])withType.String({ description: "..." })which is universally compatible across all providers and schema formats.Files changed
session-analytics.tsquery_typeType.Union([Type.Literal(...)])Type.String()governance-profiles.tsactionType.Union([Type.Literal(...)])Type.String()safe-boot.tsactionType.Union([Type.Literal(...)])Type.String()Testing
Type.Union/Type.Literalpatterns in pi-stack extensionsexecute()is unchangedPrevention
For future tool schemas, prefer:
Type.String({ description: "a | b | c" })— universally safeStringEnum([...] as const)— generates{ type: "string", enum: [...] }Type.Union([Type.Literal(...)])— generates incompatibleanyOf+const