Agent name lost when session continues from context compaction

Status Fixed / completed
Maintainer reply ✓ Yes — ashwin-ant
Activity 4 comments · opened Apr 15, 2026 · closed Apr 18, 2026
💡 Likely answer: A maintainer (ashwin-ant, collaborator) responded on this thread — see the highlighted reply below.

Description

When a Claude Code session runs out of context and is continued into a new session (context compaction), the agent name assigned via the rename feature disappears. The name is no longer displayed on the right side of the screen.

Steps to reproduce

  1. Start a Claude Code session
  2. Rename the agent using the rename feature
  3. Verify the name displays on the right side of the screen
  4. Continue working until the session runs out of context and is auto-continued
  5. The agent name is gone — no longer displayed

Expected behavior

The agent name should persist across context compaction / session continuation.

Actual behavior

The name is lost and not carried over to the continued session.

Environment

  • Claude Code v1.x (CLI)
  • macOS Darwin 24.6.0

View original on GitHub ↗

4 Comments

github-actions[bot] · 6 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/33898
  2. https://github.com/anthropics/claude-code/issues/29922
  3. https://github.com/anthropics/claude-code/issues/25090

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

0xbrainkid · 6 months ago

Agent name loss on context compaction is a session identity continuity failure — the user-assigned name is a persistent property of the agent context, not just the current session window. When compaction creates a new session, it should carry all persistent session metadata, not just the conversation content.

From an agent identity perspective, the assigned name is part of the agent identity within the project. Users name their agents to distinguish different work streams, give them personality context, or track which agent is responsible for which work. Losing the name on compaction means the agent loses a piece of its declared identity every time it runs out of context — which is exactly when long-running productive sessions tend to compact.

The fix should be straightforward: agent name is session metadata, not context content. It should be stored in the session record (likely the .jsonl session file or a companion metadata file) separately from the conversation history, and restored on session continuation alongside other session properties (project path, permission mode, MCP connections).

Two additions worth considering alongside the fix:

1. Session metadata manifest. A small JSON file alongside the session JSONL that contains all persistent session properties: {"name": "My Reviewer", "created_at": "...", "compact_count": 3, "project_path": "..."}. This survives compaction cleanly because it is not part of the context window.

2. Name in behavioral audit trail. If the session name is preserved across compactions, the compact_boundary event should include it — so behavioral monitors tracking session continuity can correlate pre- and post-compaction behavior under the same named identity.

ashwin-ant collaborator · 6 months ago

This was fixed in v2.1.47 — The session name (--name) is now re-appended to the transcript after compaction so it survives across resume. If you're still seeing this in the latest version, please comment with your version and repro and we'll reopen.

github-actions[bot] · 5 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.