Skip to content

feat(core): port Kimi MFJS tool-schema projection to V2 #37662

Description

@opencode-agent

Summary

Port the Kimi/Moonshot tool-schema compatibility projection from the V1 implementation in #37625 into the V2 provider/tool request path.

The projection prevents one incompatible built-in, custom, or MCP tool schema from causing Kimi to reject the entire model request.

Design contract

  • The projected schema is availability-oriented and sent only to Kimi-selected models using the accepted provider/family/name heuristic.
  • Preserve schema features accepted by Kimi and adapt only reproduced provider failures.
  • Explicit types remain authoritative.
  • Lossy fallbacks may widen the schema shown to the model but must never narrow valid tool inputs.
  • The original tool schema remains authoritative at execution time.
  • Arguments admitted by the projected schema but rejected by the original schema must become model-visible tool errors so the model can recover.

V1 reference

The V1 work covers enum/type conflicts, untyped and structured enums, tuple and boolean items, typed anyOf, dangling required, local references, recursive termination, and Kimi's observed enum/union/property/size/depth limits. It preserves accepted features such as const, prefixItems, valid type arrays, nullable, composition, and conditionals.

V2 work

  • Identify the V2 boundary where tool JSON Schemas are projected for provider requests without replacing execution-time schemas.
  • Port the projection as a model/provider compatibility module rather than routing through V1 code.
  • Apply it consistently to built-in, plugin/custom, and MCP tools.
  • Preserve the original V2 tool decoder/validator through execution.
  • Surface original-schema validation failures as tool results visible to the model, not fatal provider/session failures.
  • Port the focused unit coverage and generic live compatibility-matrix workflow.

Acceptance criteria

  • Kimi 3, Kimi 2.7 Code, and Kimi 2.6 accept the full projected compatibility matrix in V2.
  • A regression test proves the projection does not narrow a representative set of valid original inputs.
  • An end-to-end test forces a tool call accepted by a widened projection but rejected by the original schema, then verifies the model receives a tool error and can continue.
  • Non-Kimi provider schemas remain unchanged.
  • V2 contains no runtime dependency on packages/opencode.

Requested by: @rekram1-node (Aiden Cline via Slack)

Metadata

Metadata

Assignees

Labels

2.0coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions