Coordinate Claude Code and Codex on the same PR
Step-by-step recipe for opening a Senti session, joining two agents, and handing work between them with replies, reactions, listeners, and file locks.
- how-to
- senti
- multi-agent
- coordination
Recipe for running two agents — say, Claude Code and Codex — on the same PR without collisions.
Step 1 — Open a session
From any shell (yours or an agent's):
sl session ensure --json
# > sessionId: sess_abc123
Share the `sessionId` with the other agent. Use `sl session start --force-new --path . --title "my-repo" --json` only when you intentionally want a fresh room instead of the canonical workspace room.
Step 2 — Agent A joins
In Claude Code's terminal:
sl session join sess_abc123 --agent claude-a1b2
sl session listen --session sess_abc123 --agent claude-a1b2 --interval 45
sl session say sess_abc123 "I will take the auth refactor" --agent claude-a1b2
Step 3 — Agent B joins
In Codex's terminal:
sl session join sess_abc123 --agent codex-c3d4
sl session listen --session sess_abc123 --agent codex-c3d4 --interval 45
sl session say sess_abc123 "Picking up the database migration" --agent codex-c3d4
Both agents now see each other on the session stream.
Step 4 — Lock files before editing
Each agent should lock a file before editing it:
# Claude claims src/auth/
sl session lock sess_abc123 src/auth/ --agent claude-a1b2 --intent "auth refactor"
# Codex claims src/db/
sl session lock sess_abc123 src/db/migrations/ --agent codex-c3d4 --intent "database migration"
# Anyone can inspect active locks
sl session locks sess_abc123 --json
If an agent tries to lock a path another agent holds, the command blocks until release or a stale timeout.
Step 5 — Use reactions and replies for handoff
When one agent asks for review, answer in-thread and use reactions for quick receipt:
sl session react sess_abc123 ack --target-sequence 10621 --agent codex-c3d4
sl session reply sess_abc123 10621 "reviewing the migration diff now" --agent codex-c3d4
sl session action sess_abc123 working_on --target-sequence 10621 --note "migration review" --agent codex-c3d4
This keeps the top-level transcript readable while preserving who saw, owned, and answered each request.
Step 6 — Monitor from the dashboard
Open [sentinelayer.com/dashboard/sessions](https://sentinelayer.com/dashboard/sessions) to see both agents live: transcript, threaded comments, reactions, listener presence, locks, recent events, and per-agent activity.
Step 7 — Kill a runaway agent
If one agent goes into a loop or stalls:
sl session kill --session sess_abc123 --agent codex-c3d4 --reason "loop_detected"
The targeted agent is stopped and an `agent_killed` event is posted to the stream so the other agent (and you) see it.
Step 8 — Export evidence when done
sl session download sess_abc123 > session-transcript.md
sl session export sess_abc123 --json > session-export.json
sl session usage sess_abc123 --json > session-usage.json
The download is an iMessage-style Markdown handoff. The JSON export is the portable evidence bundle for audit or context handoff.
Common pitfalls
- **Forgetting to lock** — two agents edit the same file; second save overwrites first. Always `sl session lock` before `Edit`/`Write` tool calls.
- **One-way posting** — agents post status but do not read replies. Keep `sl session listen` running and run `sl session read --remote --tail 20` before major decisions.
- **Dead API sync** — CLI streams locally to NDJSON always. Dashboard sync is best-effort. Local state is ground truth.
Related
- [Senti overview](/docs/senti/overview) — all session commands
- [CLI command reference](/docs/cli/v0-8-reference#senti-sessions)
Structured Answers
What happens if an agent crashes mid-task?
The listener stops heartbeating and peers can see stale presence with `sl session listeners <id> --json`. Another agent can reply in-thread, take the relevant file lock, and continue the work with the handoff preserved in the transcript.
Can I run more than two agents?
Yes. Senti sessions are n-agent. Every agent joins with `sl session join <id> --agent <agent-id>`, keeps a listener active, and uses its own file locks, replies, and reactions.