fix(desktop): dial managed agents on the configured relay URL, not the canonical runtime key#2446
Conversation
…e canonical runtime key Since block#2122, spawn paths passed ManagedAgentRuntimeKey.relay_url (the canonical identity form) to spawned children as BUZZ_RELAY_URL. The canonicalizer folds every loopback spelling to 127.0.0.1, but the relay derives the community boundary from the Host header, so a community configured as ws://localhost:3000 had its UI post into the localhost:3000 community while every agent connected to the 127.0.0.1:3000 community. Agents discovered zero channels, logged 'no channel subscriptions resolved - agent will sit idle', and silently never answered mentions. Per the contract documented on buzz_core::relay::normalize_relay_url ('Connection code may retain the configured URL; this canonical form is for identity'), keep the canonical key for identity, receipts, and log paths, and dial the caller-supplied requested URL: - spawn_agent_child dials the relay_url parameter verbatim; the runtime key remains identity-only - start_managed_agent_process, start_pair, and launch restore pass their already-resolved requested URL instead of key.relay_url - reconcile_managed_agent_runtimes forwards the requested community URL to start_pair instead of the canonical form - probe_agent_relay_access probes over the requested URL so the HTTP probe hits the same community the child will join - start_pair now reports requested_relay_url in its status rows, and the Active Communities settings card prefers requestedRelayUrl for start/stop/restart actions so a manual restart re-dials the configured URL rather than the canonical echo No new automated test covers the spawn wiring itself (it forks a real child process); verified with cargo test (1560 passed), clippy, fmt, tsc, and biome. Fixes block#2444 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Lewis Wang <lewis.wang@plusalsostudios.com.au>
46a7820 to
1c55f81
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 46a7820d0d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| : "restart", | ||
| pubkey: runtime.pubkey, | ||
| relayUrl: runtime.relayUrl, | ||
| relayUrl: runtime.requestedRelayUrl ?? runtime.relayUrl, |
There was a problem hiding this comment.
Retain the requested relay URL across status refreshes
For a community configured as ws://localhost:3000, start_pair initially returns the raw URL, but the status event immediately invalidates the runtime query and list_managed_agent_runtimes returns only the canonical key (ws://127.0.0.1:3000). Once that refresh occurs, this fallback sends the canonical URL on a later Start/Restart (for example after a failed or stopped harness), so the child again dials Host 127.0.0.1 and is placed in the wrong community. Persist the configured URL with the runtime or recover it from the configured community before issuing lifecycle actions.
AGENTS.md reference: AGENTS.md:L120-L120
Useful? React with 👍 / 👎.
Fixes #2444
Problem
Since #2122 (shipped in desktop v0.4.23), every managed-agent spawn path passes
ManagedAgentRuntimeKey.relay_url- the canonical identity form - to the child asBUZZ_RELAY_URL. The canonicalizer folds every loopback spelling to127.0.0.1, but the relay derives the community boundary from the Host header. So with a community configured asws://localhost:3000:localhost:3000community127.0.0.1:3000community, which is emptyEach agent logs
discovered 0 channel(s)andno channel subscriptions resolved - agent will sit idle, shows as online, and silently never answers a mention. Full diagnosis with DB evidence is in #2444.This also contradicts the contract documented on
buzz_core::relay::normalize_relay_urlitself:Fix
Keep the canonical key for identity, receipts, and log paths. Dial the caller-supplied requested URL:
spawn_agent_childdials itsrelay_urlparameter verbatim;runtime_keystays identity-onlystart_managed_agent_process,start_pair, and the launch restore path pass their already-resolved requested URL instead ofkey.relay_urlreconcile_managed_agent_runtimesforwards the requested community URL tostart_pairinstead of the canonical echoprobe_agent_relay_accessprobes over the requested URL, so the spawn-eligibility probe hits the same community the child will joinstart_pairnow fillsrequested_relay_urlin its status rows, and the Active Communities settings card prefersrequestedRelayUrlfor start/stop/restart, so a manual restart re-dials the configured URLTesting
cargo test --manifest-path desktop/src-tauri/Cargo.toml --lib: 1560 passedcargo clippy --all-targetsandcargo fmt --checkon the Tauri crate: cleantsc --noEmitandbiome checkon the changed frontend file: cleanspawn_agent_childforks a real child process. Verified the failure mode end to end on the affected machine (v0.4.23, local relay): before the fix, children spawn withBUZZ_RELAY_URL=ws://127.0.0.1:3000(checked viaps eww) and discover 0 channels; the configured community URL isws://localhost:3000.A relay-side follow-up worth discussing separately (also in #2444): folding loopback spellings into one community key on the relay, and surfacing the agent-idle state in the UI instead of only in the log.
🤖 Generated with Claude Code