fix(persona): restore agent-relay MCP injection for spawn-modal personas#191
Conversation
Persona spawns passed skipRelayPrompt: true to the broker, which not only skips broker-side MCP arg injection (harmless — the agentworkforce wrapper is not a CLI the broker recognizes) but also suppresses the RELAY_AGENT_NAME / RELAY_AGENT_TOKEN env stamps on the worker. The workforce CLI's resolveRelayMcpFromEnv requires RELAY_API_KEY + RELAY_AGENT_NAME, so it silently skipped its own relay-MCP injection and persona harnesses launched without the agent-relay MCP. Drop the flag so the broker stamps the env, and export AGENT_RELAY_BIN to the broker (inherited by workers) so the workforce CLI's `agent-relay-broker mcp-args --register` path resolves the same binary Pear runs instead of a PATH lookup that fails in packaged installs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Your free trial PR review limit of 300 PRs has been reached. Please upgrade your plan to continue using CodeAnt AI. |
📝 WalkthroughWalkthroughThe broker's binary resolution and workforce persona spawning are refactored to enable relay MCP injection. The return type of ChangesBroker Relay MCP Injection
Possibly Related PRs
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
3 similar comments
|
pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
|
pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
|
pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
|
ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed. pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
|
pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
|
ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed. pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
|
pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
|
ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed. pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
Review follow-up: the AGENT_RELAY_BIN value was reverse-engineered from the shim env key (PEAR_AGENT_RELAY_BROKER_BINARY ?? binaryPath); have the resolver own that distinction explicitly instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Your free trial PR review limit of 300 PRs has been reached. Please upgrade your plan to continue using CodeAnt AI. |
Full review (high effort: 7 finder angles → 1-vote verify)No blocking findings. Verified across pear + the relay broker (Rust) + the workforce CLI:
Applied review cleanup (76c2f2c): Non-blocking notes / follow-ups (out of scope for this PR):
🤖 Generated with Claude Code |
|
pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/broker.test.ts (1)
867-878:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAdd a regression assertion for broker-start
AGENT_RELAY_BINwiring.This update guards
skipRelayPrompt, but the PR also changes broker-start spawn env contract. Please assert that the spawned broker options includeenv.AGENT_RELAY_BINto keep that path regression-covered.Proposed test addition
expect(local.spawnPty).not.toHaveBeenCalledWith(expect.objectContaining({ skipRelayPrompt: true })) + const brokerSpawnOpts = mock.HarnessDriverClient.spawn.mock.calls.at(-1)?.[0] as { + env?: Record<string, string> + } | undefined + expect(brokerSpawnOpts?.env?.AGENT_RELAY_BIN).toEqual(expect.any(String))As per coding guidelines
**/*.test.{js,ts,tsx}: Add regression tests when touching broker start, event streaming, PTY buffering, spawned personas, or integration notifications. Include duplicate/replay cases, not just the happy path.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/broker.test.ts` around lines 867 - 878, Add a regression assertion ensuring the spawned broker process receives AGENT_RELAY_BIN in its env: add an expectation alongside the existing spawnPty checks that validates local.spawnPty was called with an options object containing env: expect.objectContaining({ AGENT_RELAY_BIN: expect.any(String) }) (use expect.objectContaining and expect.any(String) to avoid coupling to the exact value) so the broker-start spawn env contract is covered; place this assertion near the other expect(local.spawnPty)... checks that validate args and skipRelayPrompt.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/main/broker.test.ts`:
- Around line 867-878: Add a regression assertion ensuring the spawned broker
process receives AGENT_RELAY_BIN in its env: add an expectation alongside the
existing spawnPty checks that validates local.spawnPty was called with an
options object containing env: expect.objectContaining({ AGENT_RELAY_BIN:
expect.any(String) }) (use expect.objectContaining and expect.any(String) to
avoid coupling to the exact value) so the broker-start spawn env contract is
covered; place this assertion near the other expect(local.spawnPty)... checks
that validate args and skipRelayPrompt.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b5f37cf1-6b68-44ee-85a9-5f7c50ae78bd
📒 Files selected for processing (2)
src/main/broker.test.tssrc/main/broker.ts
|
pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
|
ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed. pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
|
pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
1 similar comment
|
pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
|
ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed. pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
|
pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
1 similar comment
|
pr-reviewer could not complete review for #191 in AgentWorkforce/pear. |
Problem
Selecting a persona in the spawn modal launches an agent whose harness has no agent-relay MCP — it can't message, check inbox, or appear properly on the relay.
Root cause
spawnPersonaWithModepassedskipRelayPrompt: trueto the broker's spawnPty, on the assumption that the workforce CLI (agentworkforce agent <persona>) would inject the relay MCP itself from the broker env.But in the broker (
relay/crates/broker/src/worker.rs),skip_relay_promptsuppresses both:agentworkforceisn't a CLI the broker recognizes, so this is a no-op anyway), andRELAY_AGENT_NAME/RELAY_AGENT_TOKENenv stamps on the worker process.The workforce CLI's
resolveRelayMcpFromEnvrequiresRELAY_API_KEYandRELAY_AGENT_NAME; with the name stamp suppressed it silently skips its own injection, so the inner harness launches with no relay MCP at all. (Direct claude/codex spawns work because the broker injects--mcp-config/--config mcp_servers.*for recognized CLIs.)Fix
skipRelayPrompt: truefrom the persona spawn. The broker now stampsRELAY_AGENT_NAME/RELAY_AGENT_TOKEN/RELAY_AGENT_TYPE/RELAY_STRICT_AGENT_NAMEon the worker; the wrapper command is unchanged (verified:detect_cli_name('agentworkforce')matches no injection or bypass-flag branch).AGENT_RELAY_BINon the broker process (inherited by workers) so the workforce CLI's broker-awareagent-relay-broker mcp-args --registerinjection resolves the same broker binary Pear runs — a bare PATH lookup fails in packaged installs and can hit a version-skewed global binary in dev. Without it the CLI still works via the legacy@relaycast/mcpfallback, but the pre-registered path is the intended one.Testing
vitest run src/main/broker.test.ts— 59/59 pass, including a new regression assertion that persona spawns do not setskipRelayPrompt.npm test— 109/109 pass.tsc -p tsconfig.node.json— no new errors vs HEAD baseline.Note: requires Pear restart (new broker process env) to take effect; existing running brokers won't have
AGENT_RELAY_BINbut the persona env-stamp fix applies on the next spawn through a restarted broker.🤖 Generated with Claude Code