Desktop: stale agent identities accumulate in managed-agents.json when relay URL changes
- Dominant language
- Rust
- Stars
- 32.7k
- Forks
- 4.3k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 253
Description
## Summary
When a user switches the community relay URL (e.g. from `ws://127.0.0.1:3000` → `ws://buzz.test`), new agent keypairs are generated and appended to `managed-agents.json` without removing the stale entries from the previous relay. After a few relay URL changes, the `@mention` picker shows multiple duplicate entries for the same agent name — one per historical relay URL — all labelled "managed by you · not in channel".
## Steps to reproduce
1. Set up a local relay and connect the Desktop to it (e.g. `ws://relay-a`). Agents Fizz/Honey/Bumble are created — 3 entries in `managed-agents.json`.
2. Change the community relay URL to a different host (e.g. `ws://relay-b`). Agents get new keypairs — 3 more entries appended.
3. Repeat once more (`ws://relay-c`) — 3 more entries.
4. Type `@` in any channel message box.
## Expected
Only the 3 agents for the **current** relay URL appear in the mention picker.
## Actual
9 entries appear (3 per historical relay URL), all named Fizz/Honey/Bumble with different npubs and labelled "not in channel".
```
~/Library/Application Support/xyz.block.buzz.app/agents/managed-agents.json
```
contains entries like:
```json
[
{ "name": "Bumble", "pubkey": "npub1xxx...", "relay_url": "ws://old-relay" },
{ "name": "Bumble", "pubkey": "npub1yyy...", "relay_url": "ws://new-relay" },
...
]
```
## Suggested fix
When saving a new relay URL for a community, remove (or archive) managed-agent entries whose `relay_url` no longer matches any active community. Alternatively, scope the mention picker to only show agents whose `relay_url` matches the current community.
## Environment
- Buzz Desktop v0.5.8, macOS (arm64)
Contributor guide
Assessment
This issue has not been assessed yet.