Skip to content

Comments

feat: migrate relay integration to relaycast Rust SDK#455

Open
willwashburn wants to merge 3 commits intocli-uses-brokerfrom
relaycast-crate
Open

feat: migrate relay integration to relaycast Rust SDK#455
willwashburn wants to merge 3 commits intocli-uses-brokerfrom
relaycast-crate

Conversation

@willwashburn
Copy link
Member

@willwashburn willwashburn commented Feb 22, 2026

Summary

  • migrate Relay WS/HTTP integration to the published relaycast crate APIs
  • update relay dependency to relaycast 0.2.4
  • require handler_agent_id for command.invoked mapping and route commands only to the targeted broker

Validation

  • cargo check
  • cargo test

Open with Devin

Copy link
Collaborator

@khaliqgant khaliqgant left a comment

Choose a reason for hiding this comment

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

Nice. Much cleaner

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 6 additional findings in Devin Review.

Open in Devin Review

metadata: None,
};

match relay.register_agent(request).await {
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 register_agent_with_workspace_key always returns None for workspace_id, losing it from the registration response

The new SDK-based register_agent_with_workspace_key hardcodes None for the workspace_id tuple element at src/auth.rs:336, whereas the old code extracted the workspace_id field from the API response JSON.

Detailed Explanation

The old code extracted workspace_id from the registration response:

let workspace_id = data
    .get("workspace_id")
    .and_then(Value::as_str)
    .map(ToOwned::to_owned);
return Ok((agent_id, returned_name, token, workspace_id));

The new code always returns None:

return Ok((agent.id, agent.name, agent.token, None));

In finish_session (src/auth.rs:295-297), the workspace_id is resolved as:

let workspace_id = workspace_id_from_register
    .or(workspace_id_hint)
    .unwrap_or_else(|| "ws_unknown".to_string());

Since workspace_id_from_register is now always None, resolution depends entirely on workspace_id_hint. This hint is populated from cache (src/auth.rs:220-222) or from create_workspace (src/auth.rs:238). However, when a user sets RELAY_API_KEY in the environment and no cache file exists (first run, or cache was cleared), workspace_id_hint is None and no fresh workspace is created (the env key succeeds directly). The resulting workspace_id becomes "ws_unknown", which is persisted in the cache and carried forward to all subsequent sessions via rotate_token (src/auth.rs:195).

Impact: In the env-key-no-cache scenario, workspace_id is permanently set to "ws_unknown" instead of the real value from the API. This affects any downstream logic or logging that relies on a valid workspace_id.

Prompt for agents
In src/auth.rs, line 336, the register_agent_with_workspace_key function returns None for the workspace_id (4th tuple element). If the relaycast SDK's Agent struct includes a workspace_id field (or if it can be obtained from the RelayCast client after registration), use that value instead of None. If the SDK truly doesn't provide workspace_id in the registration response, consider making a separate workspace info API call to resolve it rather than falling back to 'ws_unknown'. Alternatively, if workspace_id is not critical, document this intentional change.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Apply changes to src/relaycast_ws.rs to align broker RelayCast plumbing with SDK-first auth/bootstrap and event/channel mapping.
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.

2 participants