fix(question): reject empty questions array instead of hanging - #41597
Open
ousamabenyounes wants to merge 1 commit into
Open
fix(question): reject empty questions array instead of hanging#41597ousamabenyounes wants to merge 1 commit into
ousamabenyounes wants to merge 1 commit into
Conversation
Both Question.ask (v1) and QuestionV2.ask registered a pending request for an empty questions array, leaving nothing to render or answer so the session waited indefinitely. Fail fast before registering the pending deferred, on both the existing question tool and the V2 core question tool paths. Closes anomalyco#41549
avion23
pushed a commit
to avion23/opencode
that referenced
this pull request
Aug 10, 2026
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 #41549
Type of change
What does this PR do?
The question tool accepted an empty
questionsarray.Question.askthenregistered a pending request that had nothing to render or answer, so the
session waited indefinitely. This happened on both the v1 question tool and the
V2 core question tool, which share the same "register a pending deferred" shape.
The fix rejects an empty
questionsarray up front, before a pending request isregistered, in both
Question.ask(packages/opencode/src/question/index.ts)and
QuestionV2.ask(packages/core/src/question.ts). Both tool call sitesalready
.pipe(Effect.orDie)the result ofask, so failing here ends the turnthe same way a dismissed question already does — instead of hanging forever.
How did you verify your code works?
Added a test at each
asklayer that asks with an emptyquestionsarray,bounds the call with a timeout, and asserts it fails fast (and registers no
pending request) rather than hanging:
packages/opencode/test/question/question.test.tspackages/core/test/question.test.tsRED (before the fix): the call hangs and only the timeout fires, so the failure
cause does not contain the guard message. GREEN (after the fix): it fails
immediately with
... requires at least one question.Local runs (baseline → with fix):
packages/opencodequestion tests: 16 → 17 pass, 0 failpackages/corequestion tests: 7 → 8 pass, 0 failbun typecheckfor thecoreandopencodepackages: passChecklist