Repository navigation
feat: opt-in durable cross-CLI agent communication through Relay - #500
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: ✨ 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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Devin Review found 4 potential issues.
3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| await this.relay.messaging.messages.send({ channel: this.relay.channel, | ||
| text: `${peer} -> ${this.dispatch.step_id}: ${JSON.stringify(entry.payload.message)}`, | ||
| metadata, idempotencyKey: `${key}-projection` }); |
There was a problem hiding this comment.
🔴 Projection outage fails durable conversation
When channel projection fails after injection, pump rejects the attempt. Relaycast is only a view, but its availability now controls workflow completion.
Learn more
The direct message on lines 75–76 performs the agent injection. The following channel send only creates the human-readable Relaycast projection. Awaiting both in one failure path lets a projection outage reject pump, which rejects the session result in run. The worker then records worker_error even though the durable journal and agent delivery succeeded. This contradicts RFC-0001 settled decision 7, which defines Relaycast as a projection without execution semantics.
Example: Relay injects message offset 4 into reviewer, then publishing designer -> reviewer to wf-... times out. Reviewer may process the message, but the step fails and a retry injects it again instead of continuing the durable conversation.
Recommended fix: Decouple projection publication from delivery success. Record or expose projection failures as non-execution diagnostics, while keeping journal delivery and direct injection failures fail-closed. Preserve a stable projection idempotency key so a later best-effort retry cannot duplicate the observer entry.
Was this helpful? React with 👍 or 👎 to provide feedback.
| const { attachCommunicationWorkers } = await import('../communication/local.js'); | ||
| communicationWorkers = await attachCommunicationWorkers(spec, socketPath, dataDir); | ||
| } |
There was a problem hiding this comment.
🟡 Relay prerequisites bypass preflight
checkFlow accepts communication flows without the Relay packages or workspace key. attachCommunicationWorkers then fails before submission as a protocol error.
Learn more
Communication adds two locally checkable runtime requirements: both optional Relay packages must resolve, and RELAY_API_KEY must contain an existing workspace key. The normal check path only probes each agent CLI. These lines discover both requirements after daemon connection and classify any setup exception through protocolFailure, although the daemon protocol did not fail. RFC-0001 covenant 2 requires submit-time preflight to refuse or warn on every provable assumption.
Example: A machine has Claude installed and authenticated but omits @agent-relay/sdk. flows check conversation.flow.yaml reports success; flows run ... --local-agent connects to the daemon, throws during worker attachment, and exits with protocol_error before creating a run.
Recommended fix: Add explicit communication-environment diagnostics to the check/run preflight boundary. Verify package resolvability, RELAY_API_KEY, and any required local runtime before daemon submission, and return a closed refusal kind rather than protocol_error. Keep the optional imports lazy for ordinary flows.
Was this helpful? React with 👍 or 👎 to provide feedback.
| broker = await HarnessDriverClient.spawn({ workspaceKey, brokerName: prefix, cwd, channels: [], | ||
| ...(process.env.RELAYFLOW_RELAY_BROKER_BIN ? { binaryPath: process.env.RELAYFLOW_RELAY_BROKER_BIN } : {}), | ||
| env: { ...process.env, RELAY_API_KEY: workspaceKey, RELAY_WORKSPACE_KEY: workspaceKey } }); |
There was a problem hiding this comment.
| const helperPath = join(directory, 'tool.mjs'); | ||
| const sockets = new Set<Socket>(); | ||
| let busy = false; | ||
| const server = createServer({ allowHalfOpen: true }, socket => { |
There was a problem hiding this comment.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4aef60f5e3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await this.relay.messaging.messages.send({ channel: this.relay.channel, | ||
| text: `${peer} -> ${this.dispatch.step_id}: ${JSON.stringify(entry.payload.message)}`, | ||
| metadata, idempotencyKey: `${key}-projection` }); |
There was a problem hiding this comment.
Keep observer projection failures out of step execution
When the human-facing channel publication fails after the direct injection succeeds, this awaited projection rejects pump(), which rejects the worker result and completes the agent attempt with worker_error; the next attempt may then reinject a message the agent already received. The wf-* publication is explicitly an observer projection, so a transient channel outage must not turn a durable, successfully injected exchange into a failed run; report the projection failure separately without failing the step.
AGENTS.md reference: AGENTS.md:L45-L49
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3eb8ca1. Configure here.

Explicit
communication.linkslets concurrent agents exchange durable messages through the existing Relay broker and Relaycast injection. Each step retains its declared CLI; Relay supplies its launch/injection behavior. Ordinary flows—including multi-agent DAGs without links—do not load the optional runtime or start a broker.Each directed link lowers to a separate kernel stream. Sends and deliveries are journaled before injection, and only an explicit processing acknowledgement advances the cursor. Resume restores sent/processed history and redelivers unacknowledged messages. Observer channel creation/publication runs independently: failures emit diagnostics without failing or blocking the conversation.
Preflight checks local Relay prerequisites before submission and probes known CLIs under the same filtered environment used for execution. Other interactive CLIs get an honest unverified-auth warning. The broker excludes unrelated ambient credentials; CLI sessions get supported provider authentication and a unique helper token. Missing, incorrect, or cross-session tokens are rejected before journal operations. Local processes still share an OS user/home: this is not isolation against hostile same-user processes.
Dedicated workers opt into the backward-compatible
worker.attach.required_streamsfield, preventing ordinary steps from taking a communicating peer's slot. Resume reattaches ordinary and linked workers, and CLI waiting distinguishes temporary capacity backpressure from a terminal park. Use the matching daemon build: older daemons refuse the new optional attach field.Validation, with literal commands and complete captured output in the review evidence:
01M2Z04VN15G7ATCGZBH2CM785: three sends, deliveries, processing acknowledgements, and successful completions. Each CLI first verified that unrelated/broker credentials were absent and session authentication was present.The final live run used installed Claude/Codex binary paths because this machine's mise wrappers hung under the filtered environment. Gemini lacked Google authentication; OpenCode hit a free-model quota and a rejected configured key. No all-CLI live coverage is claimed.
Current scope: local interactive CLI sessions with shell tools and stream surfaces. Usage is explicitly unmetered; timeouts bound duration. Injection is at-least-once across attempts. Hosted provisioning, the public TypeScript channel API, and permission enforcement are outside this change. No merge or release performed.
Usage and trust boundary · Mixed-CLI example
Note
High Risk
Touches local execution credentials, journal channel semantics, worker dispatch/eligibility, and crash/resume redelivery—security- and correctness-sensitive paths beyond documentation-only changes.
Overview
Adds opt-in live messaging between concurrent local agents when a flow declares
communication.links. Compile expands links into journaled channels, typed agent instructions, and per-step stream surfaces; ordinary multi-agent DAGs without links are unchanged.Runtime:
--local-agentruns dedicated communication workers that journal sends/deliveries/acks, inject inbound messages via Relay PTY, and expose a token-gated shell helper (send/ack/complete). Optional@agent-relay/*peers load lazily;flows check/run/resumerefuse missing workspace key, packages, Node, or broker withprobe_failedbefore touching the daemon. Resume rebuilds conversation history and redelivers unacked messages; observer Relay channel publication failures are non-fatal diagnostics.Safety & scheduling: Filtered broker/agent env (provider creds per CLI, session tokens, no ambient secrets in probes),
managed_cli_unverifiedfor interactive CLIs, unmetered budget warnings, and kernelworker.attach.required_streamsso ordinary steps cannot occupy linked workers. CLI park detection waits on live sibling leases before treating capacity as terminal.Adds schema/docs, example workflows, verification scripts, and broad SDK/kernel tests plus captured live evidence (Claude→Codex→Cursor).
Reviewed by Cursor Bugbot for commit 55e58e7. Bugbot is set up for automated code reviews on this repo. Configure here.