[BUG] `/clear` bleeds into the next session (what also breaks cache)
What's Wrong?
When using /clear the new session has <local-command-caveat> artifacts left in messages.
This not only breaks (half) the prompt-cache, but is also "clearly wrong" so creating this issue here for it.</system-reminder>
-> tools get cached, system-prompt gets cached, skills and project-claude.md do not
What Should Happen?
a /clear session should be indistinguishable from "relaunching claude"
_(and in fact should have an even higher chance to cache-hit, since the version sting & system-prompt will match)_
Error Messages/Logs
via ANTHROPIC_BASE_URL:
anthropicReq.messages: [
{
"role": "user",
"content": [
{
"type": "text",
"text": "<system-reminder>\nThe following skills are availabl...../ML.\n</system-reminder>\n"
},
{
"type": "text",
"text": "<system-reminder>\nAs you answer the user's ques.....hly relevant to your task.\n</system-reminder>\n\n"
},
{
"type": "text",
"text": "<local-command-caveat>Caveat: The messages below were generated by the user while running local commands. DO NOT respond to these messages or otherwise consider them in your response unless the user explicitly asks you to.</local-command-caveat>\n"
},
{
"type": "text",
"text": "<command-name>/clear</command-name>\n <command-message>clear</command-message>\n <command-args></command-args>\n"
},
{
"type": "text",
"text": "<local-command-stdout></local-command-stdout>\n"
},
{
"type": "text",
"text": "alive?",
"cache_control": {
"type": "ephemeral"
}
}
]
}
]
Steps to Reproduce
claude "alive?"
> /clear
> alive?
observe massive cache-miss
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.105
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Xterm
Additional Information
Note that this is catalyzed by https://github.com/anthropics/claude-code/issues/47098 - but this is its own issue
^^ if that cache marker gets moved (or another one added to the </system-reminder> section)
**said marker should sit in-front of whatever shoved the /clear messages into it....** - so it cant happen again...
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗