[BUG] Session name auto-set on plan approval cannot be cleared by agent or removed on plan completion
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?
When a user approves a plan via ExitPlanMode, the Claude Code runtime automatically sets the session name (status line label) by kebab-casing the plan's H1 title. This name is never cleared — not when the plan completes, not when the plan file is deleted, and not by any tool available to the agent.
The name is injected as JSONL entries into the session transcript:
[Agent] Write tool → creates plan file ~/.claude/plans/<slug>.md
[Agent] ExitPlanMode tool → submits plan for user approval
[User] Approves the plan
[Runtime] {"type":"custom-title","customTitle":"sendit-production-refactor"} ← INJECTED
[Runtime] {"type":"agent-name","agentName":"sendit-production-refactor"} ← INJECTED
[Agent] Starts executing
The name is derived from the plan's H1: # SendIt Production-Ready Refactor Plan → sendit-production-refactor. These entries are written to ~/.claude/projects/<project-hash>/<session-id>.jsonl on each session resume but never removed.
The agent cannot clear it — no tool, skill, or API is exposed. Only the user can fix it via /rename.
What Should Happen?
The session name should be cleared when the plan is completed or the plan file is deleted. Alternatively, expose a rename mechanism to the agent so it can clean up after itself.
Error Messages/Logs
Steps to Reproduce
mkdir /tmp/test-plan-bug && cd /tmp/test-plan-bug && git initclaude— start a new session- Paste this prompt:
````
create a plan to add a hello-world.txt file to this repo. despite how simple the task is, i'm asking you to follow the instructions.
- Claude enters plan mode, writes a plan file, calls
ExitPlanMode - Approve the plan
- Observe: Status line now shows a kebab-cased version of the plan title (e.g.,
add-hello-world-file) - Let Claude finish or cancel
- Delete the plan file:
rm ~/.claude/plans/*.md - Observe: Status line still shows the stale name
- Ask Claude to clear it — it cannot
- Only fix:
/rename
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.87
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
The custom-title and agent-name JSONL entries are written by the runtime, not by the agent. They're injected between the user's plan approval message and the next assistant response. The agent has no tool to write these entries or overwrite them with empty values.
Suggested fixes (any one would work):
- Auto-clear session name when the plan file is deleted or plan completes
- Expose a rename tool to the agent
- Don't auto-set the session name from plan titles at all
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗