anomalyco / anomalyco/opencode

Agent config extra fields are forwarded verbatim into upstream provider requests, causing invalid_request_error

Open
#49,027 3 comments 0 reactions 1 assignee View on GitHub

@MrMushrooooom is already working on this.

Since Sep 14, 2026.

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

Description

Environment

  • opencode-ai: 1.18.31 (latest at time of filing)
  • OS: Windows 11
  • Provider: opencode-go (Zen gateway, https://opencode.ai/zen/go)
  • Model tested: opencode-go/kimi-k3 (also reproduces with glm-5.3, gpt-5.6-luna, glm-5.3-flash)

Description

Any custom/vendor property added at the top level of an agent entry in opencode.jsonc (e.g. agent.<name>.__managed_by) ends up serialized into the outbound request body sent to the model provider. When the upstream endpoint validates the request strictly (rejecting unknown fields), the whole call fails — even though the extra key is agent metadata, not a message/tool/model parameter.

The public config schema (https://opencode.ai/config.json) does not restrict additional properties on AgentConfig (no additionalProperties: false), so nothing in the schema suggests this field is unsafe to add. The request builder should not forward config keys it doesn't recognize.

Steps to reproduce

  1. Add an arbitrary extra key to any agent definition in opencode.jsonc:
    "agent": {
      "explore": {
        "__managed_by": "some-tool",
        "description": "...",
        "mode": "subagent",
        "model": "opencode-go/kimi-k3"
      }
    }
    
  2. Invoke that agent (or have opencode dispatch a task to it).
  3. Observe the request fails before reaching the model.

Expected behavior

Custom/unrecognized top-level properties on an agent definition are ignored when building the provider request.

Actual behavior

Error from provider (Console Go): Upstream request failed: [invalid_request_error] Extra inputs are not permitted, field: '__managed_by', value: 'gentle-ai/sdd'

Suspected root cause

The request serialization path for at least the opencode-go provider appears to spread the agent config object into the upstream request payload instead of picking only known fields.

Suggested fix

Allowlist the fields forwarded to the provider request body when building it from AgentConfig, so config-level metadata never leaks onto the wire.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.