fix(cli): fleet release honors the persisted workspace route over ambient RELAY_BASE_URL

Merged
AG
2d ago
+421-14

Summary

  • prefer a validated persisted server-selected Relaycast route over ambient RELAY_BASE_URL when no --base-url flag was supplied;
  • keep an explicit conflicting --base-url fail-closed with the existing error;
  • keep broker-session origins non-authoritative and the persisted origin and route-scoped credential paired in the constructed client;
  • extend the lifecycle integration test across spawn, attach, message, list, and release under a conflicting ambient canonical URL;
  • track the separate sandbox-teardown warning follow-up in #1922.

The shared helper covers all workspace-scoped callers, including Fleet/release/attach, Agent, Channel, Message, Capabilities, Observer, Integration, and join-ticket flows.

Fixes #1919.

Red/green proof

With the helper source change reverted:

Test Files  2 failed (2)
Tests       3 failed | 42 passed (45)

The failing cases are the ambient-vs-persisted resolution, exact client credential/origin pairing, and the full persisted Fleet lifecycle route.

With the fix restored:

Test Files  2 passed (2)
Tests       45 passed (45)

Test Plan

  • Tests added/updated
  • Manual testing completed

RelayFlow Proof

  • Change type: bugfix
  • RelayFlow case: 1919-fleet-release-persisted-route

Verification

  • npx vitest run packages/cli/src --maxWorkers=1 — 96 passed, 1 skipped files; 1,993 passed, 11 skipped tests
  • affected-area Vitest run — 6 files, 226 tests passed
  • npm run typecheck
  • npm --prefix packages/cli run lint -- --quiet
  • Prettier and git diff --check

Sandbox release findings

fleet release dispatches the inner worker release and prints its asynchronous acknowledgement; it does not call Cloud's existing sandbox deletion endpoint. Open PR #1672 hardens broker-side process and roster cleanup but does not add provider teardown. The smallest warning follow-up is tracked in #1922.


[!NOTE]
Medium Risk
Changes shared CLI transport resolution used by fleet, integration, and other workspace commands; wrong precedence could misroute API calls, though explicit --base-url conflict handling is unchanged and coverage is strong.

Overview
Fixes workspace-scoped CLI routing so a persisted server-selected Relaycast route (isolated origin + route-scoped API key) wins when --base-url is omitted, even if RELAY_BASE_URL or a broker-session URL points at the canonical gateway.

resolveWorkspaceTransport in sdk-client.ts splits authoritative vs ambient origins: new optional fallbackBaseUrl holds non-authoritative session URLs; precedence is explicit --base-url (fail-closed if it conflicts with the persisted route), then the persisted route, then fallback / RELAY_BASE_URL. Integration retry paths and inbound-target provisioning now pass broker loopback hints via fallbackBaseUrl instead of overwriting baseUrl.

Tests cover persisted-route preference, explicit conflict rejection, client credential/origin pairing, fleet lifecycle routing, integration subscribe, and a RelayFlow 1919-fleet-release-persisted-route red/green proof. Changelog documents the patch under Unreleased.

Reviewed by Cursor Bugbot for commit 2aa0afb1adff8b8454a738abbc764489ba0b1654. Bugbot is set up for automated code reviews on this repo. Configure here.


Agent Relay sessions

  • codex session 01a11a0b · opened via gh pr create · last active 2026-10-08
  • codex session 01a11780 · contributor · pushed commits · last active 2026-10-08