[BUG] shell-snapshots of interactive session mutated by invoked agents

Resolved 💬 3 comments Opened Jul 22, 2025 by cseickel Closed Aug 19, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.57
  • Operating System: Arch Linux
  • Terminal: Kitty

Bug Description

I have a custom mcp server that runs bots (sub agents) via the typescript SDK. The server uses node and a stdio interface. When I run a bot, the ~/.claude/shell-snapshots/snapshot-zsh-c<timestamp>-<random-hash>.sh of the parent process is taken over. If the bot uses the Bash tool, it will replace that file. When the bot finishes, it will delete the file. It deletes the file even if it never used the Bash tool.

Steps to Reproduce

It's hard to give you steps since the mcp server is not publicly available.

Expected Behavior

Each instance of claude code has it's own snapshot-shell file.

Actual Behavior

Agents invoked by claude take over the shell-snapshot file of the parent process.

Additional Context

This seems to be related to #4014, but on my computer I am able to start multiple instances simultaneously without conflict. I only have the issue when claude is invoked by claude.
#3619 also seems to be the same issue, but it was closed.

Workaround

I was able to work around the problem by creating a new home directory for my mcp-server to use. I set it with the env field in .mcp.json. I had to run one interactive session to login the first time. I then symlinked some files and folders to my real home dir to fit my needs.

It's hacky but it works for now. It's definitely not something I want to keep permanently though as it adds a lot of complexity to setting up a new dev environment.

View original on GitHub ↗

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