Conversation
There was a problem hiding this comment.
Code Review
This pull request implements namespacing for Codex bridge tools by introducing a bridgeToolName helper and updating guidance prompts across the codebase to use namespaced tool names (e.g., mcp__loop_bridge__...). The reviewer suggests centralizing the BridgeTool type and the quotedBridgeTool helper within bridge-guidance.ts to eliminate duplication and improve maintainability across paired-loop.ts and tmux.ts.
src/loop/bridge-guidance.ts
Outdated
| import { BRIDGE_SERVER, CLAUDE_CHANNEL_USER } from "./bridge-constants"; | ||
| import type { Agent } from "./types"; | ||
|
|
||
| type BridgeTool = "bridge_status" | "receive_messages" | "send_message"; |
There was a problem hiding this comment.
The BridgeTool type is used in multiple files (paired-loop.ts, tmux.ts). Exporting it from here centralizes the definition and avoids duplication.
| type BridgeTool = "bridge_status" | "receive_messages" | "send_message"; | |
| export type BridgeTool = "bridge_status" | "receive_messages" | "send_message"; |
References
- When communicating between agents in a paired tmux runtime, use newline-delimited JSON on stdout for agent CLIs, as Content-Length framing can break registration/connection.
| export const bridgeToolName = (agent: Agent, tool: BridgeTool): string => | ||
| agent === "claude" ? tool : codexBridgeToolName(tool); |
There was a problem hiding this comment.
The quotedBridgeTool helper is currently duplicated in paired-loop.ts and tmux.ts. It should be defined once here and exported to improve maintainability. Ensure that the resulting strings are used within newline-delimited JSON for agent communication.
| export const bridgeToolName = (agent: Agent, tool: BridgeTool): string => | |
| agent === "claude" ? tool : codexBridgeToolName(tool); | |
| export const bridgeToolName = (agent: Agent, tool: BridgeTool): string => | |
| agent === "claude" ? tool : codexBridgeToolName(tool); | |
| export const quotedBridgeTool = (agent: Agent, tool: BridgeTool): string => | |
| '"' + bridgeToolName(agent, tool) + '"'; |
References
- When communicating between agents in a paired tmux runtime, use newline-delimited JSON on stdout for agent CLIs, as Content-Length framing can break registration/connection.
src/loop/paired-loop.ts
Outdated
| acknowledgeBridgeDelivery, | ||
| readNextPendingBridgeMessage, | ||
| } from "./bridge-dispatch"; | ||
| import { bridgeToolName } from "./bridge-guidance"; |
There was a problem hiding this comment.
Import the shared quotedBridgeTool helper from bridge-guidance.ts to reduce local duplication.
| import { bridgeToolName } from "./bridge-guidance"; | |
| import { bridgeToolName, quotedBridgeTool } from "./bridge-guidance"; |
References
- When communicating between agents in a paired tmux runtime, use newline-delimited JSON on stdout for agent CLIs, as Content-Length framing can break registration/connection.
src/loop/paired-loop.ts
Outdated
| import { hasSignal } from "./utils"; | ||
|
|
||
| const MAX_BRIDGE_HOPS = 12; | ||
| type BridgeTool = "bridge_status" | "receive_messages" | "send_message"; |
There was a problem hiding this comment.
src/loop/paired-loop.ts
Outdated
| const quotedBridgeTool = (agent: Agent, tool: BridgeTool): string => | ||
| `"${bridgeToolName(agent, tool)}"`; |
There was a problem hiding this comment.
src/loop/tmux.ts
Outdated
| resolveClaudeChannelServerName, | ||
| } from "./bridge-config"; | ||
| import { | ||
| bridgeToolName, |
There was a problem hiding this comment.
Import the shared quotedBridgeTool helper from bridge-guidance.ts instead of defining it locally.
| bridgeToolName, | |
| bridgeToolName, | |
| quotedBridgeTool, |
References
- When communicating between agents in a paired tmux runtime, use newline-delimited JSON on stdout for agent CLIs, as Content-Length framing can break registration/connection.
src/loop/tmux.ts
Outdated
| const quotedBridgeTool = ( | ||
| agent: Agent, | ||
| tool: "bridge_status" | "receive_messages" | "send_message" | ||
| ): string => `"${bridgeToolName(agent, tool)}"`; |
There was a problem hiding this comment.
Summary
bridge-guidance.ts, including sharedBridgeTool,bridgeToolName(...), andquotedBridgeTool(...)helpers so paired and tmux prompts derive the same tool strings from one placeRoot Cause
Codex and Claude do not expose the same bridge tool identifiers. Some prompts still referenced generic tool names even when the available tool was namespaced, and the tool-formatting logic was duplicated across call sites, which made the guidance easier to drift out of sync with the actual MCP surface.
Impact
Paired runs and tmux sessions now tell each agent to call the exact bridge tools available in that environment, and the shared helper path reduces the chance that future prompt changes reintroduce mismatched bridge tool names.
Validation
bun test tests/loop/bridge-guidance.test.ts tests/loop/paired-loop.test.ts tests/loop/tmux.test.tsbun run check