Skip to content

Fix Codex bridge tool guidance#57

Merged
axeldelafosse merged 3 commits intomainfrom
codex/fix-loop-bridge-send-message-routing
Apr 1, 2026
Merged

Fix Codex bridge tool guidance#57
axeldelafosse merged 3 commits intomainfrom
codex/fix-loop-bridge-send-message-routing

Conversation

@axeldelafosse
Copy link
Copy Markdown
Owner

@axeldelafosse axeldelafosse commented Apr 1, 2026

Summary

  • centralize bridge tool naming in bridge-guidance.ts, including shared BridgeTool, bridgeToolName(...), and quotedBridgeTool(...) helpers so paired and tmux prompts derive the same tool strings from one place
  • update paired-loop prompts, review handoff guidance, and forwarded bridge prompts to reference the correct bridge tool name for the current agent
  • update paired tmux guidance so Claude uses the dynamic tmux bridge server tool names and Codex uses the loop bridge MCP tool names
  • remove duplicated bridge helper logic from paired-loop and tmux after moving it into the shared guidance module
  • add regression coverage for both resolved bridge tool names and quoted bridge tool names

Root 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.ts
  • bun run check

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

import { BRIDGE_SERVER, CLAUDE_CHANNEL_USER } from "./bridge-constants";
import type { Agent } from "./types";

type BridgeTool = "bridge_status" | "receive_messages" | "send_message";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The BridgeTool type is used in multiple files (paired-loop.ts, tmux.ts). Exporting it from here centralizes the definition and avoids duplication.

Suggested change
type BridgeTool = "bridge_status" | "receive_messages" | "send_message";
export type BridgeTool = "bridge_status" | "receive_messages" | "send_message";
References
  1. 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.

Comment on lines +10 to +11
export const bridgeToolName = (agent: Agent, tool: BridgeTool): string =>
agent === "claude" ? tool : codexBridgeToolName(tool);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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
  1. 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.

acknowledgeBridgeDelivery,
readNextPendingBridgeMessage,
} from "./bridge-dispatch";
import { bridgeToolName } from "./bridge-guidance";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Import the shared quotedBridgeTool helper from bridge-guidance.ts to reduce local duplication.

Suggested change
import { bridgeToolName } from "./bridge-guidance";
import { bridgeToolName, quotedBridgeTool } from "./bridge-guidance";
References
  1. 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.

import { hasSignal } from "./utils";

const MAX_BRIDGE_HOPS = 12;
type BridgeTool = "bridge_status" | "receive_messages" | "send_message";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This type is now exported from bridge-guidance.ts. Removing the local definition avoids redundancy.

References
  1. 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.

Comment on lines +111 to +112
const quotedBridgeTool = (agent: Agent, tool: BridgeTool): string =>
`"${bridgeToolName(agent, tool)}"`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This helper has been moved to bridge-guidance.ts and should be removed from here.

References
  1. 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
resolveClaudeChannelServerName,
} from "./bridge-config";
import {
bridgeToolName,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Import the shared quotedBridgeTool helper from bridge-guidance.ts instead of defining it locally.

Suggested change
bridgeToolName,
bridgeToolName,
quotedBridgeTool,
References
  1. 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
Comment on lines +158 to +161
const quotedBridgeTool = (
agent: Agent,
tool: "bridge_status" | "receive_messages" | "send_message"
): string => `"${bridgeToolName(agent, tool)}"`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This helper is duplicated and should be removed in favor of the shared implementation in bridge-guidance.ts.

References
  1. 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.

@axeldelafosse axeldelafosse changed the title [codex] Fix Codex bridge tool guidance Fix Codex bridge tool guidance Apr 1, 2026
@axeldelafosse axeldelafosse marked this pull request as ready for review April 1, 2026 05:04
@axeldelafosse axeldelafosse merged commit 63a8f23 into main Apr 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant