jcode icon indicating copy to clipboard operation
jcode copied to clipboard

OpenAI provider rejects the whole tool catalog when an MCP property has no type keyword (cua-driver set_config.value)

Open dariuscorvus opened this issue 4 months ago • 2 comments

Summary

An MCP tool property with a description but no type keyword at all makes OpenAI reject the entire function-tool catalog, so every spawned OpenAI-route agent dies on its first turn.

invalid_request_error (invalid_function_parameters): Invalid schema for
function 'mcp__cua-computer-use__set_config': ...

This is the same class as #446 (missing properties), #543/#551 (format: "uri"), and #687 (uniqueItems): a construct that is valid JSON Schema, accepted by Anthropic, rejected by OpenAI's narrower subset, and fatal to the whole catalog rather than the one tool. It may overlap with the branch in #711 — see "Relationship to #711" below.

Trigger

cua-driver's set_config tool declares a value property with no type:

"value": {
  "description": "New value for `key`. JSON type depends on the key."
}

The omission is deliberate upstream. set_config accepts a {key, value} pair where value's JSON type depends on which key is being written (max_image_dimension is an integer, capture_scope a string, experimental_pip a boolean). There is no single correct type, so the server omits the keyword rather than lying. That is legal JSON Schema — an empty schema accepts any instance.

Not fixed by updating the server: reproduced on cua-driver 0.7.1, then again on 0.14.2 after upgrading. The schema is unchanged across seven minor versions.

Environment

  • jcode v0.64.2 (6c6fbba1c)
  • Provider: OpenAI, model gpt-5.5, spawned via swarm spawn
  • MCP server: cua-driver mcp (0.7.1 and 0.14.2, both affected)
  • macOS, aarch64

Reproduction

  1. Configure cua-driver in ~/.jcode/mcp.json:
    "cua-computer-use": {
      "command": "~/.local/bin/cua-driver",
      "args": ["mcp"],
      "shared": true
    }
    
  2. Spawn any OpenAI-route agent: swarm spawn with model: "gpt-5.5".

The agent fails on its first turn. Anthropic-route agents against the same catalog work fine.

Minimal reproducing schema

{
  "type": "object",
  "properties": {
    "key":   { "type": "string" },
    "value": { "description": "JSON type depends on the key." }
  }
}

Scope of the trigger in practice

Scanning every tool across all connected MCP servers on this machine, exactly one property is untyped — this one. It is rare, but one occurrence disables the OpenAI provider entirely.

Relationship to #711

The branch in #711 hardens strict eligibility against "constraint-only/untyped combinator branches, direct untyped enums, boolean schemas". Those are untyped branches inside a combinator. This report is a plain untyped property at the top level of properties, with no anyOf/enum involved, so it may or may not be covered. Worth checking that branch against the minimal schema above before treating this as a separate fix.

Suggested fix

  • In the OpenAI schema compatibility pass (openai_compatible_schema, crates/jcode-provider-core/src/openai_schema.rs), treat a property carrying no type keyword — no type, $ref, anyOf/oneOf/allOf, enum, or const — as ineligible for strict mode, or give it an explicit permissive type.
  • Add a regression test using the minimal schema above.
  • The recurring pattern across #446, #543, #687, and this report suggests the durable fix is an explicit allow-list of the OpenAI-supported keyword subset plus a normalization pass, rather than adding a case each time a new construct is found in the wild. #687 raised the same suggestion.

Secondary issue: the failure is nearly silent

Both spawned agents sat in swarm list as failed with the API error tucked into a status line. Nothing surfaced to the coordinator at the moment of failure. Two agents were dead for five minutes and would have stayed dead indefinitely; I noticed only because I happened to re-check before restarting them for an unrelated reason.

A spawned agent that dies on its first turn without producing a single tool call is a distinct, detectable condition. It is worth surfacing to the coordinator directly rather than leaving it to be discovered by polling — especially since the failure is catalog-wide and deterministic, so every sibling agent on the same route is dead too.

dariuscorvus avatar Aug 01 '26 16:08 dariuscorvus

Fixed. Root cause: set_config declares value with only a description, no type keyword (its shape depends on key). build_tools wrapped it into a strict schema's anyOf for nullability, producing an anyOf branch with no type key. OpenAI rejects the whole tool catalog for that, not just the one tool, so any session with an MCP server exposing an untyped property failed outright on OpenAI.

schema_supports_strict now also rejects an object schema if any of its properties lack type info (type, enum, const, $ref, anyOf, oneOf, allOf, properties, or items). Those tools fall back to strict: false with the untouched compatible schema instead of being force-normalized into an invalid strict variant.

Commit: https://github.com/dariuscorvus/jcode/commit/27eef20 Branch: https://github.com/dariuscorvus/jcode/tree/fix-713-openai-untyped-schema (can't open a PR against master directly, upstream restricts PRs to collaborators)

Verified end-to-end: reproduced live with a spawned gpt-5.5 subagent on the pre-fix binary (invalid_function_parameters), then confirmed the fixed build resolves it with the same repro.

dariuscorvus avatar Aug 01 '26 23:08 dariuscorvus

Thanks for the fix and for the clear framing of the defect class.

Agreed on the analysis: an untyped property is legal JSON Schema, set_config omits the type honestly rather than lying about it, and OpenAI rejecting the entire catalog for one tool is the part that turns a minor incompatibility into a session-killer.

Routing this to a maintainer rather than auto-merging, for two reasons:

  1. It overlaps materially with the branch in #711, which hardens the same schema_supports_strict path for constraint-only and enum-only anyOf branches, untyped enums, boolean schemas, unresolved refs, and untyped array items. Landing both independently risks conflicting or redundant logic. These probably want to be reconciled into one change.
  2. Loosening strict-mode eligibility is a deliberate trade (schema validation strength vs catalog survivability), which is a judgement call rather than a mechanical fix.

Labeled recurring-theme: with #446, #543, #551, #687 and now this, the pattern is clearly "OpenAI's strict subset is narrower than JSON Schema, and one bad tool kills the whole catalog". The general fix is arguably to make catalog building fail per tool instead of all-or-nothing, so a single incompatible MCP tool degrades to being unavailable rather than taking every other tool down with it. Worth considering alongside the targeted fix.

Your branch is recorded here and linked for whoever picks this up.

--- — Jcode agent (automated triage), on behalf of @1jehuang

1jehuang avatar Aug 02 '26 10:08 1jehuang