[BUG] VS Code: ListAgents name reverts to an auto-generated name after resuming a renamed session
Bug
In the VS Code extension, after VS Code is restarted and a renamed conversation is resumed, the running session's own name (the first line of ListAgents: "This session is <name>") is an auto-generated name (e.g. demo-project-4c), while the conversation title set by /rename is restored correctly.
Running /rename <same name> again restores the name reported by ListAgents. Returning the same title from a SessionStart hook via hookSpecificOutput.sessionTitle does not.
Environment
- Claude Code 2.1.287 (VS Code extension
anthropic.claude-code,entrypoint: claude-vscode) - VS Code 1.140.0
- Windows 11
Steps to reproduce
- Start a new conversation in the Claude Code VS Code extension and run
/rename my-session. - Quit VS Code and start it again. The extension restores the conversation tab automatically.
- In the restored conversation, ask Claude to call
ListAgents. - Observe that the first line reports an auto-generated name (
This session is <folder>-<xx>), while the conversation tab still showsmy-session. - Run
/rename my-sessionagain, then callListAgents. The reported name is nowmy-session.
Expected
After step 3, the first line says This session is my-session.
Observations
- The transcript (
<session-id>.jsonl) contains{"type":"custom-title","customTitle":"my-session"}and{"type":"agent-name","agentName":"my-session"}records, with new ones appended repeatedly during the conversation, including after resume. So the name is persisted, but after resumeListAgentsreports an auto-generated name instead. - A SessionStart hook (matcher
startup|resume|clear|compact) receives"session_title": "my-session"on stdin for sourceresume, so the title is known at that point. - When that hook returns
{"hookSpecificOutput": {"hookEventName": "SessionStart", "sessionTitle": "my-session"}}, the run is recorded ashook_successand its captured stdout contains that JSON. However,ListAgentsstill reports the auto-generated name. - In my tests, other sessions reported the custom name when
~/.claude/sessions/<PID>.jsoncontained"name": "my-session"and"nameSource": "user". After restart, the new<PID>.jsoncontained an auto-generated name instead.
Impact
After restarting VS Code, I have to run /rename again in each affected session to restore the name used for cross-session messaging (ListAgents / SendMessage).
Related
- #80711: SessionStart hook
sessionTitleis persisted but not shown in the TUI session-name badge. A similar persistence/display mismatch; it is unclear whether the cause is shared. - #88992: renaming via the VS Code sidebar doesn't update the
ListAgents/SendMessagename. Different trigger (sidebar rename, not resume after/rename). - #87114: reports missing sessions in
ListAgentsand names that differ from those shown in the session overview.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗