Bidirectional Sandbox is a small proof-of-concept that lets two CLI-based LLM agents collaborate through the same live terminal.
The demo uses plain files as the coordination layer. Codex CLI and Gemini CLI both read the cleaned terminal log, decide on the next step, and queue commands for a tmux-backed terminal session to execute. The result is a simple, inspectable loop where both agents can see what happened and continue from shared evidence.
Most multi-agent demos hide the coordination layer behind an API, server, or framework. This project keeps the mechanism visible:
- A shared terminal is the source of truth.
- A queue file carries commands from agents into the terminal.
- A clean log gives both agents the same readable history.
- tmux keeps the session observable and attachable by a human.
It is intentionally small so the collaboration loop is easy to understand, modify, and extend.
| File | Purpose |
|---|---|
ai-terminal.sh |
Starts the tmux session, injects queued commands, and refreshes the clean log. |
launch-all.sh |
Starts the background engine for normal demo use. |
terminal-session.log |
Raw terminal output captured from tmux. Generated at runtime. |
terminal-clean.log |
ANSI-stripped terminal output read by the agents. Generated at runtime. |
pending-command.txt |
Command queue consumed by the engine. Generated at runtime. |
scripts/queue-command.sh |
Safely appends one validated command to the queue. |
scripts/status.sh |
Prints the tmux, queue, and latest-log status. |
scripts/checkpoint.sh |
Creates a timestamped git checkpoint. |
scripts/clean-logs.sh |
Rebuilds the clean log from the raw terminal log. |
bidirectional-sandbox.desktop |
Desktop launcher for one-click local starts. |
Codex CLI Gemini CLI
| |
| read terminal-clean.log | read terminal-clean.log
| |
| queue commands | queue commands
| |
+---------------+------------------+
|
v
pending-command.txt
|
v
ai-terminal.sh
queue watcher + tmux injector
|
v
tmux session: exp001
|
v
terminal-session.log -> terminal-clean.log
- Bash
- tmux
- Git
- A Unix-like desktop or shell environment
- Two CLI agents, such as Codex CLI and Gemini CLI
On Debian or Ubuntu:
sudo apt install tmux gitStart the demo engine:
./launch-all.shWatch the collaboration log:
tail -f terminal-clean.logAttach to the live terminal:
tmux attach -t exp001Detach from tmux with Ctrl+B, then D.
Each agent should begin its turn by reading the shared state:
cat terminal-clean.log | tail -100Then queue exactly one command:
./scripts/queue-command.sh "./scripts/status.sh"Preview a command without queueing it:
./scripts/queue-command.sh --dry-run "ls -la"The engine consumes one queued line at a time, injects it into tmux, captures the raw output, and refreshes the cleaned log for the next agent turn.
./scripts/status.sh
./scripts/queue-command.sh "ls -la"
./scripts/clean-logs.sh
./scripts/checkpoint.sh "Describe the checkpoint"- Anything in
pending-command.txtexecutes as a shell command in the shared tmux session. - Use
scripts/queue-command.shinstead of writing to the queue by hand. - The queue helper rejects blank commands, multiline commands, and a few high-risk command patterns unless
--yesis supplied. - Runtime logs and queue files are ignored by git.
The static badges at the top work before the repository has any GitHub Actions configured. After publishing, add repository-specific badges such as:
Replace OWNER/REPO after the GitHub repository exists.
Contributions should keep the demo easy to run and easy to inspect.
- Read the current log with
cat terminal-clean.log | tail -100. - Make one focused improvement.
- Run the relevant script checks, usually
bash -n scripts/*.sh ai-terminal.sh launch-all.sh. - Use
./scripts/status.shto verify the local collaboration state. - Create a checkpoint with
./scripts/checkpoint.sh "Short description".
Good next contributions include cleaner log rendering, a small web dashboard, safer command approval flows, GitHub Actions smoke tests, and packaging the desktop launcher.
MIT. See LICENSE.