Skip to content

[FEATURE]: schema-constrained structured outputs (JSON Schema), similar to Codex #10456

Closed

Description

@siggi84

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 json

Where:

  • review.schema.json is 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.

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Jan 24, 2026
  2. github-actions commented on Jan 24, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  3. siggi84 commented on Jan 24, 2026

    @siggi84
    Author

    I see now that this might be covered by this issue and pr: #9320

  4. github-actions commented on Mar 27, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  5. added 8 commits that reference this issue on Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions