Skip to content

fix(broker): record workspace_id from agent registration response#1175

Merged
willwashburn merged 4 commits into
mainfrom
fix/broker-resolve-workspace-id
Jun 23, 2026
Merged

fix(broker): record workspace_id from agent registration response#1175
willwashburn merged 4 commits into
mainfrom
fix/broker-resolve-workspace-id

Conversation

@barryollama

@barryollama barryollama commented Jun 19, 2026

Copy link
Copy Markdown

Supersedes the original GET /v1/workspace approach on this branch. Per review, we fix it at the source (the engine returns the id) and the broker simply reads it — no extra request.

What

When the broker joins a workspace by key, the agent it registers — and any fleet node it spawns — were enrolled under a phantom ws_unknown workspace, because register_agent_with_workspace_key hardcoded None for the registration's workspace id (CreateAgentResponse didn't carry one). Result: GET /v1/nodes for the real workspace stayed empty even with fleet_nodes_enabled on.

This reads workspace_id from the registration response at both register sites (strict register_or_get_agent and the non-strict register_agent loop), so the session records the real workspace. workspace_id is Option<String>, so against an engine that doesn't return it the value is None and the existing hint/sentinel behavior is unchanged — no new failure mode.

Depends on

  • fix(engine,sdk-rust): return workspace_id from agent registration relaycast#201 — engine returns workspace_id in the registration response and the relaycast Rust SDK exposes it on CreateAgentResponse / Agent.
  • A published relaycast crate carrying that field. This bumps relaycast to =4.0.0; the exact pin may need adjusting to whatever release ships the field. Draft until that crate is published — CI won't resolve relaycast with the field before then.

Verified

Built and tested locally against the relaycast#201 sdk-rust via a [patch.crates-io] override (not committed): cargo check clean (the 3.0.0→4.0.0 bump needs no other migration) and all relaycast::auth::tests pass, including uses_env_workspace_key_without_creating_workspace, updated so its register mock returns workspace_id and asserts the session records ws_env (instead of ws_unknown).

🤖 Generated with Claude Code

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 691dbcd8-cbfc-443d-92fa-f7388bbe857c

📥 Commits

Reviewing files that changed from the base of the PR and between beefe5d and 5ab136a.

📒 Files selected for processing (1)
  • crates/broker/src/relaycast/auth.rs

📝 Walkthrough

Walkthrough

register_agent_with_workspace_key now propagates the workspace_id returned by the RelayCast SDK in both the strict_name early-return and retry-loop success paths, replacing the prior hardcoded None. The test is updated to mock a workspace ID in the agent registration response and verify the session records that real workspace ID.

Changes

Workspace ID propagation from RelayCast agent registration

Layer / File(s) Summary
Workspace ID propagation in both registration paths
crates/broker/src/relaycast/auth.rs
register_agent_with_workspace_key returns result.workspace_id from the RelayCast response instead of None in both the strict_name and non-strict_name success paths.
Test: env workspace key registration includes workspace_id
crates/broker/src/relaycast/auth.rs
uses_env_workspace_key_without_creating_workspace test mocked response now includes workspace_id, and assertions verify the created session's credentials.workspace_id matches the returned value.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • AgentWorkforce/relay#1055: Both PRs modify the broker's relaycast authentication flow around register_agent_with_workspace_key and AGENT_RELAY_WORKSPACE_KEY handling.

Suggested reviewers

  • willwashburn
  • khaliqgant

Poem

🐇 Hops through relaycast skies so blue,
Workspace IDs now come shining through.
No more None on registration's track—
The workspace rides the agent back! 🎯

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description comprehensively covers the problem, solution, dependencies, and testing. However, it does not follow the repository's required template structure. Restructure the description to match the template: add a 'Summary' section, 'Test Plan' section with checkboxes for tests and manual testing, and optional 'Screenshots' section.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: propagating workspace_id from agent registration response in the broker.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/broker-resolve-workspace-id

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Read `workspace_id` from the registration response at both register
sites instead of hardcoding `None`, so a join-by-key session records the
real workspace instead of the "ws_unknown" fallback — with no extra
request. Bumps the `relaycast` SDK to pick up the new field.

Requires a published `relaycast` crate that includes `workspace_id` on
`CreateAgentResponse` / `Agent` (AgentWorkforce/relaycast#201); the
pinned version may need adjusting to whatever release carries it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@barryollama barryollama force-pushed the fix/broker-resolve-workspace-id branch from beefe5d to 1d548af Compare June 19, 2026 15:24
@barryollama barryollama changed the title fix(broker): resolve workspace id after join-by-key registration fix(broker): record workspace_id from agent registration response Jun 19, 2026
@barryollama barryollama marked this pull request as draft June 19, 2026 15:24
The published relaycast 4.0.0 did not carry workspace_id on
CreateAgentResponse, breaking the broker build. 4.1.1 (already on
main) ships the field, so pin to it.
@willwashburn willwashburn marked this pull request as ready for review June 23, 2026 09:33
@willwashburn willwashburn merged commit 3f293f1 into main Jun 23, 2026
46 of 48 checks passed
@willwashburn willwashburn deleted the fix/broker-resolve-workspace-id branch June 23, 2026 14:07
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.

3 participants