anomalyco / anomalyco/opencode

OpenCode Go rejects Codex tool schemas with a root-level oneOf

Open
#41,110 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

When OpenCode Go is configured as an OpenAI-compatible custom provider in Codex (ChatGPT Desktop), requests that include the built-in automation_update function fail during tool-schema validation, before model inference starts.

The emitted function.parameters is a JSON Schema with a root-level $defs and oneOf. Every branch is an object schema, but the parameters schema itself has no top-level type. OpenCode Go / Console Go rejects this shape and requires tools[].function.parameters.type to be "object".

Steps to Reproduce

  1. Configure https://opencode.ai/zen/go/v1 as an OpenAI-compatible custom provider in Codex / ChatGPT Desktop.
  2. Send a non-streaming chat completion request to /v1/chat/completions using deepseek-v4-flash and the following tool schema.
  3. Use an OpenCode Go API key in the Authorization header.
export OPENCODE_GO_API_KEY='REDACTED'
curl -sS https://opencode.ai/zen/go/v1/chat/completions \
  -H "Authorization: Bearer ${OPENCODE_GO_API_KEY}" \
  -H 'Content-Type: application/json' \
  --data-binary @request.json

request.json:

{
  "model": "deepseek-v4-flash",
  "messages": [
    {"role": "user", "content": "schema compatibility probe"}
  ],
  "stream": false,
  "tool_choice": "auto",
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "automation_update",
        "description": "Create, update, view, or delete recurring automations.",
        "parameters": {
          "$defs": {
            "stringValue": {"type": "string"}
          },
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "mode": {"type": "string", "enum": ["view"]},
                "id": {"$ref": "#/$defs/stringValue"}
              },
              "required": ["mode", "id"]
            },
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "mode": {"type": "string", "enum": ["delete"]},
                "id": {"$ref": "#/$defs/stringValue"}
              },
              "required": ["mode", "id"]
            }
          ]
        }
      }
    }
  ]
}

Expected Behavior

The provider should accept a root-level oneOf when its branches are object schemas, or document the supported subset and provide a compatible normalization path.

Actual Behavior

The request is rejected with HTTP 400 before inference:

Error from provider (Console Go): Upstream request failed:
[invalid_request_error] Invalid schema for function 'automation_update':
schema must be a JSON Schema of 'type: "object"', got 'type: null'.

Adding only this property to function.parameters:

"type": "object"

made the same minimal request return HTTP 200 for both deepseek-v4-flash and kimi-k3.

Environment

  • Client: Codex / ChatGPT Desktop
  • Provider: OpenCode Go
  • Endpoint: https://opencode.ai/zen/go/v1/chat/completions
  • Models tested: deepseek-v4-flash, kimi-k3
  • Protocol: OpenAI-compatible Chat Completions

Additional Context

The full automation_update schema emitted by Codex has the same root shape ($defs plus oneOf) as the reduced reproduction above. The failure is independent of thinking/reasoning settings and occurs during tool-schema validation, before model inference.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the /v1/chat/completions request path and reproduce the failure with the request.json schema shown in the issue, tracing where function.parameters is validated or normalized. Done means the root-level oneOf schema with object branches is accepted, or the supported subset and a compatible normalization path are clearly documented and covered by a regression check.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.