Skip to content

fix(tool): refuse an empty question list - #793

Merged
Ishaan Gangwani (ishaan1124) merged 2 commits into
synthetic-sciences:mainfrom
aniruddhaadak80:fix/question-empty-list
Sep 29, 2026
Merged

Ishaan Gangwani (ishaan1124) merged 2 commits into
synthetic-sciences:mainfrom
aniruddhaadak80:fix/question-empty-list

Conversation

@aniruddhaadak80

Copy link
Copy Markdown
Contributor

What

QuestionTool accepted questions: []. The only validation is:

const invalid = params.questions.find(
  (question) => question.options.length < 2 || !question.options[0]?.label.endsWith("(Recommended)"),
)

find over an empty array returns undefined, so an empty list passes.

Why it matters

Two wrong outcomes, both of which misreport the run's state:

Autonomous / balanced-planning invents a decision:

title:  "Continued with 0 recommended choices"
output: "OpenScience continued without pausing. Assumption recorded: ."
metadata: { answers: [], assumptions: [] }

The model is told an assumption was recorded when none was — and the dangling Assumption recorded: . is a visibly broken sentence it then has to reason about.

Interactive hangs. Question.ask({ questions: [] }) publishes a question.asked event with zero questions and returns a promise that only settles on a UI reply or an abort, so the turn waits on a card with nothing to answer until the user interrupts.

Verification

Fails before, passes after:

error: Expected promise that rejects
Received promise that resolved: Promise { <resolved> }
(fail) tool.question > refuses an empty question list instead of answering nothing
(pass) should successfully execute with valid question parameters
(pass) refuses an empty question list instead of answering nothing
(pass) should now pass with a header longer than 12 but less than 30 chars
(pass) Interactive permits collaborative planning with a recommended first option
(pass) Balanced decides routine planning but still permits consequential questions
(pass) Independent makes the recommended call unless authority is genuinely missing
(pass) planning and consequential choices fail closed without a recommendation
 7 pass
 0 fail

The test covers both autonomy paths and asserts Question.ask was never reached, so the hang cannot come back quietly. All 6 pre-existing tests still pass.

The change

   async execute(params, ctx): Promise<QuestionDecisionResult> {
+    if (!params.questions.length) {
+      throw new Error(
+        "The question list was empty, so nothing was asked and nothing was decided. Retry with at least one question and the options to choose from.",
+      )
+    }
     const autonomy = MessageV2.resolveDelegationSettings(ctx.extra?.delegationSettings).autonomy

Placed before the recommended-choice guard, and phrased for the model the way the neighbouring throw already is.

bun run typecheck clean; touched files are Prettier-clean (checked on LF-normalized copies — this checkout has core.autocrlf=true, which makes Prettier flag every file in the repo).

Fixes #792

@vercel

vercel Bot commented Sep 28, 2026

Copy link
Copy Markdown

ANIRUDDHA ADAK (@aniruddhaadak80) is attempting to deploy a commit to the InkVell Team on Vercel.

A member of the Team first needs to authorize it.

find() over an empty array is undefined, so the recommended-option guard passed and the tool went on to report an assumption it had not recorded, or ask the user a question with nothing in it and wait for an answer that could not be given.
@ishaan1124
Ishaan Gangwani (ishaan1124) merged commit 4a05a13 into synthetic-sciences:main Sep 29, 2026
8 of 9 checks passed
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.

The question tool accepts an empty question list and then answers or hangs

2 participants