feat(broker): expose RELAY_AGENT_NAME to PTY children even when skip_relay_prompt#1018
feat(broker): expose RELAY_AGENT_NAME to PTY children even when skip_relay_prompt#1018khaliqgant wants to merge 5 commits into
Conversation
…relay_prompt A wrapper launcher that the broker spawns as a PTY child — e.g. the `agentworkforce` CLI, which then spawns the real harness itself rather than being the harness — needs the broker-assigned worker name to wire the relaycast MCP for that harness under the SAME identity the broker routes messages to. Otherwise a persona launched this way registers under a different (or no) name and can't exchange messages with the team. Previously RELAY_AGENT_NAME was set only when `!skip_relay_prompt`, and persona spawns use skip_relay_prompt. Set RELAY_AGENT_NAME for every PTY child; keep RELAY_AGENT_TOKEN / RELAY_AGENT_TYPE / RELAY_STRICT_AGENT_NAME gated behind `!skip_relay_prompt` since those configure the broker's own injected MCP — exactly what skip_relay_prompt opts out of. A launcher that wires its own relaycast server supplies them itself. Pairs with AgentWorkforce/workforce, where the agentworkforce CLL reads RELAY_AGENT_NAME + RELAY_API_KEY and injects the relaycast MCP into the persona's harness spec. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
✅ Files skipped from review due to trivial changes (5)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe change refactors environment variable injection for PTY workers in the broker's worker registry. ChangesPTY Worker Identity Environment Setup
Sequence Diagram(s)sequenceDiagram
participant WorkerRegistry
participant apply_pty_relay_agent_env
participant ChildProcess
WorkerRegistry->>apply_pty_relay_agent_env: call(assigned_name, skip_relay_prompt, Command)
apply_pty_relay_agent_env->>ChildProcess: unset RELAY_AGENT_CHILD_ENV_KEYS
apply_pty_relay_agent_env->>ChildProcess: set RELAY_AGENT_NAME (always)
apply_pty_relay_agent_env->>ChildProcess: optionally set RELAY_AGENT_TOKEN / RELAY_AGENT_TYPE / RELAY_STRICT_AGENT_NAME
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Code Review
This pull request modifies crates/broker/src/worker.rs to ensure that the broker-assigned worker name (RELAY_AGENT_NAME) is always exposed to PTY child processes, even when skip_relay_prompt is enabled. Other environment variables, such as RELAY_AGENT_TOKEN, RELAY_AGENT_TYPE, and RELAY_STRICT_AGENT_NAME, remain gated behind the skip_relay_prompt check. There are no review comments, and I have no feedback to provide.
There was a problem hiding this comment.
No issues found across 1 file
You’re at about 92% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.
Why
This is the broker half of giving Agent Relay personas the ability to message the team. (Workforce half: AgentWorkforce/workforce#170.)
When the broker spawns a regular harness (claude/codex/…), it recognizes the CLI and auto-wires the relaycast MCP. But a persona is launched via the
agentworkforceCLI, which is a wrapper: the broker's PTY child isagentworkforce, and the real harness (claude) is a grandchild the broker never sees. So the broker can't wire relaycast for it — theagentworkforceCLI has to, by injecting a relaycast MCP server into the harness spec it builds.To do that under the same identity the broker routes to, the launcher needs the broker-assigned worker name. The broker already passes
RELAY_API_KEY/RELAY_BASE_URL/RELAY_DEFAULT_WORKSPACEto every child viaworker_env, butRELAY_AGENT_NAMEwas set only when!skip_relay_prompt— and persona spawns useskip_relay_prompt: true. So the launcher had no way to know its assigned name.What changed
crates/broker/src/worker.rs: setRELAY_AGENT_NAMEfor every PTY child. The token / type / strict-name vars stay gated behind!skip_relay_prompt— those configure the broker's own injected MCP, which is exactly whatskip_relay_promptopts out of; a launcher that wires its own relaycast server supplies them itself (the workforce side setsRELAY_AGENT_TYPE/RELAY_STRICT_AGENT_NAMEin the MCP server's env block it injects).Behavior is unchanged for the
!skip_relay_promptpath (all four vars still set) and for headless agents (PTY-only via thematches!guard). The only delta:skip_relay_promptPTY children now also getRELAY_AGENT_NAME(an identity hint a normal harness ignores; a wrapper launcher uses).Testing
cargo check -p agent-relay-broker— cleancargo test -p agent-relay-broker --lib worker::— 39 passed, 0 failed🤖 Generated with Claude Code