Skip to content

fix: remove allOf/anyOf/const/if/then from tool schemas for provider compat#248

Open
sergio-agosti wants to merge 1 commit into
nicobailon:mainfrom
sergio-agosti:fix/kimi-json-schema-compat
Open

fix: remove allOf/anyOf/const/if/then from tool schemas for provider compat#248
sergio-agosti wants to merge 1 commit into
nicobailon:mainfrom
sergio-agosti:fix/kimi-json-schema-compat

Conversation

@sergio-agosti
Copy link
Copy Markdown

@sergio-agosti sergio-agosti commented Jun 3, 2026

Problem

Providers with limited JSON Schema support (kimi/Moonshot, Antigravity proxy, and potentially others) reject the subagent tool registration because the parameter schema contains keywords not supported by their minimal JSON Schema parsers:

  • AcceptanceOverride: Uses anyOf with 3 alternatives (string enum, const: false, nested object with nested anyOf in criteria.items and review)
  • ChainItem: Uses allOf with if/then/not conditional constraints

kimi returns:

Error: 400 Error from provider: JSON Schema not supported: could not understand the instance {required: [criteria]}

then:

Error: 400 Error from provider: Conflict in schema definitions for key if. Previous: {required: [expand]}, New: {required: [collect]}

Antigravity proxy (Google Cloud Code Assist): same class of error with anyOf/const (previously noted in CHANGELOG).

Fix

Two changes in src/extension/schemas.ts:

1. AcceptanceOverride — no anyOf/allOf/const keywords

Before After
Top-level anyOf with 3 alternatives (string, const: false, object) type: ["string", "boolean", "object"] — same expressiveness, basic JSON Schema
criteria.items.anyOf with string/AcceptanceGateSchema type: ["string", "object"] with inline properties (id, must, evidence, severity) and required: ["id", "must"]
review.anyOf with const: false / AcceptaceReviewGateSchema type: ["boolean", "object"] with inline properties (agent, focus, required)

All field-level type constraints are preservedverify must be array, stopRules must be array, criteria items must be string or object with id+must, etc. A malformed input like { verify: "npm test" } still fails schema validation because verify.type is "array".

2. ChainItem — remove allOf with if/then/not

Replace the conditional schema (expand requires parallel+collect, collect requires expand+parallel, expand without parallel type=array) with additionalProperties: true. The expand/collect/parallel conditional logic is enforced by runtime execution code.

Verification

  • Tested with kimi (moonshot/kimi-k2.6) via OpenCode Go subscription: subagent() calls with acceptance blocks work without 400 errors
  • Structural validation preserved: malformed acceptance objects (wrong types) still rejected by schema
  • All runtime validation paths (validateAcceptanceInput(), normalizeAcceptanceInput()) unchanged
  • No allOf/anyOf/const/if/then/not in AcceptanceOverride or ChainItem schemas

Related

  • CHANGELOG previously noted anyOf/const issues with Antigravity proxy
  • This extends the fix to cover allOf/if/then/not keywords and applies to the acceptance schema

Copy link
Copy Markdown

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

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: 6d376e06bc

ℹ️ 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".

Comment thread src/extension/schemas.ts Outdated
Comment on lines +85 to +86
type: ["string", "boolean", "object"],
additionalProperties: true,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restore validation for acceptance object fields

For direct tool calls, this relaxed schema is the only validation gate; validateAcceptanceInput() is only used when loading saved JSON chains, not before SubagentParams are executed. With acceptance now accepting any object, inputs such as acceptance: { level: "verified", verify: "npm test" } pass the tool schema and later reach formatAcceptancePrompt()/evaluateAcceptance(), which assume verify is an array and eventually call spawn(command.command) on characters from the string, causing the run to fail/crash instead of returning a validation error. The previous schema rejected these malformed objects, so either keep object field constraints without unsupported keywords or invoke the runtime validator on all tool params before execution.

Useful? React with 👍 / 👎.

… provider compat

kimi/Moonshot and other providers (e.g. Antigravity proxy) do not
support allOf, anyOf, const, if/then/not keywords in JSON Schema for
tool function.parameters. This caused 400 errors when the subagent
tool was registered with providers that only implement a minimal
JSON Schema subset.

Changes:
- AcceptanceOverride: replace top-level anyOf (string/false/object)
  with type: [string, boolean, object]. Replace criteria.items.anyOf
  with type: [string, object]. Replace review.anyOf (const: false /
  object) with type: [boolean, object]. Inline sub-schemas so no
  anyOf/allOf/const keywords remain anywhere in the schema.
  All field-level type constraints (verify must be array, criteria
  items must be string|object, stopRules must be array) are preserved.
- ChainItem: remove allOf with if/then/not conditional constraints,
  use additionalProperties: true.

All removed constraints that lacked a runtime equivalent are now
enforced by the JSON Schema itself using only basic keywords
(type, properties, required, items, enum, additionalProperties).
@sergio-agosti sergio-agosti force-pushed the fix/kimi-json-schema-compat branch from 6d376e0 to 7b65bab Compare June 3, 2026 12:16
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