Feature request: forced readback after mutation tool calls to prevent confabulation
Problem
LLMs using Claude Code can confabulate tool results — generating text that looks like a tool's output without actually calling the tool. This is a known autoregressive generation behavior (not a bug) where the model "fills in" expected results instead of waiting for real tool output.
Concrete example
During a session with high tool-call density (e.g., ticket complete → git commit → grep verification sequence), the model may:
- Issue
git commit - In the same message, continue writing a fake commit hash and success message
- Issue
grep -cto "verify" the commit landed - In the same message, write a fake integer result
The verification step itself gets confabulated, making self-correction impossible. The model believes it verified, but no tool was actually called.
Why existing hooks can't solve this
- PreToolUse/PostToolUse hooks only fire on actual tool calls. Confabulation is the absence of a tool call (the model writes text instead of calling the tool).
- There is no AssistantTextGeneration or AssistantMessage hook event that could intercept the model's text output.
- PostToolUse can inject "reminder" messages, but the model can still confabulate the verification in the same turn.
Proposed solution: forced readback after mutation tools
After any mutation tool call (Bash commands containing git commit, git push, file writes, etc.), the Claude Code runtime could:
- Force a turn boundary — end the current assistant message after the mutation tool result is returned
- Inject a mandatory read-only verification tool call — automatically run a verification command (e.g.,
git log --oneline -1aftergit commit) and include its result before allowing the model to continue generating
This would structurally prevent the confabulation "ignition action" (writing expected results in the same message as the tool call) by making the turn boundary mandatory rather than advisory.
Alternative: configurable post-mutation verification
A lighter-weight version could be a new hook event like PostMutationVerify that:
- Fires after mutation tool calls complete
- Receives the tool name and result
- Can return a verification command whose output is injected into the conversation
- Forces a turn boundary before the model continues
Impact
This affects any long-running Claude Code session with high tool-call density. Our project has documented multiple incidents where confabulation cascaded through 5+ turns before external intervention (user or hook) broke the cycle.
References
- Related to the general challenge of LLM confabulation in agentic tool-use settings
- The "one command → message end → next turn reads real result" discipline is the current best practice, but it relies on model self-discipline rather than structural enforcement