Skip to content

fix(question): reject empty questions array instead of hanging - #41597

Open
ousamabenyounes wants to merge 1 commit into
anomalyco:devfrom
ousamabenyounes:question-empty-guard
Open

fix(question): reject empty questions array instead of hanging#41597
ousamabenyounes wants to merge 1 commit into
anomalyco:devfrom
ousamabenyounes:question-empty-guard

Conversation

@ousamabenyounes

Copy link
Copy Markdown

Issue for this PR

Closes #41549

Type of change

  • Bug fix

What does this PR do?

The question tool accepted an empty questions array. Question.ask then
registered 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 questions array up front, before a pending request is
registered, in both Question.ask (packages/opencode/src/question/index.ts)
and QuestionV2.ask (packages/core/src/question.ts). Both tool call sites
already .pipe(Effect.orDie) the result of ask, so failing here ends the turn
the same way a dismissed question already does — instead of hanging forever.

How did you verify your code works?

Added a test at each ask layer that asks with an empty questions array,
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.ts
  • packages/core/test/question.test.ts

RED (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/opencode question tests: 16 → 17 pass, 0 fail
  • packages/core question tests: 7 → 8 pass, 0 fail
  • bun typecheck for the core and opencode packages: pass

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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
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.

Question tool accepts empty questions array

1 participant