feat: migrate relay integration to relaycast Rust SDK#455
feat: migrate relay integration to relaycast Rust SDK#455willwashburn wants to merge 3 commits intocli-uses-brokerfrom
Conversation
| metadata: None, | ||
| }; | ||
|
|
||
| match relay.register_agent(request).await { |
There was a problem hiding this comment.
🟡 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.
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.
Summary
Validation