A pending AskUserQuestion is not written to the session transcript until it is answered, unless a PreToolUse hook matches it

Status Open
Reported on v2.1.281
Maintainer reply None cached
Activity 0 comments · opened Sep 24, 2026

Version: Claude Code 2.1.281, interactive terminal session, macOS.

What happens: When the model calls AskUserQuestion, the assistant record with the tool_use is not appended to ~/.claude/projects/<cwd>/<session>.jsonl while the question waits for an answer. The tool_use record and its tool_result are appended together, after the user answers. The tool_use record's timestamp is the time of the call, but it reaches the file only after the answer.

If a PreToolUse hook with matcher AskUserQuestion is configured (ours only appends its input to a log file), the tool_use record is written within about 2 seconds of the call, before the answer.

Why it matters: Tools that follow a session by reading its transcript cannot see that the agent is waiting on a question, or what it asks. ~/.claude/sessions/<pid>.json shows waitingFor: "input needed", but not the question.

Measurement: one single-select question with 3 options. The line count of the session JSONL was polled every 2 seconds. Claude was restarted between arms.

| arm | PreToolUse hook for AskUserQuestion | tool_use stamped | tool_use on disk | answer given |
|---|---|---|---|---|
| A1 | no | 15:51:17 | 15:51:50 | 15:51:48 |
| B1 | yes | 15:52:28 | 15:52:29 | after |
| A2 | no | 15:53:29 | 15:54:40 | 15:54:38 |
| B2 | yes | 15:55:22 | 15:55:24 | after |

In a separate session, a Bash tool_use was on disk while the command was still running, so the delay looks specific to AskUserQuestion. We did not test other tools that prompt for permission.

Expected: a pending tool_use for AskUserQuestion is written when the call is made, as other tool calls are, whether or not a hook is configured.

Steps to reproduce:

  1. Start claude in an empty directory, with no hooks.
  2. Ask it to call AskUserQuestion with one question.
  3. While the question is pending, tail -n 1 the session JSONL. The tool_use is not there.
  4. Answer the question. The tool_use and the tool_result appear together.
  5. Add a PreToolUse hook with matcher AskUserQuestion whose command appends stdin to a log file, restart, and repeat. The tool_use appears before you answer.

View original on GitHub ↗