anomalyco / anomalyco/opencode
[Bug] Console Go gateway rejects OpenAI-compatible client metadata with `extra inputs are not permitted` (strict schema, extra="forbid")
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- Avg merge
- 7h 2m
- Merged PRs (30d)
- 384
Description
Description
Describe the bug
The OpenCode "Console Go" API gateway (https://opencode.ai/zen/go/v1) validates the messages array with a strict schema (pydantic extra="forbid" behavior). Any non-standard field attached to a message is rejected with HTTP 400:
[invalid_request_error] Extra inputs are not permitted, field: 'messages[1].agent', value: 'cli'
This breaks interoperability with OpenAI-compatible clients that attach extra metadata to messages (e.g. agent, reasoning, messageId, model, traceId, usage, extra_fields, etc.). Standard OpenAI-compatible behavior is to ignore unknown fields, not reject them.
To Reproduce
Send a minimal chat completion, then the same request with one extra field:
# 1) Clean payload -> HTTP 200 (model, key, format all fine)
curl https://opencode.ai/zen/go/v1/chat/completions \
-H "Authorization: Bearer $OPENCODE_KEY" -H "Content-Type: application/json" \
-d '{"model":"glm-5.2","messages":[{"role":"user","content":"hi"}],"max_tokens":16,"stream":false}'
# 2) Same request + one extra field on a message -> HTTP 400
curl https://opencode.ai/zen/go/v1/chat/completions \
-H "Authorization: Bearer $OPENCODE_KEY" -H "Content-Type: application/json" \
-d '{"model":"glm-5.2","messages":[{"role":"user","content":"hi"},{"role":"assistant","content":"hello","agent":"cli"}],"max_tokens":16,"stream":false}'
# -> 400 {"error":{"message":"Error from provider (Console Go): ... Extra inputs are not permitted, field: 'messages[1].agent', value: 'cli'"}}
Expected behavior
OpenAI-compatible endpoints should tolerate and ignore unknown message fields, so clients that attach metadata (agent ids, tracing, reasoning flags) keep working. The request in step 2 should return 200 like step 1.
Actual behavior
HTTP 400 with Extra inputs are not permitted for any non-standard field on any message.
Environment
- Gateway:
https://opencode.ai/zen/go/v1(Console Go) - Model:
glm-5.2 - Client: WorkBuddy App 5.3.13 (sends requests via its backend, which attaches internal metadata fields)
- Observed on: macOS
Suggested fix
Relax the messages / message schema at the Console Go gateway to extra="allow" (ignore unknown fields), matching standard OpenAI-compatible server behavior. Optionally document which fields are required vs optional.
Additional context
This is not specific to one client — any OpenAI-compatible proxy/agent that forwards internal metadata will hit the same 400. A clean payload works perfectly (step 1 returns valid reasoning_content too), confirming auth + model + base format are correct; only the strict schema blocks it.
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the two curl requests against the Console Go gateway at https://opencode.ai/zen/go/v1 and determine whether its message schema is implemented in this repository. Trace the gateway's message validation and add coverage for an unknown message field; done means the metadata-bearing request is accepted without the existing HTTP 400 error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100