[Agent View] Supervisor doesn't preserve --mcp-config / --settings across /bg → respawn

Resolved 💬 3 comments Opened May 14, 2026 by gabe4coding Closed May 17, 2026

Environment

  • Claude Code 2.1.141 (also seen on 2.1.140, 2.1.139), macOS
  • Single user, agent-view enabled

Summary

When an interactive Claude Code session is launched with custom flags (--mcp-config, --settings, --disallowedTools, --strict-mcp-config, --name, etc.) and then backgrounded via /bg, the supervisor records respawnFlags: [] in ~/.claude/daemon/roster.json. On the next respawn (attach after timeout, claude respawn, or supervisor restart), Claude is relaunched with --resume <id> -- continue and none of the original launch flags. The session retains its conversation and customTitle, but MCP servers, settings.json overrides (sandbox, plugins, permission mode, env), and disallowed-tools rules are all silently dropped.

Reproduction

# Launch with a custom MCP config and settings
claude --strict-mcp-config --mcp-config /tmp/mine.json --settings /tmp/settings.json --name "my-profile"

# Inside the session
/bg

Inspect the resulting roster entry:

{
  "sessionId": "dd9470e1-…",
  "dispatch": {
    "launch": {
      "mode": "resume",
      "fork": true,
      "flagArgs": ["--", "continue"]
    },
    "respawnFlags": [],
    "seed": { "name": "my-profile" }
  }
}

Now attach (or wait for the supervisor to expire the worker and respawn). The new session has no MCP servers loaded, no sandbox, no plugin overrides — only the conversation history and the custom title remain.

Expected

The supervisor preserves the original launch flags in respawnFlags (or some equivalent mechanism) so a /bg'd session restores with the same tool surface and policy it had before. At minimum: --mcp-config, --settings, --strict-mcp-config, --disallowedTools, --add-dir, --system-prompt[-file], --append-system-prompt[-file], --agents, --plugin-dir, --plugin-url, --model, --permission-mode.

Actual

respawnFlags is empty. flagArgs is ["--", "continue"] regardless of how the session was originally launched.

Impact

Any tooling that wraps Claude Code with non-default flags (CLI profile managers, project-scoped MCP configs, sandboxed launchers, internal CI runners) cannot rely on /bg. From the user's perspective:

"I /bg'd my session and when I attached back, all my MCP servers and my permission policy were gone. The conversation is intact but the tool surface isn't."

It also means a session restored from sleep silently changes behavior — same conversation, different permissions / different tools available.

Suggested fix

Capture the original process.argv at session start and persist it (minus terminal-bound options like -r / --resume) as respawnFlags. Optionally allow opt-out via a --no-preserve-flags flag.

A workaround would be to expose a /bg --preserve-flags form, or a claude-code API hook on SessionWillBackground so wrappers can populate respawnFlags themselves.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗