Add opt-in cross-repo agent messaging (Agents settings toggle)#698
Merged
Conversation
dispatch_send_message and list_agents scope the addressable peer set to the sender's git repo root, so an agent in one repo can't message or see an agent in another. Add an opt-in DISPATCH_CROSS_REPO_MESSAGING env flag that lifts the scoping for local multi-repo workflows; when set, senderRepoRoot is no longer required and every other agent is addressable. Default behavior is unchanged. Adds tests covering both handlers with the flag on, and documents the flag in .env.example. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
niiyeboah
force-pushed
the
feat/cross-repo-messaging
branch
from
June 26, 2026 18:26
284cef9 to
6701fac
Compare
Per security review: when DISPATCH_CROSS_REPO_MESSAGING is enabled, name-based targeting matches across all repos, so recommend agt_ IDs for unambiguous addressing. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Extract addressableAgents() so dispatch_send_message and list_agents share one definition of the visibility boundary (flag check + self-exclusion + repo-root scoping), preventing drift (architecture review #113). - Parse DISPATCH_CROSS_REPO_MESSAGING with strict === "true" to match the codebase convention instead of a third 1/true/yes form (review #115). - Update .env.example and tests accordingly. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
niiyeboah
marked this pull request as ready for review
July 1, 2026 00:04
Per review feedback (Brad), swap the DISPATCH_CROSS_REPO_MESSAGING env var for a setting controlled from the Agents settings page (default off). - cross-repo-messaging-settings.ts: a dedicated accessor module owning the settings key and the "true"/"false" <-> boolean encoding, mirroring agent-type-settings.ts. Both the system route and the MCP handler call isCrossRepoMessagingEnabled / setCrossRepoMessagingEnabled, so the encoding lives in exactly one place (no bare key in db/settings.ts). - mcp-handlers.ts: the gate reads the setting instead of the env var. - system.ts: GET/POST /api/v1/app/settings/cross-repo-messaging. - Frontend: a jotai atom backs the toggle, but the server is authoritative — the component GETs the value on mount to hydrate the atom and only POSTs on an explicit user toggle. This avoids a mount-time write that would otherwise let one device clobber the server-wide gate just by opening settings. Copy reflects the server-wide effect; errors use role="alert"; in-flight requests are sequence-guarded so a stale response can't override newer intent. - Drop the env var from .env.example; update unit tests to drive the setting; add an e2e regression test. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
niiyeboah
force-pushed
the
feat/cross-repo-messaging
branch
from
July 1, 2026 00:08
16759e1 to
04617a6
Compare
Track last server-confirmed value in a ref so the optimistic revert on POST failure restores the correct state instead of blindly using !next (which desyncs after a double-toggle where both POSTs fail). Remove three dead self-exclusion checks in sendMessage — addressableAgents already excludes self at line 129. Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.
Summary
Agent-to-agent messaging (
dispatch_send_messageandlist_agents) scopes the addressable peer set to the sender's git repo root — an agent in one repo can't message or even see an agent in another. That's the right default, but it blocks local multi-repo workflows (e.g. an agent inneocoordinating with an agent inbrane-uis).This adds an opt-in toggle that lifts the scoping. When enabled,
senderRepoRootis no longer required and every other agent is addressable. Default behavior is unchanged (off).How it works
cross_repo_messaging_enabled) in the existingsettingstable, read by the MCP handler for every agent. It is not per-device.Changes
apps/server/src/cross-repo-messaging-settings.ts(new): accessor module owning the settings key and the"true"/"false"↔ boolean encoding —isCrossRepoMessagingEnabled(pool)/setCrossRepoMessagingEnabled(pool, bool). Mirrorsagent-type-settings.ts, so the encoding lives in exactly one place.apps/server/src/server/mcp-handlers.ts: the addressable-peer gate reads the setting via the accessor; the boolean is resolved once per call and threaded into a singleaddressableAgents()helper shared by both message delivery and agent listing.apps/server/src/routes/system.ts:GET/POST /api/v1/app/settings/cross-repo-messaging(mirrors the existing agent-types / IDE settings routes; validatesenabledis a boolean).apps/web:crossRepoMessagingEnabledAtom+ aCrossRepoMessagingSettingscomponent rendered in the Agents settings section. Server-authoritative hydration,role="alert"on errors, and a request-sequence guard against out-of-order responses..env.example; updated unit tests to drive the setting; added an e2e regression test.Testing
pnpm run check(tsc, server + web) — cleanmcp-handlers.test.ts) — 73 pass, incl. the gate logic driven by the settingReview
Reviewed by three persona agents (backend-security, architecture, frontend-ux) — all approved after one round of changes that moved the toggle to a server-authoritative model.
🤖 Generated with Claude Code