C:/Program Files/Git/clear leaves stale agent entries in the Agents status panel
Description
After running /clear, the Agents panel in the status line briefly displays agent entries from the previous conversation context. The stale entries disappear on subsequent UI refresh (e.g., when the user starts typing), but their momentary appearance is confusing.
Steps to reproduce
- Start a Claude Code session and run several agents (Explore, general-purpose, etc.)
- Wait for all agents to complete
- Run
/clear - Observe: status line shows
ctx:0%,0 tokens— Agents panel is not visible (correct) - Send a new message and wait for the response
- Observe: the Agents panel reappears showing all previously completed agents from before
/clear(all showingdone,0model tokens) - Start typing again
- Observe: the stale agents disappear; only current-context agents remain
Expected behavior
After /clear, the Agents panel should be fully reset. Agent entries from the previous conversation context should never reappear.
Actual behavior
Stale agent metadata persists at the session level and is re-rendered into the Agents panel when the first new response arrives after /clear. The entries self-correct on the next UI refresh cycle.
Screenshots
<img width="2532" height="228" alt="Image" src="https://github.com/user-attachments/assets/1e86f5d6-50a9-4a31-b494-28866c3bcad5" />
<img width="2527" height="524" alt="Image" src="https://github.com/user-attachments/assets/578e94e5-3018-4e07-9062-e98af6b81a23" />
<img width="2524" height="451" alt="Image" src="https://github.com/user-attachments/assets/d77c7151-b93b-4937-ab11-c8726a984799" />
Analysis
/clear resets the conversation context (messages) but does not clear the agent tracking state in the status line UI. The agent metadata appears to be scoped to the session rather than the conversation context, so it survives /clear. On the first post-clear render, the UI pulls from this stale session-level cache. Subsequent renders correct the display, likely because the new conversation context has no matching agent references.
Suggested fix
When /clear is executed, also reset the agent registry / tracking state used by the status line renderer, so no stale entries can be displayed.
Environment
- Claude Code CLI (Desktop, Windows 11)
- Model: Opus 4.6
- Platform: Windows 11 (10.0.26200)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗