buzz icon indicating copy to clipboard operation
buzz copied to clipboard

Managed Claude agents inherit the owner's personal Claude Code config (global CLAUDE.md, auto-memory, hooks) — no isolation

Open cogpros opened this issue 4 months ago • 3 comments

Summary

Buzz Desktop's managed Claude agents load the desktop owner's personal Claude Code configuration into every agent session: ~/.claude/CLAUDE.md (global instructions), the Claude Code auto-memory directory (~/.claude/projects/<home>/memory/, including MEMORY.md), user-scope hooks, and user-scope MCP servers.

If the owner uses Claude Code in the terminal with their own persona/instructions in ~/.claude/CLAUDE.md, every Buzz agent boots with that other agent's identity, rules, and memory injected into its context — ahead of, and in conflict with, the persona the owner defined in Buzz Desktop. There is currently no isolation setting.

Environment

  • Buzz Desktop 0.5.0, macOS 26.5.2 (arm64)
  • @agentclientprotocol/claude-agent-acp 0.63.0 (latest), bundled in node-tools
  • Claude Code CLI installed and configured by the owner for personal terminal use

Root cause

Two doors, both open:

  1. Adapter default. claude-agent-acp hardcodes settingSources: ["user", "project", "local"] when building SDK options (src/acp-agent.ts, current main — search settingSources). The "user" source pulls in the owner's global ~/.claude config. That default makes sense for the adapter's original IDE use case (the user's editor acting as the user), but not for Buzz's managed, persona-scoped agents. The adapter already spreads ...userProvidedOptions after this default, so an ACP client can override settingSources per session via _meta.claudeCode.options — Buzz never passes it (no hits for settingSources in this repo).

  2. Nest location. The agent workspace (~/.buzz) lives inside the owner's home directory, and Claude Code treats <ancestor>/.claude/CLAUDE.md as project memory for that ancestor. $HOME/.claude/CLAUDE.md is therefore picked up through the project source too, so merely dropping "user" is not sufficient. The auto-memory directory similarly resolves to the $HOME project and is not gated by setting sources at all.

Reproduction

  1. Put any distinctive content in ~/.claude/CLAUDE.md (e.g. # I am a different agent named X).
  2. Create a managed Claude agent in Buzz Desktop with its own system prompt.
  3. Ask the agent whether its context contains that heading — it does.

One-shot probes against the CLI reproduce it without Buzz:

$ cd ~/.buzz && claude --setting-sources user,project,local -p \
    "If your context includes any CLAUDE.md contents, quote its first heading; else NONE"
# → quotes the heading of ~/.claude/CLAUDE.md

$ cd ~/.buzz && claude --setting-sources project,local -p ...
# → STILL quotes it (ancestor project-memory door)

$ cd /tmp && claude --setting-sources project,local -p ...
# → NONE (confirms the ancestor walk is the second door)

Verified fix (tested locally)

Two layers, both verified on the versions above:

A. Environment variables in the managed-agent spawn env — works with the adapter's current defaults, no adapter change needed:

CLAUDE_CODE_DISABLE_CLAUDE_MDS=1     # stops global + ancestor CLAUDE.md injection
CLAUDE_CODE_DISABLE_AUTO_MEMORY=1    # stops ~/.claude/projects/<home>/memory injection

With both set, the same probes return NONE / no memory even with --setting-sources user,project,local.

B. Full isolation — additionally pass settingSources: ["local"] via _meta.claudeCode.options in session/new (the adapter already honors it). This also stops the owner's user-scope hooks and MCP servers from loading into managed agents, which the env vars alone do not. Verified by patching the bundled adapter's options locally: agent context is fully clean, auth (Keychain) and everything else keeps working.

Suggested behavior

  • Managed agents should default to not inheriting the desktop owner's personal Claude Code config (persona conflicts, prompt bloat, and the owner's personal instructions/memory leaking into agents that other channel members may interact with).
  • If inheritance is ever desirable, make it an explicit per-agent opt-in toggle.

Happy to test a build — this machine reproduces it deterministically.

cogpros avatar Jul 28 '26 19:07 cogpros

Hit this independently today while digging into how buzz-acp wires MCP servers per agent — can confirm the leak, and the root cause matches exactly.

One implementation note for whoever picks this up: crates/buzz-acp/src/config.rs already has a mechanism built for exactly this shape of problem — default_agent_env(command) (see the Hermes case, HERMES_ACP_SKIP_CONFIGURED_MCP, added for #3355). It's keyed on normalized runtime identity and merged into the spawn env with precedence defaults < persona extra_env < inherited parent env (AcpClient::spawn), so an operator/persona can always opt back in. Adding a claude-agent-acp/claude-code-acp/claude-code arm there that sets CLAUDE_CODE_DISABLE_CLAUDE_MDS=1 + CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 by default would cover layer A of your fix with no adapter changes needed. Layer B (settingSources: ["local"] via _meta.claudeCode.options in session/new) would need to go in build_mcp_servers/session_new_full in crates/buzz-acp/src/acp.rs and lib.rs where the session params are actually assembled.

Happy to put up a PR for layer A if that's useful.

jamiehudson1-collab avatar Jul 29 '26 07:07 jamiehudson1-collab

Independent reproduction, different angle: a direct cross-agent memory write, not just a CLAUDE.md read-leak.

Setup: two Buzz managed agents (Claude Code via claude-agent-acp) running locally against the same fleet workspace directory, so both resolve to the same ~/.claude/projects/<slug>/memory/ auto-memory folder described in this issue.

Verified sequence (timestamps from actual tool calls, not inference):

  1. Agent A reads a memory file it maintains about Agent B — file ends at a known line, modified timestamp shows an old date.
  2. ~17 minutes later, Agent A edits that same file; the edit tool reports the file changed on disk since the last read.
  3. Re-reading shows a new paragraph inserted by Agent B itself, describing its own recent activity, plus an updated frontmatter description and a fresh modified timestamp — and Agent B's own added text states outright that it "mounts this shared project memory too."

So this isn't only the owner's personal CLAUDE.md/hooks bleeding into agents (the original report) — separate agent personas, each told via system prompt that the memory store is "a persistent, file-based memory system" personal to them, are silently co-authoring the same files, unattributed. An agent's memory of record can end up containing another agent's claims with no signal they came from somewhere else, which is a data-integrity problem stacked on top of the isolation problem: content in these files can no longer be trusted as that agent's own verified observation.

+1 on prioritizing — the fix already proposed here (CLAUDE_CODE_DISABLE_AUTO_MEMORY=1, etc.) looks right for this angle too, since it's the same auto-memory-resolves-off-cwd mechanism, just hit via a write instead of a read.

tonyswartz avatar Aug 31 '26 17:08 tonyswartz

Checked current main before writing this so the thread has a fixed point.

Status as of today: nothing has landed. default_agent_env() in crates/buzz-acp/src/config.rs still carries only the Hermes arm, and the test right below it asserts that claude-agent-acp gets no env defaults. There are zero hits for CLAUDE_CODE_DISABLE anywhere in the repo. On the adapter side, claude-agent-acp main still hardcodes settingSources: ["user", "project", "local"] (v0.70.0 is the latest release), so both doors from the original report are still open.

@tonyswartz's write collision is the same mechanism hit from the other side. Auto-memory resolves off cwd, every managed agent shares one cwd, so every managed agent shares one memory store. Reads leak the owner's config in. Writes leak one agent's claims into another agent's memory of record with no attribution. Layer A (CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 in the spawn env) closes the write side too.

Two open issues sit on the same root and would move with this one: #4038 (one nest and one memory store across all communities on a machine) and #5367 (nest AGENTS.md never reaches Claude Code agents). Worth triaging together.

@jamiehudson1-collab's layer A PR offer from July still stands and the seam he named is unchanged. If a maintainer can confirm that's the wanted shape, I'll test the build here. This machine still reproduces it deterministically.

cogpros avatar Sep 01 '26 00:09 cogpros