agentpair

module
v0.0.0-...-b9c1f37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2026 License: MIT

README ΒΆ

AgentPair

Go CI Go Lint Go SAST Go Report Card Docs Visualization License

Agent-to-agent pair programming between Claude and Codex.

AgentPair orchestrates pair programming sessions between AI agents. One agent works on the task while the other reviews, iterating until completion or max iterations reached.

Features

  • 🀝 Paired mode: Claude and Codex work together, one implements while the other reviews
  • πŸ‘€ Single-agent mode: Run --claude-only or --codex-only for simpler tasks
  • πŸŒ‰ Bridge communication: JSONL-based messaging with SHA256 deduplication
  • πŸ”Œ MCP integration: Agents communicate via Model Context Protocol tools
  • πŸ” Review modes: claude, codex, or claudex (both review)
  • πŸ–₯️ tmux support: Side-by-side terminal panes for watching agents work
  • 🌲 Git worktree isolation: Each run can use an isolated worktree
  • πŸ’Ύ Session persistence: Resume runs from any state
  • πŸ“Š Live dashboard: Monitor active runs in real-time
  • πŸ”„ Auto-update: Self-updating binary

Installation

go install github.com/plexusone/agentpair@latest

Or build from source:

git clone https://github.com/plexusone/agentpair
cd agentpair
go build -o agentpair ./cmd/agentpair

Prerequisites

  • Go 1.21+
  • claude CLI (Claude Code)
  • codex CLI (OpenAI Codex)
  • Optional: tmux for side-by-side view
  • Optional: Git for worktree isolation

Quick Start

# Paired session (Codex works, Claude reviews)
agentpair --prompt "Implement a REST API for user management"

# Claude as primary worker
agentpair --agent claude --prompt "Add unit tests for the auth module"

# Single-agent mode
agentpair --claude-only "Refactor the logging system"
agentpair --codex-only "Fix the memory leak in cache.go"

# With tmux side-by-side view
agentpair --tmux --prompt "Implement OAuth2 authentication"

# With git worktree isolation
agentpair --worktree --prompt "Experimental feature X"

Usage

agentpair [flags] [prompt]

Flags:
  -p, --prompt string       Task prompt (or provide as argument)
  -a, --agent string        Primary worker: claude or codex (default "codex")
  -m, --max-iterations int  Maximum loop iterations (default 20)
      --proof string        Proof/verification command (e.g., "go test ./...")
      --review string       Review mode: claude, codex, claudex (default "claudex")
      --done string         Custom done signal (default "DONE")
      --claude-only         Run Claude in single-agent mode
      --codex-only          Run Codex in single-agent mode
      --tmux                Use tmux for side-by-side panes
      --worktree            Create git worktree for isolation
      --run-id int          Resume by run ID
      --session string      Resume by session ID
  -v, --verbose             Verbose output

Commands:
  dashboard    Show live dashboard of active runs
  bridge       Show bridge status for a run
  update       Check for and install updates
  version      Print version information

Architecture

github.com/plexusone/agentpair/
β”œβ”€β”€ cmd/agentpair/          # CLI entry point
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ agent/              # Agent interface
β”‚   β”‚   β”œβ”€β”€ claude/         # Claude CLI wrapper (NDJSON protocol)
β”‚   β”‚   └── codex/          # Codex App Server client (JSON-RPC 2.0)
β”‚   β”œβ”€β”€ bridge/             # Agent-to-agent messaging
β”‚   β”‚   β”œβ”€β”€ bridge.go       # JSONL storage with SHA256 dedup
β”‚   β”‚   └── server.go       # MCP server for bridge tools
β”‚   β”œβ”€β”€ loop/               # Orchestration state machine
β”‚   β”œβ”€β”€ run/                # Run persistence (~/.agentpair/runs/)
β”‚   β”œβ”€β”€ review/             # PASS/FAIL signal parsing
β”‚   β”œβ”€β”€ tmux/               # tmux session management
β”‚   β”œβ”€β”€ worktree/           # Git worktree automation
β”‚   β”œβ”€β”€ dashboard/          # Live dashboard UI
β”‚   β”œβ”€β”€ config/             # Configuration and paths
β”‚   β”œβ”€β”€ logger/             # Structured logging (slog)
β”‚   └── update/             # Auto-update mechanism
└── pkg/jsonl/              # JSONL utilities

How It Works

State Machine
init β†’ working β†’ reviewing β†’ working β†’ ... β†’ complete
                    ↓                           ↑
                  fail β†β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  1. Init: Run created, agents starting
  2. Working: Primary agent executes the task
  3. Reviewing: Secondary agent reviews the work
  4. Complete: Both agents signal DONE/PASS
  5. Failed: Max iterations reached or agent error
Bridge Communication

Agents communicate through a JSONL bridge file with MCP tools:

  • send_to_agent: Send a message to the other agent
  • receive_messages: Get pending messages
  • bridge_status: Check bridge state

Message types:

  • task: Initial task or follow-up work
  • result: Work output
  • review: Review feedback
  • signal: Control signals (DONE, PASS, FAIL)
  • chat: Free-form discussion
Review Modes
Mode Behavior
claude Only Claude reviews
codex Only Codex reviews
claudex Both review; consensus required

Configuration

Create ~/.agentpair/config.yaml:

agent: codex
max_iterations: 20
review_mode: claudex
done_signal: DONE
use_tmux: false
use_worktree: false
verbose: false
timeout: 2h

CLI flags override config file values.

Run Persistence

Runs are stored in ~/.agentpair/runs/{repo-id}/{run-id}/:

~/.agentpair/runs/
└── github-plexusone-myrepo/
    └── 1/
        β”œβ”€β”€ manifest.json      # Run metadata
        β”œβ”€β”€ bridge.jsonl       # Agent messages
        └── transcript.jsonl   # Audit log

Resume a run:

agentpair --run-id 5
agentpair --session abc123

Development

# Run tests
go test -v ./...

# Run tests with race detection
go test -race ./...

# Lint
golangci-lint run

# Build
go build -o agentpair ./cmd/agentpair
Test Coverage
Package Status
pkg/jsonl βœ“
internal/bridge βœ“
internal/config βœ“
internal/logger βœ“
internal/loop βœ“
internal/review βœ“
internal/run βœ“
internal/tmux βœ“
internal/worktree βœ“

Dependencies

License

MIT

Directories ΒΆ

Path Synopsis
cmd
agentpair command
Package main provides the CLI entry point for agentpair.
Package main provides the CLI entry point for agentpair.
internal
agent
Package agent defines the Agent interface and common types.
Package agent defines the Agent interface and common types.
agent/claude
Package claude implements the Claude agent via the Claude SDK WebSocket server.
Package claude implements the Claude agent via the Claude SDK WebSocket server.
agent/codex
Package codex implements the Codex agent via the Codex App Server.
Package codex implements the Codex agent via the Codex App Server.
bridge
Package bridge provides agent-to-agent communication via JSONL files.
Package bridge provides agent-to-agent communication via JSONL files.
config
Package config provides configuration types and path management.
Package config provides configuration types and path management.
dashboard
Package dashboard provides a live terminal UI for monitoring active runs.
Package dashboard provides a live terminal UI for monitoring active runs.
logger
Package logger provides structured logging utilities for agentpair.
Package logger provides structured logging utilities for agentpair.
loop
Package loop provides the main orchestration for agent-to-agent pair programming.
Package loop provides the main orchestration for agent-to-agent pair programming.
review
Package review provides PASS/FAIL signal parsing and consensus logic.
Package review provides PASS/FAIL signal parsing and consensus logic.
run
Package run provides run management and state persistence.
Package run provides run management and state persistence.
tmux
Package tmux provides tmux session management for side-by-side agent panes.
Package tmux provides tmux session management for side-by-side agent panes.
update
Package update provides auto-update mechanism for the agentpair binary.
Package update provides auto-update mechanism for the agentpair binary.
worktree
Package worktree provides git worktree automation for isolated run environments.
Package worktree provides git worktree automation for isolated run environments.
pkg
jsonl
Package jsonl provides utilities for reading and writing JSONL (JSON Lines) files.
Package jsonl provides utilities for reading and writing JSONL (JSON Lines) files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL