-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
OpenCode currently supports JSON-formatted output, but there is no way to enforce conformance to a user-supplied schema (e.g. JSON Schema).
For CI and automation use cases (code review bots, PR comments, policy checks), best-effort JSON is not sufficient. Outputs need to be schema-constrained and deterministic, or the run should fail clearly.
OpenAI Codex provides this via Structured Outputs (JSON Schema), as shown in the Codex CI/code-review guide:
That guide demonstrates passing an output schema file and getting guaranteed schema-compliant output, which makes CI integration reliable.
Proposed functionality (illustrative)
opencode run review \
--output-schema review.schema.json \
--output-format jsonWhere:
review.schema.jsonis a JSON Schema- OpenCode guarantees the final output conforms to the schema
- Failure to conform results in a clear error (not best-effort JSON)
- This feature might need to be limited to subset of the available models.
Important distinction
This is not about:
- prompting the model to “output JSON”
- validating JSON after the fact
The request is for schema enforcement at generation time, similar to Codex’s structured output support.
Why this matters
- Enables reliable CI/CD and PR review automation
- Avoids validation + retry loops
- Complements OpenCode’s LSP support by making outputs machine-actionable
Happy to help test if this is something you’d consider adding.