[BUG] Assistant's turn overruns and writes a fake "user" message that gets treated as real input
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Title
Assistant's turn overruns and writes a fake "user" message that gets treated as real input
Environment
- Claude Code, model: Opus 5, high effort
- OS: Windows 11
- Shell: PowerShell
- Mode: TUI fullscreen
- Context: running a custom skill with a 9-question interview flow
What happened
During a 9-question check-in (custom skill), 8 messages appeared in the
conversation that I never typed. Each one rendered as the literal role
token "user" stuck directly onto invented text, with no space, e.g.:
useri do not remember exactly. i probably placed the stop mentally
usermissing out on the NBIS long move. i was frustrated because...
useryes: on wednesday i was distracted because i was waiting for the technician
The assistant treated each fake line as my real answer, and used them to
build a persisted, published report. I only found the problem when I
read the output afterward.
Evidence that these were not real input
- No ">" prompt marker and no input highlight. Every real message of mine has both.
- The fake line sits ABOVE the Stop-hook output — inside the assistant's own turn, not a new turn.
- The content was a plausible prediction of my answer, written with full context of the question (specific invented details: a chimney sweeper, a doctor's appointment, a claimed misunderstanding).
- Several fake answers arrived as 2–3 consecutive "user" messages in a row, where real turns arrive as one.
What I ruled out
- Hooks: none of my configured hooks produce text output (Stop = git status + beep + a script; PostToolUse = a commit script; Notification = beep only).
- Scheduled jobs: none found via CronList.
- Remote control:
remoteControlAtStartup: trueis set, but this does not explain a literal "user" role token appearing inside the assistant's own turn.
Impact
Any multi-question interview-style flow is defenceless against this. The
harness cannot tell a fabricated answer from a real one, so invented
content gets written into stored, persisted records as if the user said it.
Expected behavior
The assistant's turn should stop cleanly at its actual end. Text
resembling a "user" role token generated by the model should never be
parsed and executed as a new, real user turn.
What Should Happen?
The assistant's turn should stop cleanly at its actual end. Text
resembling a "user" role token generated by the model should never be
parsed and executed as a new, real user turn.
Error Messages/Logs
Steps to Reproduce
Steps to reproduce
- Run Claude Code in TUI fullscreen mode (Windows 11, PowerShell).
- Use a custom skill that asks the user several questions in a row (an interview-style flow) — in my case, a 9-question check-in.
- Continue answering normally through the questions.
- At some point (question 4 onward in my case), the assistant's turn does not stop cleanly. It generates a fake line starting with the literal role token "user" directly followed by invented answer text, no space.
- The harness treats that fake line as a real user message and continues the flow using it.
Note: this is intermittent, not deterministic. I cannot make it happen on command. It has occurred once so far, corrupting 8 consecutive answers in one interview flow.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.233
Platform
Other
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
_No response_