feat(command): add noReply flag to skip LLM dispatch#28763
Open
Svtter wants to merge 3 commits into
Open
Conversation
…s directly When a command is configured with `noReply: true`, the LLM round-trip is skipped entirely. The hook-modified parts are written as a completed assistant message so they render immediately in the TUI without any token cost or latency. This enables plugins like opencode-review to register instant toggle commands (e.g. `/review:auto on/off`) that execute purely locally via the `command.execute.before` hook. Closes anomalyco#28292 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
3 tasks
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Related PR Found:PR #27521: feat(command): add noReply flag to skip LLM dispatch for display-only commands Why they're related: |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Related to #28292, #5305, #26022. Builds on the schema approach from #27521.
Type of change
What does this PR do?
Adds a
noReplyboolean flag to the command schema. Whentrue, the LLM round-trip is skipped entirely and hook-modified parts are written as a completed assistant message so they render immediately in the TUI.Problem: Plugins like opencode-review register toggle commands (
/review:auto on/off) that just flip a boolean. Currently this requires a full LLM agent round-trip — wasting tokens and adding latency for an instant operation. Thecommand.execute.beforehook can intercept the command but cannot skip the LLM call.Changes:
config/command.tsnoReplyto command config schemacommand/index.tsnoReplyto command registry schema + pass throughsession/prompt.tsnoReplyfromcommand()toprompt(); when set, create assistant message with parts directly (no LLM)test/session/prompt.test.tsnoReply command skips LLM and creates assistant message with partsDifferences from PR #27521: That PR added the
noReplyschema but when it short-circuited the LLM, the command's parts silently disappeared. This PR also creates a visible assistant message in the TUI so the user sees the result.Usage — command config (
.opencode/commands/test.md):Or via plugin config hook:
Combined with
command.execute.beforehook:How did you verify your code works?
bun run typecheckpasses (15/15 packages)noReply command skips LLM and creates assistant message with partsopencode run --command test -- "hello"exits instantly, no LLM call/review:auto offskips LLM, toggles state via hookScreenshots / recordings
N/A (session/prompt behavior change, no TUI layout change)
Checklist
🤖 Generated with Claude Code