Skip to content

fix: format AskUserQuestion tool_result content as natural-language s…#55

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

fix: format AskUserQuestion tool_result content as natural-language s…#55
hilr merged 1 commit into
mainfrom
fix/ask-user-question-tool-result-format

Conversation

@quick-sort

Copy link
Copy Markdown
Owner

Summary

The AskUserQuestion resume path was sending tool_result.content as a JSON string ({"questions": [...], "answers": {...}}). Comparing against a real Claude Code CLI transcript shows the content fed back to the model should be a human-readable string instead:

User has answered your questions: "<q>"="<a>", ... You can now continue with the user's answers in mind.

The structured questions/answers live in the transcript's top-level toolUseResult metadata (written by the CLI), not in the message content.

Changes

  • Add _format_answers_for_tool_result() to render answers in the CLI's natural-language format (multiSelect arrays joined with , ).
  • Update run() resume path to use it; fallback now wraps the raw user reply in the same sentence format instead of emitting JSON.

Test Plan

  • uv run pytest tests/test_agents.py (63 passed)

…tring

Match Claude Code CLI's actual tool_result format. The content fed back
to the model should be a human-readable string ("User has answered your
questions: ...") rather than JSON. Structured questions/answers belong in
the transcript's toolUseResult metadata, not the message content.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@hilr
hilr merged commit c3919f1 into main Jun 17, 2026
1 check passed
@hilr
hilr deleted the fix/ask-user-question-tool-result-format branch June 17, 2026 05:36
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