Skip to content

One engineer with two sessions

You can run more than one agent at a time. Each session gets its own branch and worktree, and Zentri keeps the agents out of each other’s files. This guide starts two sessions, shows what happens when both reach for the same file or the same function, and how to clear the way.

  • zt logged in, with role engineer or above. See an engineer’s day.
  • tmux, which zt start uses to run each agent.
  • Claude Code, Codex, or OpenCode as the agent. These three get the hooks that claim each file before an edit. Any other agent gets only the git pre-commit hook, which warns and never blocks.

Every user brings their own agent credentials. Zentri never collects, proxies, stores, or resells model access or consumer subscription tokens.

Layer When it acts What it does
Worktree and branch At zt start Each session works in its own git worktree on its own zentri/... branch.
File claims Before each edit The edit hook claims the file for the session. One session at a time holds a path in a project, and that includes your own other sessions. A held file blocks the edit.
Plans When the agent calls zentri_submit_plan The coordinator compares the plan’s files, symbols, and summary with the other live sessions and reports each overlap.
Snapshots At each git commit The pre-commit hook sends the staged change. The coordinator compares its public symbols with the other sessions’ and warns about the same or a near-duplicate name.

Claims are the only layer that blocks. Plans and snapshots only inform.

Terminal window
cd ~/src/reports
zt start "add CSV export to the reports page"
Started session 3f9a12bc for intent 7d0e44a1 (new).
branch zentri/add-csv-export-to-the-reports-page-<id>
worktree /home/ana/.local/share/zentri/worktrees/reports/add-csv-export-to-the-reports-page-<id>
Attach with: zt attach 3f9a12bc

Run zt start again from the same clone, with a different task:

Terminal window
zt start "fix the date format in the report header"

The coordinator checks the second task against your first one like any other work. A different task starts at once. When the second task is close to the first, zt shows the match and asks first:

Match with your own work Choices Default
active_duplicate merge, queue, run_anyway, fork none
partial_overlap run_anyway, queue run_anyway

Two engineers on the same task explains what each choice does.

Terminal window
zt status
Logged in to https://zentri.example.com as @ana (engineer).
Sessions on this machine:
3f9a12bc running, agent running add CSV export to the reports page
branch zentri/add-csv-export-to-the-reports-page-<id> worktree /home/ana/.local/share/zentri/worktrees/reports/add-csv-export-to-the-reports-page-<id>
8b7e21d4 running, agent running fix the date format in the report header
branch zentri/fix-the-date-format-in-the-report-header-<id> worktree /home/ana/.local/share/zentri/worktrees/reports/fix-the-date-format-in-the-report-header-<id>
No new notices.

With two live sessions, zt attach and zt done need the session. Without one they list your sessions and stop:

error: 2 live sessions on this machine; name one with zt attach SESSION:
3f9a12bc add CSV export to the reports page
8b7e21d4 fix the date format in the report header

Attach to one with its ID or its last 4 or more characters, for example zt attach 21d4. Detach with the tmux prefix and d to leave it running.

Say the first agent edits reports/header.go. Its edit hook claims the file first. When the second agent tries to edit the same file, its hook asks for the claim, the coordinator denies it, and the hook refuses the edit with this message to the agent:

Zentri: another session holds a file this edit would change.
- reports/header.go is held by @ana (session 3f9a12bc, working on "add CSV export to the reports page")
Work on something else, or ask the holder to release it, then retry. Do not write the file another way.

The message lists up to five held files, then - and N more. The session that holds the file gets a notice too:

- @ana's session asked for reports/header.go, which you hold. Release it when you are done.

Both sessions are yours, so both messages name you. The session ID tells them apart.

A session holds a claim until one of these happens:

Event How
The agent releases it Tell the holding agent to call zentri_release_file with the path.
The session ends zt done 3f9a12bc releases every claim of the session.
The session stops sending heartbeats A claim lives 30 minutes past the last heartbeat. The zentri window in each session’s tmux session sends one every minute, so a live session keeps its claims.

An agent can also ask the holder directly with zentri_post_note, naming the path. The note reaches whichever live session holds it. After the claim is gone, tell the waiting agent to retry the edit.

5. When a shell command changes a held file

Section titled “5. When a shell command changes a held file”

Agents also change files through shell commands, such as a code generator or sed. After each shell command, the hook claims every file the worktree shows as changed. When one of them is held by another session, the hook does not undo anything. It tells the agent:

Zentri: your last shell command changed files that another session holds.
- reports/header.go is held by @ana (session 3f9a12bc, working on "add CSV export to the reports page")
Revert those files now (git checkout -- <path> for a tracked file; delete a new one), and leave them alone until the holder releases them.

Both sessions also get an unclaimed_edit notice, so the holder knows to check the file before writing it again.

Claims stop two sessions from editing one file. They do not notice two sessions writing the same function in two different files. Plans and snapshots cover that.

An agent that calls zentri_submit_plan gets every overlap in the tool result, by reason, most direct first:

Reason Meaning
file A planned file or directory covers another session’s live claim or a file in its plan.
symbol A planned public symbol is one another session plans or changes.
similar_symbol A planned symbol is close to one another session plans or changes.
summary The plan’s summary is close to another plan’s summary.

Each other session it overlaps gets one notice, for example:

- @ana's plan overlaps yours: reports/header.go; a similar summary. Agree who does what with a note.

At each commit, the pre-commit hook sends a snapshot of the staged change. It finds the public symbols the change adds or changes in Go, TypeScript, TSX, JavaScript, JSX, Python, and SQL files. The coordinator compares them with the other live sessions’ latest snapshots and plans. The person or agent that commits sees each overlap on stderr:

zentri: overlap_symbol: your func FormatDate in reports/export.go; @ana (session 3f9a12bc) has func FormatDate in reports/header.go

overlap_symbol is the same kind and name. symbol_near_duplicate is the same kind and a similar name, and its line ends with the similarity, such as (similarity 0.71). Both sessions also get a notice:

- @ana also changes func FormatDate (reports/header.go). Agree on one version before you both ship it.

The pre-commit hook never blocks a commit. When the commit includes a file another session holds, it warns and commits anyway:

zentri: warning: this commit changes files another session holds:
- reports/header.go is held by @ana (session 3f9a12bc, working on "add CSV export to the reports page")
zentri: committing anyway; talk to the holder before you push.

Notices about claims and overlaps go to the session, not to zt status. The agent gets up to three of the most urgent ones each time you send it a prompt and when it starts, under Zentri notices:. When more wait, the last line says N more. Call zentri_check_inbox. The agent reads them all with zentri_check_inbox.

Terminal window
zt done 3f9a12bc
zt done 8b7e21d4

Each zt done stops that agent, releases its claims, and keeps its branch and worktree. Ship each branch on its own, as in an engineer’s day.

Symptom Cause and fix
An agent’s edit is refused with another session holds a file this edit would change The other session holds the file. Release it there, end that session, or have the agent work on something else first.
An edit is refused with Zentri coordinator unreachable. Wait and retry this edit. The edit hook needs an answer from the coordinator before each edit. A project can let edits go ahead when the coordinator is down with its edits_fail_open setting, which a lead or admin changes through PATCH /v1/projects/{project_id}. No zt command sets it.
A claim seems stuck after a laptop slept The session sent no heartbeat while the machine slept. Its claims expire 30 minutes after the last one, or end at once with zt done.
zt attach prints 2 live sessions on this machine Name the session, as in step 3.
The second zt start exits 2 It matched your first session and there is no terminal to ask on. Rerun with --resolution NAME.
  • A claim covers a whole file. Two sessions cannot edit different parts of one file at the same time.
  • Edit-time claims work for Claude Code, Codex, and OpenCode only. Other agents can claim with zentri_claim_file if they choose to, and get the pre-commit warning. See generic MCP agents.
  • Symbol overlap reads public symbols in Go, TypeScript, JavaScript, Python, and SQL files. Other files are not compared by symbol.
  • The near-duplicate signal compares name trigrams. On the project’s labeled pairs its precision and recall are both near 0.7, so expect misses and false alarms.
  • No zt command lists claims. The agent sees the files it holds with zentri_context.
  • Overlap notices reach the agents, not your terminal, except the lines the pre-commit hook prints.