fix: correct tool_result message format for AskUserQuestion#53
Merged
Conversation
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
approved these changes
Jun 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
parent_tool_use_idwas set totool_use_idinstead ofnull— SDK 的所有用户消息都用null,这个不一致导致 CLI 无法正确匹配tool_result,LLM 收不到用户的回答,从而重新问同一个问题session_idfallback 从"default"改为""以匹配 SDK 初始消息格式ask.get("session_id", "")→ask.get("session_id") or ""修正None值不触发默认值的问题Test Plan