Clarify Claude reply routing in paired mode#36
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the communication protocols between Claude and Codex agents in paired mode. The primary goal is to improve the clarity and correctness of message routing, ensuring that agents use the appropriate tools for replies and proactive messages, and preventing unintended human interaction in agent-to-agent conversations. These changes aim to streamline the agent collaboration workflow and reduce potential confusion. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refines and clarifies the instructions given to agents (Claude and Codex) in a paired programming/review setup, particularly concerning interactions with the human and the appropriate use of bridge tools. The changes aim to prevent agents from directly answering the human when a response is expected by the peer agent and to provide more precise guidance on when to use send_to_agent or reply. The review comments suggest further improvements by breaking down multi-part instructions into single, distinct lines or parts.push() calls to enhance clarity for the agents and improve prompt readability and maintainability.
| [ | ||
| `Messages from the Codex agent arrive as <channel source="${BRIDGE_SERVER}" chat_id="..." user="${CLAUDE_CHANNEL_USER}" ...>.`, | ||
| 'When you are replying to an inbound channel message, use the "reply" tool and pass back the same chat_id.', | ||
| "Never answer the human when the inbound message came from Codex. Send the response back through the bridge tools instead.", |
There was a problem hiding this comment.
This line contains two distinct instructions. To improve clarity for the agent, it would be better to split them into separate lines.
| "Never answer the human when the inbound message came from Codex. Send the response back through the bridge tools instead.", | |
| "Never answer the human when the inbound message came from Codex.", | |
| "Send the response back through the bridge tools instead.", |
| "Paired mode:", | ||
| `You are in a persistent Claude/Codex pair. Use the MCP tool "send_to_agent" when you want ${peer} to act, review, or answer.`, | ||
| 'Do not ask the human to relay messages between agents. Use "bridge_status" if you need the current bridge state.', | ||
| 'Do not ask the human to relay messages between agents or answer the human on the other agent\'s behalf. Use "bridge_status" if you need the current bridge state.', |
There was a problem hiding this comment.
This line combines multiple instructions. For better clarity for the agent, consider splitting it into separate lines, each with a single instruction.
'Do not ask the human to relay messages between agents.',
'Do not answer the human on the other agent\'s behalf.',
'Use "bridge_status" if you need the current bridge state.',| `Message from ${capitalize(source)} via the loop bridge:`, | ||
| message.trim(), | ||
| "Treat this as direct agent-to-agent coordination. Reply with send_to_agent only when you have something useful for the other agent to act on. Do not acknowledge receipt without new information.", | ||
| "Treat this as direct agent-to-agent coordination. Do not reply to the human.", |
There was a problem hiding this comment.
For better clarity and to ensure each instruction is distinct for the agent, consider splitting this line into two separate instructions. This aligns with the goal of breaking down complex instructions into simpler, more direct ones.
| "Treat this as direct agent-to-agent coordination. Do not reply to the human.", | |
| "Treat this as direct agent-to-agent coordination.", | |
| "Do not reply to the human.", |
src/loop/tmux.ts
Outdated
| "You are in a persistent Claude/Codex pair.", | ||
| 'When Codex sends you an inbound channel message, reply to Codex with the MCP tool "reply" and reuse the same chat_id.', | ||
| 'Use "send_to_agent" only when you need to start a new proactive message to Codex.', | ||
| "Do not ask the human to relay messages between agents. Do not answer the human when Codex is waiting for the response.", |
There was a problem hiding this comment.
To improve clarity for the agent, consider splitting this line into two separate instructions. This ensures each directive is distinct and easy to process.
| "Do not ask the human to relay messages between agents. Do not answer the human when Codex is waiting for the response.", | |
| "Do not ask the human to relay messages between agents.", | |
| "Do not answer the human when Codex is waiting for the response.", |
| parts.push( | ||
| `Your first action is to use "send_to_agent" to tell ${primary}: "Reviewer ready. No task yet. I am waiting for your request." After that, wait for the human or ${primary} to provide a concrete task or review request.` | ||
| `Your first action is to use "send_to_agent" to tell ${primary}: "Reviewer ready. No task yet. I am waiting for your request." After that, wait for ${primary} to provide a concrete task or review request. If the human clearly assigns you separate work in this pane, treat that as a new task. If you are answering ${primary}, use the bridge tools instead of a human-facing reply.` | ||
| ); |
There was a problem hiding this comment.
This parts.push() call adds a long string with multiple concatenated instructions. For better readability and maintainability of the prompt, and to make instructions clearer for the agent, consider breaking this down into multiple parts.push() calls. Each call would add a distinct instruction, which will be separated by double newlines in the final prompt. This aligns with the principle of using newline-delimited messages for agent communication, as outlined in the rules.
For example:
parts.push(
`Your first action is to use "send_to_agent" to tell ${primary}: "Reviewer ready. No task yet. I am waiting for your request."`
);
parts.push(
`After that, wait for ${primary} to provide a concrete task or review request.`
);
parts.push(
`If the human clearly assigns you separate work in this pane, treat that as a new task.`
);
parts.push(
`If you are answering ${primary}, use the bridge tools instead of a human-facing reply.`
);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. This principle extends to structuring prompts for clarity and distinct instructions, ensuring agents process messages correctly.
Summary
replytool for Codex channel replies and keep proactive messages onsend_to_agentVerification
Review