Skip to content

Commit 3f293f1

Browse files
barryollamabarryonthecapeclaudegithub-actions[bot]willwashburn
authored
fix(broker): record workspace_id from agent registration response (#1175)
* fix(broker): record workspace_id from agent registration response 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> * style: auto-format Rust code with cargo fmt * fix(broker): bump relaycast to 4.1.1 for workspace_id field 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. --------- Co-authored-by: Barry Cape <barryonthecape@icloud.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Will Washburn <will.washburn@gmail.com>
1 parent 86ad9b4 commit 3f293f1

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

crates/broker/src/relaycast/auth.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -699,12 +699,7 @@ impl AuthClient {
699699
.register_or_get_agent(request)
700700
.await
701701
.map_err(relay_error_to_anyhow)?;
702-
return Ok((
703-
result.id,
704-
result.name,
705-
result.token,
706-
None, // workspace_id not returned in CreateAgentResponse
707-
));
702+
return Ok((result.id, result.name, result.token, result.workspace_id));
708703
}
709704

710705
loop {
@@ -717,12 +712,7 @@ impl AuthClient {
717712

718713
match relay.register_agent(request).await {
719714
Ok(result) => {
720-
return Ok((
721-
result.id,
722-
result.name,
723-
result.token,
724-
None, // workspace_id not returned in CreateAgentResponse
725-
));
715+
return Ok((result.id, result.name, result.token, result.workspace_id));
726716
}
727717
Err(RelayError::Api { code, status, .. })
728718
if is_conflict_code(&code) || status == 409 =>
@@ -1068,20 +1058,24 @@ mod tests {
10681058
unsafe {
10691059
std::env::set_var("AGENT_RELAY_WORKSPACE_KEY", "rk_live_env");
10701060
}
1061+
// The register response now carries workspace_id, so a join-by-key
1062+
// session records the real workspace instead of the "ws_unknown"
1063+
// fallback — no extra lookup required.
10711064
let register = server.mock(|when, then| {
10721065
when.method(POST)
10731066
.path("/v1/agents")
10741067
.header("authorization", "Bearer rk_live_env");
10751068
then.status(200)
10761069
.header("content-type", "application/json")
1077-
.body(r#"{"ok":true,"data":{"id":"a2","name":"lead","token":"at_live_2","status":"online","created_at":"2025-01-01T00:00:00Z"}}"#);
1070+
.body(r#"{"ok":true,"data":{"id":"a2","workspace_id":"ws_env","name":"lead","token":"at_live_2","status":"online","created_at":"2025-01-01T00:00:00Z"}}"#);
10781071
});
10791072

10801073
let client = AuthClient::new(server.base_url());
10811074

10821075
let session = client.startup_session(Some("lead")).await.unwrap();
10831076
assert_eq!(session.token, "at_live_2");
10841077
assert_eq!(session.credentials.api_key, "rk_live_env");
1078+
assert_eq!(session.credentials.workspace_id, "ws_env");
10851079
register.assert_hits(1);
10861080

10871081
unsafe {

0 commit comments

Comments
 (0)