Skip to content

fix(desktop): dial managed agents on the configured relay URL, not the canonical runtime key#2446

Open
lewiswang0516 wants to merge 1 commit into
block:mainfrom
lewiswang0516:fix/agent-relay-url-normalization
Open

fix(desktop): dial managed agents on the configured relay URL, not the canonical runtime key#2446
lewiswang0516 wants to merge 1 commit into
block:mainfrom
lewiswang0516:fix/agent-relay-url-normalization

Conversation

@lewiswang0516

Copy link
Copy Markdown

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 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 with a community configured as ws://localhost:3000:

  • the UI posts messages into the localhost:3000 community
  • every agent connects to the 127.0.0.1:3000 community, which is empty

Each agent logs discovered 0 channel(s) and no 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_url itself:

Connection code may retain the configured URL; this canonical form is for identity, receipts, status and deduplication.

Fix

Keep the canonical key for identity, receipts, and log paths. Dial the caller-supplied requested URL:

  • spawn_agent_child dials its relay_url parameter verbatim; runtime_key stays identity-only
  • start_managed_agent_process, start_pair, and the launch restore path 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 echo
  • probe_agent_relay_access probes over the requested URL, so the spawn-eligibility probe hits the same community the child will join
  • start_pair now fills requested_relay_url in its status rows, and the Active Communities settings card prefers requestedRelayUrl for start/stop/restart, so a manual restart re-dials the configured URL

Testing

  • cargo test --manifest-path desktop/src-tauri/Cargo.toml --lib: 1560 passed
  • cargo clippy --all-targets and cargo fmt --check on the Tauri crate: clean
  • tsc --noEmit and biome check on the changed frontend file: clean
  • Honest gap: no new automated test covers the spawn wiring itself, since spawn_agent_child forks 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 with BUZZ_RELAY_URL=ws://127.0.0.1:3000 (checked via ps eww) and discover 0 channels; the configured community URL is ws://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

@lewiswang0516
lewiswang0516 requested a review from a team as a code owner July 23, 2026 00:44
…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>
@lewiswang0516
lewiswang0516 force-pushed the fix/agent-relay-url-normalization branch from 46a7820 to 1c55f81 Compare July 23, 2026 00:47

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Desktop 0.4.23 spawns managed agents on ws://127.0.0.1:3000 while the community uses ws://localhost:3000 - agents silently stop responding

1 participant