Under the hood
Appending user or compact-boundary messages mid-turn now always runs a cleanup step, even on error
What
When Claude Code adds a user message or a compact_boundary marker (used when a conversation is compacted, or shortened, to save space) to the ongoing conversation, that step is now wrapped so a cleanup function always runs afterward, even if something goes wrong partway through.
Why
This guards against internal state being left inconsistent if an error occurs while recording one of these messages.