fix(chat): submit AskUserQuestion answers keyed by question text#84
fix(chat): submit AskUserQuestion answers keyed by question text#84hanifnr wants to merge 2 commits into
Conversation
The Claude Agent SDK's AskUserQuestion tool expects the `answers` map keyed by the full question text (see AskUserQuestionOutput in @anthropic-ai/claude-agent-sdk: "question text -> answer string"). Braid was sending answers keyed by `header` (the short chip label), so the SDK could not correlate answers back to their questions and the model saw the user's selections as unreadable. Iterate over `pendingQuestion.questions` directly and write each answer under `q.question`. This also drops the now-unnecessary header→question lookup map and makes the "other" override precedence explicit.
There was a problem hiding this comment.
Code Review
This pull request updates the handleSubmit function in AskUserQuestionPrompt.tsx to use question text as keys for the final output, ensuring compatibility with the SDK. The implementation was also changed to have free-text 'other' values override selections. Feedback suggests merging these values instead of overriding them to prevent potential data loss in multi-select scenarios.
Previously the free-text "other" value replaced any selected labels, so a multi-select user who picked "Option A" + "Other" with typed "Option B" would lose "Option A". Single-select is unaffected because the UI already replaces selections with `['__other__']` when "Other" is picked.
|
@gemini-code-assist Thanks for the review. Addressed the data-loss concern in a77019c — multi-select labels and "other" free-text are now merged into a single comma-separated answer instead of overriding, matching multi-select semantics. Single-select behavior is unchanged because the UI replaces selections with |
|
Thanks for the update, @hanifnr. The logic in |
Summary
AskUserQuestionanswers keyed byq.header(the short chip label), but the Claude Agent SDK expects them keyed byq.question(the full question text — seeAskUserQuestionOutputin@anthropic-ai/claude-agent-sdk: "question text -> answer string").pendingQuestion.questionsand emit each answer underq.question. Drops the now-unnecessary header→question lookup and makes the "other" override precedence explicit.Root cause
AskUserQuestionOutput.answers,sdk-tools.d.ts:2666): keys are question text → answer string.answers[V.question]when rendering / formatting the tool result back to the model.AskUserQuestionPrompt.tsx#handleSubmitpreviously keyedfinalbyheader, so the lookup failed silently downstream.Test plan
AskUserQuestionwith a single question — verify Claude correctly reads the chosen option.AskUserQuestionwith multiple questions — verify Claude correlates each answer with the right question.yarn testpasses (pre-existing unrelated failures inlsp/helpersanduseSwipeNavigationremain).