Skip to content

fix: isolate Relaycast agent auth#293

Merged
khaliqgant merged 1 commit into
mainfrom
fix/runtime-relaycast-token-audience
Jul 18, 2026
Merged

fix: isolate Relaycast agent auth#293
khaliqgant merged 1 commit into
mainfrom
fix/runtime-relaycast-token-audience

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Jul 18, 2026

Copy link
Copy Markdown
Member

Summary

  • authenticate both ctx.relay.dm() and delivery's default Relaycast sender only with a Relaycast credential
  • prefer RELAY_AGENT_TOKEN, with RELAY_API_KEY retained as the legacy Relaycast fallback
  • reject the Relayfile/workflow WORKFORCE_AGENT_TOKEN rather than sending it to /v1/dm

Root cause

Deployed personas currently receive a Relayfile/workflow JWT in WORKFORCE_AGENT_TOKEN. Both workforce Relaycast send paths selected that token ahead of the real Relaycast token and sent it to cast.agentrelay.com/v1/dm, where the wrong audience correctly produced 401.

This PR fixes the workforce credential boundary. The companion Cloud change will mint/register a stable Relaycast identity and inject RELAY_AGENT_TOKEN separately.

RED-first evidence

Before each implementation, the runtime and mirrored delivery regression tests both failed:

  • expected Bearer tok_agent, received Bearer tok_workflow
  • workflow-token-only unexpectedly returned success instead of failing without a Relaycast credential

The delivery mirror was added after independent review identified it, resetting the review SHA.

Validation

  • pnpm --filter @agentworkforce/delivery test — 19/19 pass
  • pnpm --filter @agentworkforce/runtime build
  • node --test packages/runtime/dist/relay.test.js — 6/6 pass

The full runtime suite has 13 pre-existing local-preview failures in this checkout because the host is Node 25.8 while the preview guard requires patched Node >=26.3.1. The Relaycast regression suites are isolated from that environment gate and pass completely.

@cursor

cursor Bot commented Jul 18, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@khaliqgant, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 58 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a13c1f7d-e685-434b-b3cb-d82573e791cb

📥 Commits

Reviewing files that changed from the base of the PR and between 6bf2dea and 9842804.

📒 Files selected for processing (7)
  • packages/delivery/src/delivery.ts
  • packages/delivery/src/relaycast.test.ts
  • packages/delivery/src/relaycast.ts
  • packages/delivery/src/types.ts
  • packages/runtime/src/local-preview.ts
  • packages/runtime/src/relay.test.ts
  • packages/runtime/src/relay.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/runtime-relaycast-token-audience

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes WORKFORCE_AGENT_TOKEN from the token resolution logic in packages/runtime/src/relay.ts to ensure workflow tokens are not sent to Relaycast, updating the associated tests and warning logs. Feedback highlights that a mirrored implementation of token resolution and warning logs in packages/delivery/src/relaycast.ts also needs to be updated to prevent the same authentication issue.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines 24 to 28
function resolveAgentToken(env: NodeJS.ProcessEnv): string | undefined {
return (
env.WORKFORCE_AGENT_TOKEN?.trim() ||
env.RELAY_AGENT_TOKEN?.trim() ||
env.RELAY_API_KEY?.trim() ||
undefined

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The file packages/delivery/src/relaycast.ts contains a mirrored implementation of token resolution (resolveRelayAgentToken) and warning logs that still reference WORKFORCE_AGENT_TOKEN. Since the goal of this PR is to isolate Relaycast agent auth and reject WORKFORCE_AGENT_TOKEN from being sent to /v1/dm, please update packages/delivery/src/relaycast.ts as well to prevent the same authentication issue there.

@khaliqgant
khaliqgant force-pushed the fix/runtime-relaycast-token-audience branch from f802112 to 109d6d6 Compare July 18, 2026 11:28
@khaliqgant khaliqgant changed the title fix(runtime): isolate Relaycast agent auth fix: isolate Relaycast agent auth Jul 18, 2026
@khaliqgant
khaliqgant force-pushed the fix/runtime-relaycast-token-audience branch 2 times, most recently from a179ff1 to 8b76065 Compare July 18, 2026 11:33
@khaliqgant
khaliqgant force-pushed the fix/runtime-relaycast-token-audience branch from 8b76065 to 9842804 Compare July 18, 2026 11:34
@khaliqgant
khaliqgant merged commit 3667b97 into main Jul 18, 2026
3 checks passed
@khaliqgant
khaliqgant deleted the fix/runtime-relaycast-token-audience branch July 18, 2026 11:40
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.

1 participant