Repository navigation
feat(opencode): allow skipping the agent turn after a command - #46579
Closed
renaudcerrato wants to merge 1 commit into
Closed
renaudcerrato wants to merge 1 commit into
renaudcerrato wants to merge 1 commit into
Conversation
Commands always ran an agent loop after execution: CommandInput had no noReply field and the command.execute.before hook could only mutate parts, so neither clients nor plugins could opt out of the LLM turn. prompt() already short-circuits on noReply — it just was not reachable from the command path. Plumb noReply through: - CommandInput gains an optional noReply field (server API callers) - command.execute.before hook output gains a noReply flag (plugins), forwarded to prompt() alongside the client-provided value Semantics are OR: either party can suppress the turn, neither can force a turn the other explicitly declined. This lets text-only commands (config management, toggles, lookups) complete without a wasted LLM call and without the model emitting a spurious reply to an effectively empty user turn. Tests: client noReply skips the loop; hook noReply skips the loop; a hook cannot force a turn the client suppressed. SDK types regenerated, docs updated.
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Member
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
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
Closes #28292 (the
noReplyhalf; custom dialogs are a separate surface)Type of change
What does this PR do?
Slash commands always run an agent LLM turn after execution, even when the command needs no LLM involvement.
prompt()already short-circuits onnoReply(returns the user message without running the loop), but the flag was unreachable from the command path:CommandInputhad nonoReplyfield, and thecommand.execute.beforehook could only mutateparts.This PR plumbs
noReplythrough the command path:CommandInputgains an optionalnoReplyfield, so server API callers (POST /session/:id/command) can skip the turncommand.execute.beforehook output gains anoReplyflag (defaultfalse) that plugins can set, forwarded toprompt()alongside the client-provided valueReal-world usage (from our own plugin and others in #28292):
noReplyfixes the cost./queuecommands entirely locally.ignored: trueparts workaround fails: the turn still fires, still costs tokens, and suppression is probabilistic.How did you verify your code works?
bun run typecheckclean inpackages/opencode,packages/plugin,packages/sdk/jsbun test test/session/prompt.test.ts: 61 pass, 0 fail, including three new tests:noReply: true→ user message returned, zero LLM callsoutput.noReply = trueincommand.execute.before→ same, plus plugin-pushed parts land in the persisted messageoutput.noReply = falsewhile client sentnoReply: true→ turn still skipped (a hook cannot override the client's suppression)noReplyadditions, no unrelated driftScreenshots / recordings
Not a UI change.
Checklist
Critical changes: the
command.execute.beforehook output type changes from{ parts }to{ parts, noReply }— additive; existing plugins that only touchpartsare unaffected (structural typing; runtime always initializesnoReply: false).Command.Event.Executed'smessageIDis the user message whennoReplyis set (vs the assistant message otherwise); noted in the SDK docs row. The only in-repo consumer reads onlydata.nameand is unaffected.