Skip to content

[FEATURE]: support JSON schema as a constrain of opencode run command #9320

Closed as not planned

Description

@richardanaya

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

Support for new --json on opencode run command similar to llama.cpp cli

'''
opencode run -m opencode/grok-code --json '{"type":"object","properties":{"colors":{"type":"array","items":{"type":"string"}}},"required":["colors"]}' "make 3 colors"
'''

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Jan 19, 2026
  2. github-actions commented on Jan 19, 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. laygir commented on Mar 10, 2026

    @laygir

    Arrived here looking for equivalent of following but for Opencode to run on the pipeline for code review. (also allowedTools)

    claude -p "$PROMPT" \
      --allowedTools "Read(*),Grep(*),Bash(git diff *),Bash(git log *)" \
      --output-format json \
      --json-schema "$REVIEW_SCHEMA" \
      --max-turns 20
  4. removed
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on May 3, 2026
  5. trevorWieland commented on May 27, 2026

    @trevorWieland

    Picking this up. The server/SDK already supports it — session.prompt accepts format: { type: "json_schema", schema, retryCount? } and the v2 SDK exposes it on the typed body (@opencode-ai/sdk/v2). The gap is the CLI surface; today opencode run --format json only controls the event stream shape, not the model's output contract.

    Prior attempt #17276 stalled with no review and is stale against the current effectCmd structure of run.ts.

    Proposed surface (mirrors codex exec --output-schema / claude -p --json-schema):

    opencode run "extract function names from auth.py" --output-schema ./schema.json

    --output-schema accepts a path to a .json file or an inline JSON string. The structured JSON is written to stdout.

    Would be happy to submit a PR for this if the direction's right.

  6. github-actions commented on Jul 27, 2026

    @github-actions
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions