buzz icon indicating copy to clipboard operation
buzz copied to clipboard

Claude-backed managed agents launch under fabricated identities and fail readiness on every app launch

Open jcg-git opened this issue 2 months ago • 3 comments

Claude-backed managed agents launch under fabricated identities and fail readiness on every app launch

Summary

On desktop v0.5.25 (also reproduced on the commit prior to a ~312-commit main pull, so not obviously tied to that update), every Claude-backed managed agent (backend: claude, i.e. running through claude-agent-acp) fails to auto-start correctly, while agents on every other backend in the same launch batch (grok, a local model, a failover router, etc.) start cleanly. Two distinct problems, confirmed separately:

1. Claude-backed agents launch under a pubkey that exists nowhere locally

Comparing the BUZZ_AUTH_TAG signature on a freshly-spawned Claude-backed agent's process against the signature stored for that persona's canonical record in managed-agents.json shows two completely different signed auth events — not a field mix-up, a genuinely different identity. The fabricated pubkey does not appear in:

  • managed-agents.json (any record, any field)
  • the relay-side NIP-IA archive snapshot (kind 13535)
  • any other local Buzz state file (teams.json, profile-reconcile-pending.json, global-agent-config.json)

This happens on every app launch, including re-spawning a pubkey that had already been archived via buzz agents archive (kind 9035) in an earlier cleanup — archiving on the relay does not stop the desktop from spawning a local runtime for it again. The canonical, correctly-configured record for the same persona sometimes gets zero process spawned at all; the fabricated identity takes its place.

Net effect: repeated ghost/duplicate identities for the same persona name (e.g. two "Honey" entries in the DM picker), which relay-side archiving cannot permanently fix because the desktop keeps minting a new one on the next launch.

2. Every Claude-backed agent enters "needs configuration" at launch, independent of (1)

Every Claude-backed agent — fabricated identity or not — enters ACP setup mode (BUZZ_ACP_SETUP_PAYLOAD set) at launch, surfacing "complete Claude Code authentication by running the Claude CLI" in the channel. This reproduces even for a persona whose local record and identity are entirely correct, and predates the 312-commit pull mentioned above — it was the original symptom that led to this investigation.

We ruled out the obvious causes before filing:

  • claude auth status succeeds directly in a terminal (exit 0, valid session).
  • The desktop process's own inherited PATH already contains the directory where claude is installed (confirmed via reading the live process's environment).
  • The login-shell fallback probe Buzz uses internally (/bin/zsh -l -c 'command -v -- "$1"' _ claude) also succeeds when run manually, exit 0, correct path.
  • This isn't the previously-fixed stale-negative-PATH-cache class of bug (PR #6904) — cache lifetime is per-process and this fails on the very first probe of a fresh launch, every time.

Given (1) and (2) correlate 100%-with-backend (every Claude-backed agent fails both; every non-Claude-backed agent in the same batch succeeds at both), we suspect a code path that special-cases backend == claude for identity/session provisioning, but did not track down the exact call site.

Environment

  • Buzz Desktop dev build, just dev, macOS (Darwin 25.6.0)
  • Self-hosted relay, single machine, no second-device install involved (distinct from #2648)
  • claude CLI installed at a location on PATH, claude auth status reports a valid claude.ai (Max) session throughout

Repro

  1. Configure several managed agents across mixed backends (Claude + at least one non-Claude, e.g. grok or a local model), all with start_on_app_launch: true.
  2. Fully quit and relaunch Buzz Desktop.
  3. For each spawned buzz-acp process, inspect its environment (ps eww -ww -p <pid>):
    • Non-Claude-backed agents: no BUZZ_ACP_SETUP_PAYLOAD, correct canonical pubkey.
    • Claude-backed agents: BUZZ_ACP_SETUP_PAYLOAD present (CLI-login requirement), and agent_pubkey in that payload does not match any pubkey in managed-agents.json for that persona.
  4. Compare the BUZZ_AUTH_TAG signature of the running process against the auth_tag stored in managed-agents.json for the same persona name — they differ.

Question for maintainers

Is a fresh/isolated identity intentionally provisioned per-launch for Claude-backed agents (e.g. for OAuth session isolation), and if so, should it be persisted and reused rather than re-fabricated on every launch? Or is this an unintended interaction with the cross-device identity-sync path (agent_snapshot_envelope.rs) that also underlies #2648?

Happy to provide the exact ps eww env diffs and signature comparison (with real pubkeys/hostnames), just didn't want to post them in a public issue.

jcg-git avatar Sep 26 '26 20:09 jcg-git

Follow-up: found a second, broader path into the same symptom, and it isn't limited to Claude-backed agents.

Clicking Start on an existing agent card in the Agents grid sometimes shows a "Agent created" toast instead of "Agent started," and the status dot stays grey rather than turning active. This reproduces across every backend, not just Claude — same underlying effect as the identity-fabrication bug above (a fresh identity gets minted instead of the existing one being resumed), just triggered from the manual Start button rather than launch-time auto-restore.

Root cause (frontend, confirmed by reading the source): each card in desktop/src/features/agents/ui/UnifiedAgentsSection.tsx picks its click handler based on whether an existing ManagedAgent was matched for that persona:

agent ? (
  ...
  onStart={() => agent.needsRestart ? onRestartAgent(agent.pubkey) : onStartAgent(agent.pubkey)}
) : (
  ...
  onStart={() => onStartPersona(persona)}   // create-new path
)

When agent comes back undefined for a persona that does have a valid existing record, the card silently falls into the onStartPersona → createAgentMutation branch (useManagedAgentActions.ts, handleStartPersona), which shows "Agent created" and mints a new identity rather than starting the existing one.

The match itself is buildUnifiedGroups (desktop/src/features/agents/ui/unifiedAgentGroups.ts), keyed on persona.id === agent.personaId. Checked the local managed-agents.json directly — persona_id is intact and well-formed on every record inspected (a builtin id like builtin:honey and a plain-UUID custom persona id both present and correctly shaped), so the managed-agent side of the join looks fine. That points at the other side — how the persona catalog itself is loaded/keyed — as the more likely place the join is breaking, but I didn't track down the exact call site.

Given this reproduces for agents on backends that otherwise launch cleanly (i.e., not just the Claude-specific readiness/identity issue described above), it's possibly the shared root cause behind both reports: whatever changed in the persona-catalog loading path during the recent main pull broke persona↔agent matching broadly, and the Claude-specific readiness failure just happens to be the most visible symptom of it.

jcg-git avatar Sep 26 '26 20:09 jcg-git

Likely related to #7836 ("Desktop readiness ignores per-agent auth environment and blocks signed-in Claude accounts"), which root-causes a more precise version of the same failure mode: readiness.rs::collect_missing_requirements doesn't pass the agent's effective environment into cli_login::requirements, and readiness/cli_probe.rs::login_probe only overrides PATH — so the startup readiness probe and the actual launched agent can end up consulting different account/environment state. That matches what I found independently reading the same files while investigating this report's Bug 1 (needs configuration for Claude-backed agents that are actually fine).

One difference worth flagging for whoever triages both: #7836's reproduction requires a per-agent CLAUDE_CONFIG_DIR pointing at a different, authenticated account while the desktop's default account is logged out. In our case there's no per-agent CLAUDE_CONFIG_DIR anywhere, and the default account is logged in (claude auth status succeeds, valid claude.ai session) — yet every Claude-backed agent still fails the readiness gate 100% of the time, while every non-Claude-backed agent in the same launch batch succeeds. So either this report's Bug 1 is the same defect surfacing through a different environment discrepancy than CLAUDE_CONFIG_DIR (worth checking what else EffectiveAgentEnv carries that the probe doesn't), or it's a second, separate cause producing an identical symptom. Either way, #7836's fix direction — thread the effective environment through the probe with the same precedence as actual agent startup — looks like the right general fix and may resolve both.

jcg-git avatar Sep 27 '26 17:09 jcg-git

Two more concrete leads from continuing to chase this on our own setup (desktop, macOS, just dev), neither yet confirmed as the definitive root cause but both specific enough to be worth sharing.

1. Claude Code's OAuth/subscription auth depends on macOS Keychain reads, separate from API-key auth

security find-generic-password -s "Claude Code-credentials"   → present in the login keychain
~/.claude/.credentials.json                                    → plaintext fallback also present

claude --help documents this directly: its --bare flag exists specifically to skip "prefetches, keychain reads, ... Anthropic auth is strictly ANTHROPIC_API_KEY or apiKeyHelper ... OAuth and keychain are never read" in that mode. So subscription/OAuth login is Keychain-dependent by design, distinct from API-key auth.

We separately hit a real, reproducible Keychain-access failure for Buzz's own agent-key storage this week: keyring unavailable: Platform secure storage failure: User interaction is not allowed when Buzz was spawned without a normal interactive session (background/non-GUI launch context). If Buzz's internal readiness-probe subprocess doesn't get the same Keychain access an interactive terminal session does, claude auth status run by Buzz could plausibly fail to read an OAuth token from Keychain and report "not authenticated," while the identical command run directly in a terminal succeeds — matching #7836's core finding that the probe and the real launch can end up consulting different effective auth state, just naming a specific mechanism (Keychain ACL/session-context, not only env vars like CLAUDE_CONFIG_DIR).

2. resolve_command's app-lifetime cache can go stale across a live Claude Code self-update

Claude Code self-updates by swapping ~/.local/bin/claude (a symlink) to point at a new versioned binary under ~/.local/share/claude/versions/, while the old binary file stays on disk unless/until cleaned up. On our setup:

~/.local/share/claude/versions/2.1.283   mtime 2026-09-26
~/.local/share/claude/versions/2.1.285   mtime 2026-09-29 (just now)
~/.local/bin/claude -> .../2.1.285        symlink re-pointed same moment

desktop/src-tauri/src/managed_agents/discovery.rs's resolve_command caches a resolved command's absolute path "for the app lifetime," explicitly to avoid re-running the (expensive) login-shell resolution on every cheap discovery call. A long-running Desktop session (ours has been up since before this Claude update) would have cached the old binary's path the first time it resolved claude, then kept using that stale path after the self-update repointed the symlink to a new version. If the newer Claude Code version rotated/re-signed its credential format on update (a plausible and common pattern), the old cached binary could fail to read the new credential state and report "not authenticated," even though the current binary (which any fresh terminal command always resolves to, since a terminal never holds a stale cache) reads it fine.

This would explain a report pattern we independently hit: Claude-backed agents authenticate and work correctly for a while, then start reporting "needs configuration" specifically after a Claude Code version update lands while Buzz Desktop keeps running uninterrupted — no config change, no Buzz restart, just time passing and a background CLI update. A full Buzz Desktop restart (clearing the in-process cache) is a plausible, cheap way to test this distinction: if agents that were failing come back to life on Claude after nothing but a restart, this cache is very likely at least part of the story. Haven't yet confirmed the credential-rotation half of this (i.e., whether the older binary genuinely can't read the newer credential state) — that would need reproducing with two pinned Claude Code versions side by side, which we haven't set up.

Sharing both in case either narrows things down; happy to help verify further with more specific repro steps if useful.

jcg-git avatar Sep 29 '26 20:09 jcg-git