Resuming a backgrounded `--agent <name>` session reverts to the default agent, losing its system prompt and tool grant
Description
Launching a session with claude --agent <name> correctly applies that named agent's identity — its system prompt and restricted toolset match the agent definition. But if the session is sent to the background via the TUI's left-arrow "agents view" gesture and then resumed (not via --resume <id>, but via the interactive left-arrow-then-enter flow), the resumed session silently reverts to the plain/default main agent: its toolset is back to the full default set (Task/Agent, Bash, Read, Write, Edit, WebFetch, etc.) instead of the named agent's restricted grant. The conversation history/context is preserved, but the agent identity is gone.
This is a functional/security-relevant regression, not a cosmetic one — a restricted agent (e.g. one scoped to a narrow toolset for safety) silently regains full tool access after a background/resume round-trip, with no error or warning surfaced to the user.
This has been independently reproduced at least twice — once by the user reporting it, and once independently in a separate session hitting the identical symptom — both with the same steps below.
Repro steps
- Launch a session with a named agent:
claude --agent <name>(any custom agent defined under.claude/agents/, e.g. one with a restricted tool list). Confirm the session behaves as that agent — correct system prompt, correct restricted toolset. - Press the LEFT ARROW key to send the session to the background-agents list (the interactive TUI's own backgrounding gesture — not the
run_in_backgroundparameter on theAgenttool). - Press ENTER to re-enter/resume that backgrounded session from the agents list.
- Observe the resumed session's identity.
Expected behavior
Resuming a backgrounded session (left-arrow → enter) should preserve the exact agent identity (system prompt + tool grant) it had before backgrounding. Backgrounding is a UI/scheduling action, not a re-launch, so it should not silently fall back to the default agent.
Actual behavior
The resumed session presents as the plain/default main agent: its toolset reverts to the full default set (Task/Agent, Bash, Read, Write, Edit, WebFetch, etc.) instead of the named agent's restricted toolset. It has lost its --agent <name> identity entirely, even though the conversation history/context is preserved.
Environment
- Claude Code CLI version: 2.1.214
- OS: Ubuntu 26.04 LTS (Resolute Raccoon)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗