Skip to content

fix: correct tool_result message format for AskUserQuestion#53

Merged
hilr merged 1 commit into
mainfrom
fix/ask-user-question-tool-result
Jun 12, 2026
Merged

fix: correct tool_result message format for AskUserQuestion#53
hilr merged 1 commit into
mainfrom
fix/ask-user-question-tool-result

Conversation

@quick-sort

Copy link
Copy Markdown
Owner

Summary

  • parent_tool_use_id was set to tool_use_id instead of null — SDK 的所有用户消息都用 null,这个不一致导致 CLI 无法正确匹配tool_result,LLM 收不到用户的回答,从而重新问同一个问题
  • session_id fallback 从 "default" 改为 "" 以匹配 SDK 初始消息格式
  • ask.get("session_id", "")ask.get("session_id") or "" 修正 None 值不触发默认值的问题

Test Plan

  • 发送一条会触发 Claude Code 调用 AskUserQuestion 的消息
  • 回答问题 — 确认回答正确发给 LLM,不再重复问同一个问题

When Claude Code calls AskUserQuestion, the agent pauses and waits for
the user's reply, then sends it back as a tool_result. The message was
using `parent_tool_use_id: tool_use_id`, but every other user message
in the SDK (initial prompt, client.query()) uses `parent_tool_use_id: null`.
This mismatch caused the CLI to misroute the tool_result, so the LLM
never received the user's answer and re-asked the same question.

Also fix session_id fallback: use "" (matching the SDK's initial-message
format) instead of "default", and use `or ""` instead of `.get(key, "")`
so that an explicit None value is also replaced by the empty string.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hilr
hilr merged commit 916aadf into main Jun 12, 2026
1 check passed
@hilr
hilr deleted the fix/ask-user-question-tool-result branch June 12, 2026 09:52
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.

2 participants