User message and system<total_tokens> counter rendered inside the assistant's message block
What happened
An assistant message block rendered the next user message and an internalsystem<total_tokens>...</total_tokens> counter inside the assistant's own bubble,
with no separation.
The assistant's reply ended with a question, and then the following appeared appended
to the same block, on the next lines:
... 지시하지 않으신 일입니다. 지울까요?
user아니 나둬 ...
system<total_tokens>15000000 tokens left</total_tokens>
Note the literal user prefix glued to the start of the user's text, and the rawsystem<total_tokens> line, both shown as if the assistant had written them.
This is confusing: the user reasonably concluded the assistant had fabricated a user
turn. The assistant's own transcript showed those as separate incoming messages, so the
problem appears to be in rendering/merging of consecutive turns, not in model output.
Context
It happened during a long session with several messages sent while the assistant was
mid-turn (messages delivered as "The user sent a new message while you were working").
That interleaving seems related.
Expected
The user turn should render as its own block, and the internalsystem<total_tokens> counter should not be displayed at all.
Environment
- Claude Code 2.1.122
- Linux (Ubuntu 24.04, kernel 7.0.0-30-generic)
- VS Code extension
4 Comments
Additional occurrence — with a malformed closing tag and an injected English instruction
Same rendering merge as reported above, but this time the merged content included a
malformed system tag and an English imperative that the user never wrote.
The assistant's message block visually ended like this (user's screenshot):
Three problems in one block:
userprefix.</table>instead of</total_tokens>. A mismatched close like this can make thefollowing text appear to escape the system region.
appeared in that position. The user was writing in Korean and did not send this.
Item 3 is the concerning one: if the assistant had treated that line as a user
instruction, it would have started making changes without authorization. In this session
the assistant did not act on it, but the failure mode is obvious.
The session had many messages sent while the assistant was mid-turn
("The user sent a new message while you were working"), which seems related to the merge.
Expected
system<total_tokens>is not displayed, and its tags are well-formed.Environment
Third occurrence — same session, still reproducing
The rendering merge reported in this issue is still happening. Latest instance
(user screenshot):
Line 1 is the end of the assistant's message. Lines 2 and 3 are the *next user
turn* and the internal token counter, both rendered inside the assistant's
bubble with no separation. Note again the literal
userprefix glued directlyto the user's text.
This is now the third time in one long session. It happens consistently when the
user sends a message while the assistant is mid-turn (delivered to the assistant
as "The user sent a new message while you were working").
Impact: the user cannot tell what the assistant actually wrote versus what they
themselves typed. In this session the user twice believed the assistant had
fabricated their words.
Also still unfixed from the earlier comment:
system<total_tokens>should not beuser-visible at all.
Environment
Fourth occurrence + a related input-side problem
1. Rendering merge, still reproducing
Same as reported above. Latest instance: the assistant's message was rendered
with the next user turn and the
system<total_tokens>counter glued into thesame bubble. This is the fourth time in one session. It reproduces reliably
whenever the user sends a message while the assistant is mid-turn.
2. Mid-turn user messages are delivered inside a
<system-reminder>wrapperIn this session, a user message arrived to the assistant wrapped like this:
Genuine user input should not be nested inside a
system-reminderblock.Everywhere else in the product,
system-reminderis documented to the model assystem-controlled background context that is not user instruction. Delivering
real user instructions through that same channel makes the two indistinguishable
and pushes the model toward either ignoring a real instruction or treating
injected/system text as a user command.
The two problems compound: mid-turn messages are both mis-delivered (2) and
mis-rendered (1).
Suggested fix
system-remindermarkup orsystem<total_tokens>into the visible transcript.system-reminder.Environment
Fifth occurrence — and it caused the assistant to act without consent
Same rendering merge. Latest instance (user screenshot):
Line 1 is the assistant's question. Line 2 is the next user turn, line 3 is the
internal token counter — both rendered inside the assistant's bubble.
Concrete harm this time: the user states they did not authorize the action
("난 허락하지도 않았어"). The assistant treated the merged-in text as approval
and executed a database write. In a session where the user has repeatedly asked
the assistant not to act without explicit permission, this rendering defect
directly caused an unauthorized action.
This is the fifth occurrence in one session. It reproduces every time the user
sends a message while the assistant is mid-turn.
Combined with the input-side problem reported in the previous comment (mid-turn
user messages arriving wrapped in
<system-reminder>), the boundary between"user said this" and "system emitted this" is not reliable in either direction.
Environment