From 2330f50268714fa96538c6723cf1d1ac0970011a Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Thu, 12 Nov 2026 01:37:59 +0000 Subject: [PATCH] Return question answers in the tool's own input shape The Claude chat bridge sent the whole AskUserQuestion input back nested under questions, so Claude Code rejected every answer (questions must be an array) and the operator's picks were lost. Echo the original input with answers added; the fake CLI now enforces the schema. --- internal/claude/chat.go | 22 ++++++++++++---------- internal/claude/testdata/fake-claude.py | 7 ++++++- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/internal/claude/chat.go b/internal/claude/chat.go index 1de1ada3..cf448833 100644 --- a/internal/claude/chat.go +++ b/internal/claude/chat.go @@ -611,10 +611,12 @@ func (c *Chat) Answer(ctx context.Context, request protocol.ChatAnswerRequest) e answers[question] = fmt.Sprint(typed) } } - response = map[string]any{ - "behavior": "allow", - "updatedInput": map[string]any{"questions": form.rawQuestions, "answers": answers}, - } + // The tool's own input comes back unchanged ({"questions": [...]} and + // any other fields) with the answers added. + updated := map[string]any{} + _ = json.Unmarshal(form.rawInput, &updated) + updated["answers"] = answers + response = map[string]any{"behavior": "allow", "updatedInput": updated} } s.mu.Lock() form.answering = true @@ -704,11 +706,11 @@ type pendingApproval struct { } type pendingForm struct { - form protocol.ChatForm - rawQuestions json.RawMessage - questions []string - proc *process - answering bool + form protocol.ChatForm + rawInput json.RawMessage + questions []string + proc *process + answering bool } func (s *session) receivePermission(p *process, requestID string, request toolRequest) { @@ -819,7 +821,7 @@ func (s *session) receiveQuestion(p *process, requestID string, request toolRequ form.Fields = append(form.Fields, field) } s.mu.Lock() - s.forms[requestID] = &pendingForm{form: form, rawQuestions: request.Input, questions: questions, proc: p} + s.forms[requestID] = &pendingForm{form: form, rawInput: request.Input, questions: questions, proc: p} s.mu.Unlock() s.emit(protocol.ChatEventFrame{SessionID: s.id, Kind: protocol.ChatEventForm, Form: &form}) } diff --git a/internal/claude/testdata/fake-claude.py b/internal/claude/testdata/fake-claude.py index b900bc90..f70423cc 100644 --- a/internal/claude/testdata/fake-claude.py +++ b/internal/claude/testdata/fake-claude.py @@ -269,7 +269,12 @@ def handle(line): tool_result("Error: " + str(result.get("message") or "denied"), True) return if pending["kind"] == "question": - answers = (result.get("updatedInput") or {}).get("answers") or {} + updated = result.get("updatedInput") or {} + # Like Claude Code: updatedInput must still match the tool's schema. + if not isinstance(updated.get("questions"), list): + tool_result("Error: The parameter `questions` type is expected as `array`", True) + return + answers = updated.get("answers") or {} tool_result("Your questions have been answered: " + json.dumps(answers)) else: tool_result("File created successfully")