Repository navigation
Conversation
…_RUN_TOKEN_FILE) When RELAY_RUN_TOKEN_FILE is set and no rk_ workspace key is configured, the broker runs without any static workspace key: - Registers itself and spawned workers via POST /v1/agents, mints its node via POST /v1/nodes, and releases workers via DELETE /v1/agents/:name, all with the run token read from the file on every request; a 401 re-reads the file and retries once. - Never creates a workspace (fresh-workspace path and create_workspace fail closed whenever a run token file is configured). - Avoids GET /v1/agents/:name with the run token: channel-scope and presence lookups use agent tokens; name collisions fail closed instead of takeover. - Workers get only their own at_live_ token: no workspace key, run token, or RELAY_RUN_TOKEN_FILE in worker env or MCP config. harness-driver: RuntimeSpawnOptions.runTokenFile (or RELAY_RUN_TOKEN_FILE) passes only the file path to the broker and strips RELAY_API_KEY, RELAY_WORKSPACE_KEY, AGENT_RELAY_WORKSPACE_KEY and RELAY_WORKSPACES_JSON. Legacy workspace-key behavior is unchanged. Redaction helpers (Rust and TS) now cover rt_live_. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. Comment |
…ken mode Relaycast #550 agent tokens expire after 15 minutes and run-token mode has no workspace key to take an identity over, so the broker now rotates every agent token it owns via POST /v1/agents/:name/rotate-token (authenticated by the agent's own at_live_), never via takeover or delete-and-recreate: - Rotation is scheduled from token_expires_at (registration or rotation response) at the earlier of 2/3 of the lifetime or 5 minutes before expiry. Transient failures retry within the previous-token grace window; a 401/403 fails closed and is logged without the token value. Unknown expiry is probe-rotated once after 60s. - Broker self: the startup registration's token_expires_at seeds rotation. The node connection uses the node token, so nothing needs reconnecting. - Workers: get RELAY_AGENT_TOKEN_FILE (no static RELAY_AGENT_TOKEN), a per-worker file in a broker-owned 0700 directory, replaced atomically (0600 temp file + rename) on every rotation and removed on release. MCP configs for every CLI carry the file path. Rotation lineage keeps owned cleanup working after the token changes. - Agent Relay MCP server and CLI honor RELAY_AGENT_TOKEN_FILE: stat-cached re-read before every request, no RELAY_API_KEY needed, realtime bridge re-established on rotation with subscriptions kept. Legacy (rk_) mode is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
| } | ||
| let raw: string; | ||
| try { | ||
| raw = fs.readFileSync(this.path, 'utf8'); |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DEPLOY HOLD
Do not merge or release this until all of the following have landed and deployed:
rt_live_run token and opensPOST /v1/agents,DELETE /v1/agents/:name, andPOST /v1/nodesto it.relaycast-runaccess file, and setsRELAY_RUN_TOKEN_FILE.Legacy
rk_behavior is unchanged, so this is inert until a launcher setsRELAY_RUN_TOKEN_FILE. It still needs the server side before anything uses it. Spec: section 4 and the "FINAL Relaycast surface" section ofrelay-briefs/run-token-contract.md.Summary
harness-driver
RuntimeSpawnOptions.runTokenFileoption, withRELAY_RUN_TOKEN_FILEfrom the caller or parent env as a fallback.RELAY_RUN_TOKEN_FILE(the path, never the value).RELAY_API_KEY,RELAY_WORKSPACE_KEY,AGENT_RELAY_WORKSPACE_KEY, andRELAY_WORKSPACES_JSONare stripped. The legacy path is unchanged.Broker run-token mode (enabled when
RELAY_RUN_TOKEN_FILEis set and nork_key is configured)relaycast/run_token.rs:{token, expiresAt}on every request. Nothing is cached, and the token is never copied into env, argv, or files.Debugoutput and error messages are redacted.auth.rs) usesPOST /v1/agentswith the run token. The session holds no workspace key (api_keyis empty).create_workspacefail closed whenever a run token file is configured.ws.rs): all three create paths go throughpost_create_agent, which uses the run token. A name collision returnsAlreadyExistsinstead of callingGET /v1/agents/:nameplus takeover.DELETE /v1/agents/:namewith the run token:GET /v1/agents/:nameis no longer called with the run token. Channel-scope checks use the worker's ownat_live_, and presence probes use the broker's ownat_live_. Attachment downloads also use the broker'sat_live_.node_control.rs) usesPOST /v1/nodeswith the run token, re-reading the file on 401.RELAY_RUN_TOKEN_FILEwas added toINHERITED_RELAY_CREDENTIAL_ENV_KEYS, so workers never inherit the path.spawn_env_varsskips the key variables when the key is empty.rt_live_in Rust (redact.rs, node-mint logs) and TS (cliandcloudredact helpers).Agent token rotation (run-token mode; relaycast #550 tokens expire after 15 minutes)
POST /v1/agents/:name/rotate-token, authenticated by that agent's ownat_live_. It never uses takeover or delete-and-recreate.token_expires_at(registration or rotation response) at the earlier of 2/3 of the lifetime or 5 minutes before expiry; 10 minutes for a 15-minute token.RELAY_AGENT_TOKEN_FILEinstead of a staticRELAY_AGENT_TOKEN. The file holds{token, expiresAt}and lives in a broker-owned 0700 directory (<state>/agent-tokens).RELAY_AGENT_TOKEN_FILEis also scrubbed from inherited env.agent-relay-mcp.ts,lib/sdk-client.ts): both honorRELAY_AGENT_TOKEN_FILEwith noRELAY_API_KEY.@relaycast/sdktakes only a staticapiKeyand has no token provider. The adapter re-reads the file before each request (stat-cached on inode, size, and mtime) and builds the per-request agent client with the current token.Test results
cargo test -p agent-relay-broker -p relay-pty: all suites pass. That is 1575 broker lib tests (7 ignored), 269 relay-pty tests, and the integration suites.RELAY_AGENT_TOKEN, with zerork_/rt_values in its env;rk_key wins over the run token file, and the worker env andspawn_env_varsare unchanged.RELAY_AGENT_TOKEN_FILE, with nork_/rt_/at_values in its env;cargo clippy -p agent-relay-broker -p relay-pty --tests: no new warnings. Two existing warnings remain in test code.vitest:spawn-config.test.ts(5 new run-token cases), the cli/cloud redact tests,lib/agent-token-file.test.ts, and the MCP startup tests pass. The MCP tests check that the token file works without a workspace key and that a rotated token is used on the very next request.packages/clisuite: 2107 passed. The 10 failures are in files that also fail on the base commit locally (bootstrap/entrypoint/product-surfaces/node-definition-loader/bun loader; they need built packages or bun).broker-process.test.tshas 2 failures that also fail on cleanorigin/mainlocally; they are environment-dependent and unrelated.Remaining gaps
PATCH /v1/agents/:namemetadata publish;all_dm_conversations);packages/harnesses) and@agent-relay/sessionread onlyRELAY_AGENT_TOKEN. In run-token mode the native relay tools turn themselves off instead of using a stale token. Supporting the token file there is a follow-up.agent.registerreplies don't passtoken_expires_atthrough yet, so those tokens are rotated once after 60 seconds to learn their expiry.DELETE /v1/runs/:runId/authorityis the server's job (relaycast fix: pass --model flag to spawned CLI processes #559).🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Agent Relay sessions
claudesession79b75307· opened viagh pr create· last active 2026-10-18