Skip to main content
A Code turn is a tool loop like Chat’s, with two differences that define the product: the tools operate on a real repository inside an isolated guest, and the mode you choose decides which tools the model is offered at all.

The workspace catalog

All of these run inside the attached guest. python is a Chat tool; a Code turn runs the guest’s own Python through bash.

Attach before the first command

If the session names a repository and no runtime is attached, the harness starts one, attaches it, and prepares the environment before the first tool runs. An unattached runtime is never the first thing a turn does. See Cloud runtimes.

Modes decide the tools

Ask and Plan withhold the mutating tools in the harness. The model cannot edit or run anything in those modes because it is never offered the tools. See Ask, Plan, Agent.

Stopping

A turn ends when the model stops calling tools or you press Stop (Esc in the CLI). Code does not copy Chat’s eight-round budget; a coding task legitimately takes many tool rounds. Cancel aborts the stream and tells the runtime to stop the turn.

Compaction

Long sessions are compacted with Code’s own keep-set — the current task, open files, recent diffs — so the model keeps fitting in context. Compaction fails closed: an unavailable summariser is an error, not a silent loss of history.

The CLI on top

The CLI drives the same session API with streaming tokens and first-class tool rows. It adds harness-side locks — Plan and Spec keep mutating tools blocked until you switch back or accept the plan — plus approvals, a sandbox policy, and a persisted long-horizon /goal. See Modes and permissions and Goals.
Cortex CLI composer with the Goal chip, rendered in a 40 by 12 terminal

A CLI session with an active goal: the composer border reads Agent — Goal · 2/8, and the agent keeps working toward it across turns.

Compared with Chat and Bot

See How Chat works and How Bot works.