Env
The session-owned workspace where turns execute.
An Env is the workspace where model work executes. Turns run in a session's local worktree, isolated from the main repository checkout. A session can also keep task worktrees, each on its own branch, where standalone execution graph nodes run beside the session's own work. Remote execution is not implemented.
Connections🔗
flowchart LR
S[Session] -->|owns and identifies| E[Env]
T[Task] -->|attempts run in| E
N[Execution Graph node] -->|references and leases| E
H[Host] -->|resolves before each turn| E
E -->|working directory| W[Run Worker]
E -->|task worktree kind keeps| R[Task Worktree record]Identity🔗
EnvId::SessionWorktree identifies the session Env by the full persisted session ID, which Session::env_id() returns. The session's existing ownership supplies this binding; there is no separate record for it. A graph node's Env is the one its snapshot names.
EnvId::TaskWorktree identifies a task worktree by its session and a worktree ID that is unique within that session. EnvId::session_id() names the owning session for both kinds. A task worktree has its own branch, wt/<session>-<worktree>, and a directory of the same name beside the session worktree. Both use the first eight characters of each ID, so a session cannot reserve two worktree IDs that share that prefix. TaskWorktreeId::for_node derives a graph node's worktree ID from a hash of its graph and node identities. Graph validation also refuses any other ID that is not 1 to 64 ASCII letters, digits, or -, as a graph started through the session API could name one.
Resolution🔗
Before a turn executes, the host resolves a ResolvedEnv with the validated branch, working directory, and protected main checkout. Bare repositories have no main checkout to protect. Identity alone does not mean a workspace is ready: draft setup, missing-directory failures, and isolation checks retain their existing behavior. The session's project and base-branch metadata remain authoritative; resolution does not freeze a base revision or move a branch. A task worktree must be on its own branch and apart from the main checkout.
Ownership🔗
The session owns provisioning, branch operations, and cleanup. Task completion does not remove the workspace, and attempts in the session worktree remain serialized through the session worker; attempts in a task worktree run beside it and commit only on the worktree's branch. An Env does not select an agent, create a separate conversation, or grant permissions. Execution graph nodes share an Env as readers or hold it exclusively as writers; see Graph Resources.
Deleting or canceling a session settles its task worktrees as Task Worktree describes: only deletion and a cancel the terminal confirmed remove every one.