Skip to content

Conversation

@richardanaya
Copy link

@richardanaya richardanaya commented Jan 19, 2026

Fixes #9320

What does this PR do?

Allows you to constrain run commands output to a specific JSON schema.

  • Inspired by llama.cpp's functionality
  • Utilizes passed in model
  • Throws error if used with "--format json"

How did you verify your code works?

image

@github-actions
Copy link
Contributor

Hey! Your PR title Add support for json schema in opencode run doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found:

feat: support claude agent SDK-style structured outputs in the OpenCode SDK (#8161)

This PR appears related as it deals with structured outputs/schema support, which is similar in scope to the JSON schema constraint feature in PR #9319. Both are about constraining model output to specific formats/schemas.


Possibly Related (Different Scope):

feat: add JSON Schema as source of truth for type definitions (#6987)

This PR also mentions JSON Schema but appears to be focused on using JSON Schema for type definitions rather than runtime output constraints.

@richardanaya richardanaya changed the title Add support for json schema in opencode run Add support for json schema in opencode run --json <json schema> Jan 19, 2026
@richardanaya richardanaya changed the title Add support for json schema in opencode run --json <json schema> Add support for json schema: opencode run --json <json schema> Jan 19, 2026
@richardanaya richardanaya changed the title Add support for json schema: opencode run --json <json schema> Add support for json schema in run command: opencode run --json <json schema> Jan 19, 2026
@richardanaya richardanaya changed the title Add support for json schema in run command: opencode run --json <json schema> feat: Add support for json schema in run command: opencode run --json <json schema> Jan 19, 2026
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant