CodeWork
Agent

How the Agent Works

What happens between a prompt and an answer.

CodeWork is a loop around a model. You send a prompt, the model answers or asks for a tool, CodeWork runs the tool and returns the result, and the model goes again. The loop ends when the model answers without a tool call.

A run, step by step

  1. You send a prompt. It’s saved to the session before any work starts.
  2. CodeWork builds the request. It holds the system prompt, the conversation so far, and the session’s tools.
  3. The model responds. It streams text, and reasoning on models that support it. It may call tools.
  4. CodeWork runs the tools. Each one runs in the session’s sandbox, the environment where its files live and its commands run. The output, or the error, goes back to the model.
  5. Repeat until the model answers without a tool call.

Each model response is one turn. A prompt usually takes several.

Tool calls from one response run one after another. Set model.toolExecution to parallel in your settings to run them at the same time.

Streaming output

InterfaceWhat it shows
codework runThe answer on stdout. Header and usage on stderr.
ACP editorsThe answer, reasoning, and each tool call
RPC serverEvery event, through event.subscribe

Because the answer goes to stdout on its own, you can redirect it to a file:

codework run "Summarize the open TODOs in this repo" > todos.md

The system prompt

The system prompt is a short base prompt plus your project’s AGENTS.md or CLAUDE.md files. See Instructions.

Retries

CodeWork retries rate limits, overloads, server errors, timeouts, and dropped connections. The model never sees the failed attempt.

By default it retries up to 3 times, waiting 2 seconds and doubling each time, up to 60 seconds. If the provider asks to wait longer than that, the turn fails. Quota, billing, bad request, and prompt-too-long errors are never retried.

Change the limits with retry in your settings.

Sending more while it works

codework run and ACP editors send one prompt at a time. If an editor sends a second prompt while the session is busy, CodeWork rejects it.

With the RPC server, thread.prompt takes a delivery field:

deliveryWhen the model sees it
steer (default)Before its next model request, mid-task
followUpAfter the current work. Queued one at a time.

codework run --server <url> --session <id> sends a follow-up, so it waits until the current work is done.

Until the model picks up a waiting prompt, you can still change it:

RPC methodWhat it does
thread.queueLists the waiting prompts, in the order they were sent
thread.cancelWithdraws one
thread.updateRewrites one, or switches it between steer and followUp, in place

Stopping a run

InterfaceHow to stop
codework runctrl-c. With --server, it stops that thread.
ACP editorsThe stop button (session/cancel). It stops that thread.
RPC serverthread.interrupt for one thread, session.interrupt for all

Stopping ends the response and any running tool calls. CodeWork records those calls as aborted. Prompts still waiting stay queued. The session is kept, so you can send another prompt when you’re ready.

Output limit

If a reply hits the model’s output limit in the middle of tool calls, those calls don’t run. The model gets them back as errors and is asked to send them again in full. After two such replies in a row, the run ends.

When the last reply was cut off, codework run prints Response was truncated: the model reached its output token limit. and exits with 1.

Crashes and restarts

When codework serve starts, it resumes any runs that a crash or shutdown cut off:

  • A reply that was streaming is kept as aborted and hidden from the model. The request counts as a failed attempt under Retries.
  • Tool calls that had finished keep their results. Calls that were still running are recorded as aborted and never run again. The model can call them again if it needs to.

A run cut off by 5 crashes in a row isn’t resumed. It ends with a session.run.failed event, and its waiting prompts stay queued for your next run. A shutdown doesn’t count toward the 5. A run you stopped yourself is never resumed.

No permission prompts

CodeWork never asks before it acts. Every tool runs as soon as the model calls it. Work in a git repository so you can review and undo changes easily. Use a sandbox for work you don’t want on your machine.