Skip to content

feat(chat): enable agent to ask interactive multiple-choice clarifica… - #504

Open
Klabundo wants to merge 6 commits into
mainfrom
feature/agent-clarification-questions
Open

Klabundo wants to merge 6 commits into
mainfrom
feature/agent-clarification-questions

Conversation

@Klabundo

Copy link
Copy Markdown
Collaborator

Gives the agent the ability to ask interactive multiple-choice questions for clarification.

@greptile-apps

greptile-apps Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The PR is not yet safe to merge because the unresolved duplicate-question-ID finding can prevent users from answering independently.

Fix All in Claude CodeFindings

  1. P1 Duplicate question IDs break answers
Fix with agent prompt
### Issue 1
src/agent/tools/askQuestion.ts:10-14
The schema allows repeated question IDs, including an explicit ID that can collide with a generated `q_<index>` fallback. The card then uses each ID as both a Svelte list key and the key for its answer state. A call with duplicate IDs can fail to render or make separate questions share selections, preventing the user from answering them independently. Please enforce uniqueness after fallback IDs are assigned.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR adds an interactive clarification tool that lets agents pause execution, display multiple-choice questions in chat, and resume with the user's answers.

  • Registers ask_question as an enabled built-in agent tool.
  • Coordinates pending questions and answers through a reactive runtime store.
  • Adds an interactive Svelte question card and completed-answer rendering.
  • Exposes configuration controls and tests the tool and pending-question lifecycle.
  • The completed-output validator now requires every selected answer to be a string.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Agent[Agent run] --> Tool[ask_question tool]
  Tool --> Store[PendingQuestionStore]
  Store --> Card[AskQuestionCard]
  User[User] --> Card
  Card --> Store
  Store --> Tool
  Tool --> Result[Answered tool result]
  Result --> Agent
Loading

Reviews (6) · Last reviewed commit: "Merge branch 'main' into feature/agent-c..."

Comment on lines +10 to +14
const questionItemSchema = z.object({
id: z
.string()
.optional()
.describe("Optional unique identifier for this question (e.g. 'choice_format' or 'framework')"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Duplicate question IDs break answers

The schema allows repeated question IDs, including an explicit ID that can collide with a generated q_<index> fallback. The card then uses each ID as both a Svelte list key and the key for its answer state. A call with duplicate IDs can fail to render or make separate questions share selections, preventing the user from answering them independently. Please enforce uniqueness after fallback IDs are assigned.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent/tools/askQuestion.ts
Line: 10-14

Comment:
**Duplicate question IDs break answers**

The schema allows repeated question IDs, including an explicit ID that can collide with a generated `q_<index>` fallback. The card then uses each ID as both a Svelte list key and the key for its answer state. A call with duplicate IDs can fail to render or make separate questions share selections, preventing the user from answering them independently. Please enforce uniqueness after fallback IDs are assigned.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

Comment thread src/components/chat/toolOutputRenderModel.ts
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.

1 participant