buzz icon indicating copy to clipboard operation
buzz copied to clipboard

fix(desktop): reuse managed agents on team deploy instead of force-minting

Open matthewdcage opened this issue 4 months ago • 0 comments

Summary

Fixes #3639.

Deploy team to channel always passed forceNewInstance: true for every persona, which bypassed findReusablePersonaAgent() in provisionChannelManagedAgent() and minted a fresh Nostr keypair on each deploy — even when the same persona was already attached to the channel with a running managed instance.

This PR:

  1. Removes forceNewInstance: true from AddTeamToChannelDialog.tsx so team deploy follows the same reuse path as single-agent deploy.
  2. Adds findPersonaAgentInChannel() and short-circuits provisioning when the persona is already in-channel (no mint, no duplicate member attach).
  3. Refreshes batch deploy context after each attach so subsequent personas in the same team deploy see updated channel membership.
  4. Adds buzz agents draft-update --pubkey for disambiguation when multiple agents share a display name (#2423 mitigation).
  5. Adds harness roster refresh (agents_roster.rs) so the ACP pool picks up managed-agent block changes without restart.
  6. Documents Instance pubkey in the nest AGENTS.md table for operator clarity.

Root cause (confirmed on origin/main)

// AddTeamToChannelDialog.tsx (main)
forceNewInstance: true,  // ← bypasses reuse for every persona

Live reproduction (ai-advantage community)

Repeated Deploy team to channel on the same team/channel grew channel bot membership from 12 distinct running instances to ~24 pubkeys with duplicate display names. Manual cleanup via buzz channels remove-member for stale pubkeys restored 12 canonical instances.

Related issues

Issue Relationship
#3639 Primary — this PR fixes the team-deploy mint bypass
#2648 Second-install mint on same machine — not fixed here
#2973 Archive failure leaves ghost channel members — workaround unchanged
#2423 --pubkey draft-update mitigation included
#3204 Agent picker confusion worsened by duplicates — scope boundary
#2910 Same-owner team-deploy collision — improved by reuse, not fully deduped server-side

Out of scope

  • Backend dedup in create_managed_agent by persona_id
  • Agent picker filtering by running state (#3204)
  • Archive/remove-member UX (#2973)

Testing

Verified locally on branch fix/team-deploy-agent-reuse (rebased on latest origin/main):

Command Result
cargo test -p buzz-cli agent_management 4 passed
cargo test -p buzz-acp --lib extract_managed 1 passed
cargo clippy -p buzz-cli -p buzz-acp -- -D warnings pass
node --test desktop/src/features/agents/agentManagement.test.mjs 10 passed
cargo test --manifest-path desktop/src-tauri/Cargo.toml nest::tests 42 passed
just desktop-tauri-fmt pass

Manual test plan

  • [ ] Deploy a team to a channel once → N agents created (one per persona)
  • [ ] Deploy the same team to the same channel again → no new keypairs, existing instances reused
  • [ ] Channel member list shows one pubkey per persona display name
  • [ ] buzz agents draft-update --pubkey <hex> --name "…" targets the correct agent when names collide

matthewdcage avatar Jul 29 '26 23:07 matthewdcage