The coding agent
coder is an interactive agent that works in a code repository. It reads the
code, writes the code, runs the commands and tells you what it changed. It
is the coder-agent package.
Installation
Python 3.10 or newer is needed, and git when the package comes from the
repository.
pip install coder-agent
That is the whole installation. To follow the repository instead:
pip install "coder-agent @ git+https://github.com/sds819/coder-agent".
To change the code, work in a clone:
git clone https://github.com/sds819/coder-agent.git
cd coder-agent
pip install -e ".[full]"
With uv or pipx the package becomes a command on the path:
uv tool install coder-agent
pipx install coder-agent
In a conda environment:
conda create -n coder-agent python=3.11
conda activate coder-agent
pip install coder-agent
The extras
| Extra | What it adds |
|---|---|
| none | The agent: litellm, textual, typer, fastapi |
mcp |
The MCP servers |
sandbox |
The remote sandboxes: swe-rex, modal, boto3, contree-sdk |
web |
The web interface: uvicorn and jinja2 (fastapi is in the core) |
full |
Everything: dev + sandbox + mcp |
pip install "coder-agent[full]"
The files of the installation
| File | What it is |
|---|---|
~/.coderagent/config.yaml |
The configuration of the user: the model, the permissions, the hooks |
~/.coderagent/.env |
The keys of the models. Read at every start |
~/.coderagent/rules.yaml |
The permission rules of the user |
~/.coderagent/CLAUDE.md |
What the agent should remember about you |
<project>/.coderagent/config.yaml |
The configuration of the project |
<project>/.coderagent/rules.yaml |
The permission rules of the project |
Only the key of the model is needed; everything else has a default.
MSWEA_CODER_HOME moves the whole directory of the user somewhere else.
The check
coder --help
coder --list
The command is coder. It opens the terminal interface when the terminal is
interactive, and takes one task and answers when it is not.
The first session
cd my-project
coder
The interface opens in the directory of the project. Type what you want, for
example fix the failing test in tests/test_parser.py, and the agent works
through it. The status bar at the top shows the model, the size of the context,
what the session has cost so far, the sandbox and the permission mode.
Without a terminal there is one turn and then the answer:
coder --task "fix the failing test in tests/test_parser.py"
The keys of the model come from the environment or from the .env file of the
user (~/.coderagent/.env; the file that mini-swe-agent used is read too).
The name of the model is model.model_name in the configuration, or
MSWEA_MODEL_NAME in the environment.
The command line
| Option | What it does |
|---|---|
--task, -t |
The task. Without it, the interface opens when the terminal is interactive. |
--model, -m |
The model of this run |
--config, -c |
A configuration file, or key=value overrides |
--profile, -p |
A named piece of the configuration |
--cwd |
The directory of the session |
--permission-mode |
default, acceptEdits, plan, bypass or readonly |
--output-format |
text (the default) or json |
--output-schema |
A file with the JSON schema the answer has to fit |
--output-last-message |
Write the last answer of the agent to this file |
--resume <id> |
Continue the session with this id |
--continue |
Continue the last session of this directory |
--fork <id> |
Copy the session with this id and continue in the copy |
--list |
The sessions of this directory |
--tui |
Start the interface, even when there is no terminal |
--print is accepted and has no effect.
The overrides of -c are key=value pairs, the key is a path in the
configuration:
coder -c model.model_name=deepseek/deepseek-flash -c permissions.mode=plan
The model
coder model is a command of its own: it shows the settings of the model, writes
them down, or tries them out.
coder model # show the settings
coder model --name X --api-base Y --api-key Z --max-retries N # write them down
coder model --test # try the saved ones out
coder model --test --name X # try these out, write nothing
The try-out and the writing are two steps: --test never writes anything, and
the writing never waits for the try-out. A configuration that does not work yet
is worth writing down, to be fixed later. The exit code is 1 when the try-out
fails, so a script can tell.
The settings are written to the user level file (~/.coderagent/config.yaml); the
project level file is never written. The key on the command line stays in the
history of the shell: the environment variable of the provider is the safer place
for it.
The output
While the agent works, the terminal shows dots that grow and shrink. The line is cleaned when the answer comes. A pipe or a file gets the answer alone: the dots are for a terminal, and the json output is never mixed with them.
The text output is the conversation and one line about the turn:
[stop_reason=end_turn cost=0.0016 session_cost=0.0019 session=20261106-a1b2c3]
cost is what this turn cost, session_cost is what the whole session cost.
The json output has the same numbers in fields:
coder --task "..." --output-format json
{
"session_id": "20261106-a1b2c3",
"messages": [{"role": "assistant", "content": "The test needed a fixture."}],
"cost": 0.0016,
"session_cost": 0.0019,
"stop_reason": "end_turn",
"error": "",
"output": null
}
stop_reason is end_turn, max_turns, cost_exceeded, token_limit, verify_failed,
schema_invalid, interrupted or error. error is empty unless the turn failed.
output is the answer when a schema was asked for with --output-schema, and
null when it was not.
The answer itself goes into a file with --output-last-message:
coder --task "..." --output-last-message answer.md
The file holds the text of the last answer of the agent, nothing else.
The trace of a session
coder export --session 20261106-a1b2c3 --format json --out trace.json
coder export --session 20261106-a1b2c3 --format otel --out trace.otlp
coder export --session 20261106-a1b2c3 --format otel --push
The trace is the event log of the session with the metrics of the session. With
telemetry.otel_endpoint in the configuration, the trace of every turn also
goes to that OpenTelemetry collector. See Trace export.
The terminal interface
While the agent is thinking, the conversation ends with dots that grow and shrink. They go away as soon as it says or does something: the same dots as in the browser.
The card of a tool that is running shows the same dots until the tool is done.
| Key | What it does |
|---|---|
ctrl+c |
Stop the turn that is running — and the tool that is running with it. A second time leaves. |
ctrl+q |
Leave. The session is settled in the memory first. |
ctrl+o |
Open the panel of the sessions. enter continues the one that is picked. |
↑ / ↓ |
Walk through the messages you sent, the way a shell does. |
@ |
Complete the path of a file under the working directory; → takes it. |
When the agent wants to run a tool that needs approval, the interface asks.
y allows it once, n refuses it, a always allows it: that answer writes a
rule into ~/.coderagent/rules.yaml, so the same call — the same file, or the
same command — is allowed from then on, in every session. The refusal goes back
to the model, which then does something else.
The answers are listed one per line, each in a numbered box:
1 [*] y allow
2 [-] n deny
3 [-] a always allow
The box of the picked answer is starred in red, the others have a grey dash.
The arrow keys (←/→ or ↑/↓) move the pick, the numbers jump to an
answer, and enter confirms it.
The answer of the agent is rendered as Markdown: the code blocks, the tables and the lists look the way they look in the README of a project. The text is plain while it arrives, and rendered when it is complete.
When the turn is over the terminal shows a notification. A program of your own may say it in the way you want it:
ui:
notify_command: notify-send
The program is called with the title and the body of the notification:
notify-send coder "the work is done". A program that fails is a warning, not
a broken session. ui.notifications: false turns the notifications off. A
project may not choose the notifier either: that program runs on your machine,
with the answer of the agent in its hands.
A picture goes to the model with /image:
/image screenshot.png what is wrong with this layout?
The agent asks first whether the model takes pictures. A model that cannot see
one would answer about it anyway, and the answer would be made up, so the turn
does not start. model.capabilities says what a model takes:
model:
capabilities:
my/model:
image: true
litellm knows most models. For the ones it does not know — a relay station names its models in its own way — the agent asks the model itself: it shows it a picture of one color and asks what color it is. The answer is written into your own configuration file, so a model is asked only once. Say it there yourself, and the agent never asks.
A file goes to the model with its content in the message, with /mention or by
naming it in the question:
/mention src/app.py what does this do?
A file opens in your editor with /open:
/open src/app.py
The editor is the one you named in the configuration:
ui:
file_opener: vscode
vscode, cursor and windsurf are known by name; a command of your own works
too, with {file} where the file goes: my-editor {file} --wait. The file has to
be inside the working directory. A project may not choose the editor: that
program runs on your machine, so the choice is yours.
The web interface
The same agent, in the browser:
pip install "coder-agent[web]"
coder web
The chat page is the terminal interface with a window around it, and the settings page writes the model configuration — including the API key — for you. The permissions are there too: the settings page writes the mode that the new sessions get, the chat page switches the mode of the session that is running. The pages, the API and the security model are in The web interface.
The configuration
Four layers, the later ones win:
- the built-in defaults,
.coderagent/config.yamlof the project,~/.coderagent/config.yamlof the user,- the
-c key=valueoverrides of the command line.
A full example:
model:
model_name: deepseek/deepseek-flash
api_key: sk-...
api_base: https://api.deepseek.com
model_kwargs:
temperature: 0.0
litellm_config: ~/.coderagent/litellm_config.yaml
routing:
cheap: deepseek/deepseek-flash
summarize: deepseek/deepseek-flash
agent:
max_turns: 100
cost_limit: 5.0
tools:
enabled: [read, write, edit, glob, grep, ls, bash, todo_write]
disabled: [bash_output]
bash_timeout: 120
permissions:
mode: default
deny_paths: ["*.env", "secrets/**"]
include_dirs: ["../shared-library"]
rules:
- tool: bash
pattern: "git push"
decision: deny
reason: pushing is not my job
context:
context_window: 64000
compact_threshold: 0.8
summarize_model: deepseek/deepseek-flash
memory:
enabled: true
sandbox:
type: local
When a setting is wrong
A setting that means nothing is refused when the configuration is read, not
taken silently: a permission mode that is not default, a tool that does not
exist, a hook event that is not one of the moments of a session, a purpose that
names no job, a section that is written wrong (permissons instead of
permissions), a number that is negative or out of range. The command line
says which setting is wrong and what it should be:
Invalid value: the configuration is not understood: permissions.mode: unknown permission mode 'dffault'. Use one of: default, acceptEdits, plan, bypass, readonly.
The project is treated differently from the user. A repository is code that the agent may be asked to work in, so it may not break the session: what it writes wrong is left out, key by key, and the rest of the file is kept. A project that names a tool that does not exist therefore does not empty the set of tools — the tool is dropped and the others stay.
The layers are the same for the numbers: a project may lower the ceilings of a
session (agent.max_turns and the like), never raise them.
The model
The model can be written down from the terminal, from the terminal interface and
from the browser: coder model, /model --save and the settings page write the
same file, the user level one (~/.coderagent/config.yaml). The project level
file is never written.
The try-out is a step of its own in all three: it says whether the settings work and it writes nothing. A configuration that does not work yet is worth writing down, to be fixed later.
model.model_name is the model of the agent. model.api_key and model.api_base
are the key and the address of the provider; they have a field of their own, so
that a key is not one of the many parameters of the call. model.model_kwargs
goes to the provider as it is — except for model, messages, tools,
stream and stream_options: those belong to the call of the agent, and a
configuration that has one of them is refused at the start instead of breaking
the call at runtime. model.routing maps a purpose to a model:
| Purpose | What it is for |
|---|---|
main |
The agent itself |
cheap |
The small jobs: the sub agents that look around |
summarize |
The summary of a compacted context |
reflect |
What the session writes into the memory |
strong |
A stronger model, when the routing rules ask for it |
review |
The review of the changes (/review) |
model.review_model names the model of the review purpose when the routing
has no review of its own. Without it the review runs on the model of the
session. model.routing wins over model.review_model.
model.routing_rules are conditions on the state of the session:
model:
routing:
strong: anthropic/claude-sonnet-4-5
routing_rules:
- when: "tokens > 50000"
purpose: strong
The rules compare numbers only, they are parsed and not evaluated, so a configuration file cannot run code. The interface says in the event stream when the model changes and why. See Model routing.
model.capabilities says what the models take: the name of a model and the
kinds of content it takes (image, audio, video). The agent asks before
it sends a picture, so a model that cannot see one does not answer about it
with a made-up description.
model:
capabilities:
my/model:
image: true
What the user says wins over litellm, which knows most models but few of the ones a relay station names in its own way. A project may not say this: the models belong to the user.
When nobody says it, the agent finds out: it shows the model a picture of one
color and asks what color it is. The answer is written to the file of the user,
~/.coderagent/config.yaml, and the next time the configuration says it, so
the model is asked only once.
How much the model thinks
model.reasoning_effort says how long the model thinks: minimal, low,
medium or high. Empty is the default of the model, which is what most of
them are good at.
coder -c model.reasoning_effort=high --task "..."
The level is written in the words of the provider: OpenAI and the others want
reasoning_effort, Anthropic wants a number of tokens to think with
(minimal is 1024 tokens, high is 16384). A provider that does not know
the parameter refuses the call, and the refusal is not retried.
A level that does not exist is refused when the configuration is read, not in the middle of a turn.
How much the model says
model.verbosity says how much the model says: low, medium or high.
Empty is the habit of the model, which is what most of them are good at.
coder -c model.verbosity=low --task "..."
reasoning_effort is how long the model thinks, verbosity is how much it
says. The two are independent: a model may think long and answer short.
The level is an instruction, not a parameter of the provider: it goes into the system prompt of the session. Every provider understands it, and none of them is asked for a parameter it may not know.
A level that does not exist is refused when the configuration is read.
Other providers
The model goes through litellm, so every model litellm knows works. The key of the provider comes from the environment:
| Model name | Provider | Environment variable |
|---|---|---|
anthropic/claude-sonnet-4-5 |
Anthropic | ANTHROPIC_API_KEY |
openai/gpt-4o |
OpenAI | OPENAI_API_KEY |
deepseek/deepseek-flash |
DeepSeek | DEEPSEEK_API_KEY |
dashscope/qwen3-coder-plus |
Alibaba (DashScope) | DASHSCOPE_API_KEY |
moonshot/kimi-k2.5 |
Moonshot | MOONSHOT_API_KEY |
minimax/minimax-m2 |
MiniMax | MINIMAX_API_KEY (and MINIMAX_API_BASE) |
openrouter/qwen/qwen3-coder |
OpenRouter | OPENROUTER_API_KEY |
The name of a model
The name of a model may be written in three ways, and they all mean the same model:
coder -m openai/MiniMax-M2.7 --task "..." # the provider in front of the name
coder -m openai:MiniMax-M2.7 --task "..." # the same, with a colon
coder -m MiniMax-M2.7 --task "..." # no provider at all
Who is called is worked out in this order:
- The name carries the provider. It wins:
openai/MiniMax-M2.7andopenai:MiniMax-M2.7are the same model. A colon only counts when what is in front of it is a known provider, soft:gpt-4o:acmestays one name. - The address of the endpoint says the protocol. A base that mentions
anthropicis the Anthropic protocol, any other base is the OpenAI compatible protocol that most providers and relays speak. - The family of the model says the provider.
gpt-,o1,o3ando4are OpenAI,claudeis Anthropic,geminiis Google,deepseekis DeepSeek,grokis xAI,qwenis DashScope,kimiis Moonshot,minimaxis MiniMax,mistralis Mistral,commandis Cohere,sonaris Perplexity. - Nothing is known. The name stays as it is and litellm says what is missing.
The name of the configuration file is never rewritten behind your back: the
file keeps what you wrote, and the resolution happens when the model is called.
The web page shows the provider it worked out, and /model <name> in the
terminal answers with the name the session really calls.
export DASHSCOPE_API_KEY=sk-...
coder -m dashscope/qwen3-coder-plus --task "..."
export MOONSHOT_API_KEY=sk-...
coder -m moonshot/kimi-k2.5 --task "..."
export MINIMAX_API_KEY=...
export MINIMAX_API_BASE=https://api.minimax.io/v1
coder -m minimax/minimax-m2 --task "..."
Three things to know:
qwen/is not a provider. The Alibaba models live underdashscope/(orqwen_ai_platform/, the same thing under its old name).qwen/is the name of a model family, not of a route.- The window comes from the model name. The context window is looked up by
the part after the provider:
qwen32k,deepseek64k,kimi256k,minimax200k,claude200k,gpt-128k,gemini1M. When the model is new or the family is not in the table, set it yourself:context.context_window: 262144. - The model has to call tools. The agent only works with a model that
supports tool calling. The cheap models of a family usually do not, so keep
them for
model.routing.cheaponly if they do.
The routing is what makes a mixed setup work: the main model does the work, the cheap one does the looking around.
model:
model_name: dashscope/qwen3-coder-plus
routing:
cheap: moonshot/kimi-k2.5
summarize: moonshot/kimi-k2.5
The aliases of a litellm config file
An endpoint that is not in the table above can have an alias. model.litellm_config
names a litellm config file, and the model_list of that file names the models:
# ~/.coderagent/litellm_config.yaml
model_list:
- model_name: nengpa/minimax-m2.7
litellm_params:
model: openai/MiniMax-M2.7
api_base: https://api.nengpa.com/v1
api_key: sk-cp-...
# ~/.coderagent/config.yaml
model:
model_name: nengpa/minimax-m2.7
litellm_config: ~/.coderagent/litellm_config.yaml
The alias nengpa/minimax-m2.7 is then a model like any other: coder -m
nengpa/minimax-m2.7 --task "..." works, and so does the routing.
A relative path is looked for in ~/.coderagent/ first and in the working
directory after it: the setting lives in a file that does not move, the working
directory does.
The model of an entry is the model litellm calls, with the provider in front of
it. The other parameters of the entry go to litellm as they are, so the key of a
third party endpoint stays in that one file instead of the configuration of the
agent. The settings of model.model_kwargs win over the ones of the alias, and
model.api_key and model.api_base win over both.
The api_base stops at /v1: litellm appends /chat/completions to it.
An alias only works when the model name is exactly one of the aliases of the file.
A name that is not in the model_list leaves the agent with none of the settings
of that file, and the agent says so instead of going on without them:
The model 'openai/MiniMax-M2.7' is not one of the aliases of ~/.coderagent/litellm_config.yaml (nengpa/minimax-m2.7): the settings of that file are not used.
The tools
| Tool | What it does |
|---|---|
read |
Read a file. offset and limit cut a long file into pieces. |
write |
Write a file from scratch. |
edit |
Replace a piece of text in a file. |
multi_edit |
Several edits in one file, in order. |
apply_patch |
Apply a patch of blocks: change, add and delete files in one call. |
glob |
The files that match a pattern, e.g. **/*.py. |
grep |
Search for a regular expression. glob limits the files. |
ls |
List a directory. depth: -1 lists everything below it. |
bash |
Run a command. run_in_background returns a task id at once. A local environment only. |
bash_output |
The output of a background command. |
bash_kill |
Stop a background command. |
todo_write |
The task list of the agent. Shown at the bottom of the interface. |
task |
Hand a job to a sub agent. |
skill |
Load the instructions of a skill. |
tools.enabled is the list of the tools the model may call, tools.disabled
takes some of them away. The tools of the MCP servers are always there.
Every tool result is cut to the budget of the context before the model sees it: a command that prints a hundred thousand lines does not blow up the window. The full result stays in the log of the session.
The environment of the commands
The commands of the agent do not see everything you see. The key of the provider is in the process of the agent, not in its shell:
echo [$OPENAI_API_KEY] # [] — the agent does not see your key
The environment of the commands is yours by default (shell_environment.inherit:
all), except for the names that look like a secret. *_API_KEY, *_KEY,
*_TOKEN, *_SECRET, *_PASSWORD, *_PASSWD, *_CREDENTIALS and
*_ACCESS_KEY are always left out.
| Option | What it does |
|---|---|
inherit |
all (everything but the secrets), core (only what a command needs), none (nothing) |
exclude |
Names that are left out, * works as a wildcard |
include |
Names that are kept, even when they look like a secret |
set |
Names that are set, no matter what |
shell_environment:
inherit: core
exclude: ["MY_*"]
include: ["MY_TOKEN"]
set:
CI: "1"
core keeps only PATH, HOME, the locale, the shell and the temporary
directories — what a command needs to run at all. include is the way to open
a secret again, one name at a time.
The project may hide more of the environment, never show what you hid: a
project that adds an include is ignored.
The permissions
The mode decides what the agent may do without asking:
| Mode | What it does |
|---|---|
default |
Reading is free, writing and commands are asked for |
acceptEdits |
Writing is free, commands are asked for |
plan |
Nothing is changed. The agent only reads and answers. |
readonly |
Like plan, but the agent is told to describe the change instead of making it |
bypass |
Everything is allowed. For a container or a throwaway checkout. |
The mode can be changed while the session runs, with /mode or /plan.
bypass takes the guards off, so it asks once: /mode bypass says what it
would do and changes nothing, /mode bypass --yes switches it on.
bypass also has no ceiling: the money (agent.cost_limit), the tokens
(agent.token_limit) and the number of the model calls (agent.max_turns) do
not stop the session in this mode — it runs until the work is done and you stop
it. Every other mode keeps them.
The mode of the project may only take tools away: plan and readonly are
used, the other modes are ignored. The same goes for the rest of the
permissions — the project may not open directories outside the working
directory, its rules may only deny, and the tools it names may only remove
from the tools of the user. The permissions are the user's to decide.
The rest of the configuration of a project is bound the same way. It may not
put variables into the environment of the agent: a LD_PRELOAD or a PATH of
its own would run its code on your machine, in every command the agent runs.
It may not claim a context window bigger than the one of the model. And the
ceilings of the session — the turns, the money, the tokens, the timeout of a
command, the size of an output — it may only lower them. A ceiling that you
name yourself is yours: your file, a profile and the command line win over
the project.
plan and readonly make the permission layer deny the writing tools, so the
model is told about it: a <permission_mode mode="..."> block goes into the
conversation, saying what it may do and what it should answer instead. The
block follows the mode, so it changes as soon as the mode changes.
The rules are more precise than a mode. A rule has a tool, a pattern and a decision:
permissions:
rules:
- tool: edit
pattern: "tests/**"
decision: allow
- tool: bash
pattern: "rm -rf"
decision: deny
reason: that command is not allowed
The pattern is a glob for the tools that touch a path (read, write,
edit, multi_edit, glob, grep, ls) and a regular expression for
bash, where it is matched against the beginning of each part of the command.
The decision is allow, ask or deny. Among the rules that match, the
strictest one wins: a deny is never undone by a later allow, and between
allow and ask the last one wins. A command is judged part by part and the
strictest part wins, so an allowed pytest does not carry a rm along with it.
apply_patch has no path of its own — it changes several files at once — so a
rule about it is about the whole call. Every file it touches is checked against
the bounds of the session anyway: a patch that reaches outside the working
directory is refused.
The rules of the project live in .coderagent/rules.yaml, the rules of the
user in ~/.coderagent/rules.yaml. Both are read, in that order, so a rule of
the user beats a rule of the project with the same tool and pattern — except
that a deny is never beaten by anything. The rules of the project may only
deny: a project cannot allow itself something the user has to be asked for.
The rules that live in the configuration file (permissions.rules) are checked
when the configuration is read: a decision that is not allow, ask or deny,
or a key that does not exist, stops the session at the start instead of turning
into a rule that lets a call through. A rule of the project that is written
wrong is a deny: a broken deny must never become an allow.
# .coderagent/rules.yaml
rules:
- tool: bash
pattern: "pytest"
decision: allow
permissions.deny_paths are the paths that are off limits, whatever the mode
says. They are off limits for the shell as well: with *.env denied,
cat .env is refused just like read .env is. permissions.include_dirs are
the directories outside the working directory that the agent may still touch.
Without them the agent stays inside the directory of the session. The paths
that the project denies are added to the ones of the user, not put in their
place.
The shell has its own boundaries: the commands that only look around (ls,
cat, grep, git status) go through without a question, the ones that
destroy something or send it out (rm, curl, git push) ask, and a path
outside the working directory is refused in every mode. The paths of a command
are the ones it names, variables and all, and a substitution runs a command
too: cat $HOME/.ssh/id_rsa is refused, and echo $(rm -rf ~) asks.
The network has a switch of its own: permissions.network is allow by
default, deny closes it.
permissions:
network: deny
When the network is closed, the commands that reach it are refused instead
of asked for: curl, wget, pip install, git push and the like. The
refusal holds in every mode, bypass included, and a rule of the user cannot
open the network again — the same way the boundaries of the disk hold. The
model is told about it: a <permission_network policy="deny"> block goes into
the conversation, next to the one of the mode. The project may close the
network, never open it.
/permissions shows the mode and the rules that are in effect.
Without a terminal nobody can be asked, so a call that needs approval is
refused and the model is told that the user refused it. In a script, use
--permission-mode bypass for the calls that need it.
The context
The context of the model has a window (context.context_window, by default
the window of the model). When the context comes close to the limit, the
older part of it is replaced by a summary. The summary is written by another
model (context.summarize_model), the older messages are not thrown away:
they are in the summary.
| Option | What it does |
|---|---|
context_window |
The size of the window. By default the one of the model. |
compact_threshold |
When to compact, as a share of the window. |
keep_recent_turns |
How many recent turns to keep when the window has room for them. |
keep_recent_token_ratio |
The share of the window to keep when the window has room for it. |
compact_every_turns |
Compact after that many turns, even when the window is free. |
reserved_output |
The room that is kept for the answer of the model. |
auto_compact |
Whether the agent compacts on its own. |
project_doc_max_bytes |
The bytes one instruction file may take. A longer file is cut short. |
/compact compacts now.
The schemas of the tools go with every request, so they count against the window: a session with many tools compacts a little sooner.
/recap summarizes the conversation without changing it: nothing is dropped and
nothing is compressed, the summary does not go into the context of the model. It
is a report for you, not a step of the work.
/side <question> asks a question in a conversation that goes aside: it has its
own session and its own log, and the conversation you are in is not touched. The
question and the answer are recorded in your session, so the agent does not lose
the thread of the work.
/recap
/side what does the retry logic of the client do?
The memory
At the end of a session the agent asks the model what is worth remembering. The facts about the project are written right away, the preferences of the user wait for a confirmation.
/memory # the memory of the project and of the user
/memory confirm # write the pending preferences
/memory forget <text> # remove a fact
The project memory is .coderagent/memory/projects.md, the preferences of the
user are ~/.coderagent/CLAUDE.md. memory.enabled: false turns the whole
thing off, the model is not even asked. See Memory.
The checkpoints
Before a file is written, the agent takes a checkpoint of it. The checkpoints
are kept per session, the last 50 of them (checkpoint.keep). /rewind lists
them, and with an id it puts the files back and rolls the conversation back to
that point:
/rewind # the checkpoints of the session
/rewind 20261106-a1b2c3 # put the files of that checkpoint back
checkpoint.enabled: false turns them off.
The sandbox
The commands of the agent run in a sandbox. By default it is the machine of the user:
sandbox:
type: local
swerex_docker, swerex_modal, bubblewrap and contree are the other
ones. The options of the sandbox go to the environment as they are; the ones
the environment does not know are ignored:
sandbox:
type: swerex_docker
image: python:3.11
cwd: /workspace
The sandbox has no policy of its own: the network policy belongs to the environment, the paths belong to the permission layer.
The local sandbox has three modes. The operating system enforces them — Seatbelt on macOS, bubblewrap on Linux:
sandbox:
type: local
mode: workspace-write
full-access is the default, workspace-write writes only inside the working
directory, read-only writes nothing. The mode and the permission mode are two
axes: the permissions ask the user, the sandbox asks nobody. See
Sandbox.
A project may close the sandbox but never open it, and it may not choose where
the commands run: the type of the sandbox and the options of the environment
are the decision of the user.
What the agent reads
The agent reads the instructions of the project before it starts. The files are
AGENTS.md and CLAUDE.md, in this order:
coder --task "/init" # write an AGENTS.md for this project
/init writes a template with the layout of the directory; the model is not
asked. It does nothing when the file already exists.
The user file ~/.coderagent/CLAUDE.md comes first, then the repository, then
the project. An AGENTS.md in a subdirectory is read when the agent touches
something in it.
The rules of the repository are read even when the agent starts in a subdirectory of it, and they come before the rules of the directory.
One instruction file may take 32768 bytes (context.project_doc_max_bytes).
A longer file is cut short, and the agent is told that it did not see all of
it — a huge AGENTS.md does not eat the whole window. The memory files are
cut the same way.
What the agent can delegate
The sub agents
A sub agent works in its own context and returns a conclusion, so the main
context stays clean. The agent calls the task tool when a job is too big for
the main context: searching the whole code base, changing the same pattern
everywhere, checking a result on its own.
Three of them are always there:
| Name | What it does | Tools |
|---|---|---|
code-explorer |
Find code, follow a call chain | read, grep, glob, ls |
verifier |
Run the tests, reproduce the bug | read, grep, glob, bash |
refactorer |
Change the same pattern everywhere | read, edit, grep, glob |
Your own sub agents are markdown files in .coderagent/agents:
---
name: doc-writer
description: Write the documentation of a module.
tools: [read, grep, glob]
model_purpose: cheap
max_turns: 15
---
You write the documentation of a module. Read the code, then write the docs.
The tools are a white list: the sub agent cannot reach anything else. The
files of the user are in ~/.coderagent/agents. See
Sub agents.
The skills
A skill is a package of instructions, scripts and resources:
.coderagent/skills/pdf-report/
├── SKILL.md
├── scripts/
│ └── make_report.py
└── assets/
└── template.docx
---
name: pdf-report
description: Make a PDF report out of a folder of notes.
---
Run `scripts/make_report.py` to build the report...
The model sees the name and the description of every skill, and loads the
whole one when the description fits the task. The files of the user are in
~/.coderagent/skills. See Skills.
The page /skills of the web interface installs them from the network: a
GitHub repository, a registry or one SKILL.md, looked at before it is
written to the disk. See The web interface.
The plugins
A plugin adds tools, commands or hooks to the agent. It is a directory
with a plugin.py in it, and it runs in the process of the agent, without a
sandbox. A plugin is only loaded when it is trusted:
/plugins # the plugins that were found
/plugins trust hello
See Plugins.
The hooks
A hook is a command of yours that runs at an important moment of the session: before a tool runs, after it ran, when the session starts or ends. A hook can block an action, rewrite its arguments or add something to the context.
hooks:
events:
PreToolUse:
- matcher: "bash"
hooks:
- type: command
command: ./scripts/guard.sh
See Hooks.
The MCP servers
The tools of an MCP server are available
under the name mcp__<server>__<tool>. The MCP SDK is optional:
pip install "coder-agent[mcp]"
mcp:
servers:
- name: filesystem
command: npx -y @modelcontextprotocol/server-filesystem .
See MCP servers.
The code of a project
Some of the configuration of a project runs a program without asking anything: an MCP server, a hook, a verify command. That program was not written by the user, so cloning a repository must not be enough to run it.
The code of the project therefore waits for a decision. The code of the
user — in ~/.coderagent/config.yaml — is the user's own, and is used as
it is:
/trust # the code that waits for a decision
/trust 1 # trust the first one of the list
The decision is remembered in ~/.coderagent/trusted.json, and it belongs to
the command it was made for: a server or a hook whose command changes is a
thing that has to be trusted again. What is left out is left out entirely, so
a project that is not trusted does not take the servers of the user away.
What waits is only the code. The rest of the configuration of the project —
the instructions — is used as it is, because it says what the agent may do, not
what it may run. The permissions are the exception: the project may only take
tools away, never give them. The model is the other exception: where the
conversation goes is the decision of the user, so the whole model section of
a project is dropped. So are the two other places where a model is named:
context.summarize_model of a project, and the model of a command of the
project. The commands of the user, in ~/.coderagent/commands, may name one.
The same holds for the programs a project would run on your machine: the
editor of ui.file_opener, the notifier of ui.notify_command and the
environment of sandbox.type are dropped from the configuration of a project.
A project may close the sandbox, never open it, and it may never say where its
commands run.
The sessions and the money
A session is an append-only log of events, and that log is the source of
truth. The sessions live in ~/.coderagent/sessions: one .jsonl file with the
events of a session and one .meta.json file with its metadata.
coder --list # the sessions of this directory
coder --resume <id> # continue one of them
coder --fork <id> # continue a copy of one of them
Inside the interface, /clear starts a new session, /resume and /fork do
the same as on the command line.
A session has a life of its own:
| Command | What it does |
|---|---|
/rename <name> |
Give the session a name |
/archive [session-id] |
Put a session away, or take it out again |
/delete <session-id> |
Remove a session and everything in it |
A session that is put away is not in the list of /resume, but it is still there
and /resume <id> opens it. The session you are in cannot be deleted: start a
new one (/clear) first. The name of a session is in /status and in the list
of coder --list.
The history of the sessions grows with every session. Two settings say how much of it is kept:
history:
persistence: save-all # or save-none: nothing is written to the disk
max_bytes: 0 # the bytes the history may take, 0 is no limit
With a limit, the oldest sessions are deleted when the history grows over it. The session that is running is never one of them. A project may not touch these settings: the history belongs to you.
A session that was killed in the middle of a tool call can still be continued:
the call whose result never came back is given a result that says so, so the
history the model sees stays whole. The same happens after a /rewind that
drops the result of a call.
/cost shows what the session has cost and where the money went:
model: deepseek/deepseek-flash
calls: 9
tokens in the context: 120433
tokens spent: 45678
cost so far: $0.4200
cost: $0.4200
tokens: 120433 in, 4567 out
model calls: 9
tool calls: 14
duration: 42.1s
by purpose:
main $0.3800
cheap $0.0400
by model:
deepseek/deepseek-flash $0.4200
by tool:
read 8
The bill belongs to the session: a new session starts at zero, whatever the
session before it spent. The same number is in the trace, in /status and in
the session_cost of the command line.
The files
| Path | What it is |
|---|---|
.coderagent/config.yaml |
The configuration of the project |
.coderagent/rules.yaml |
The permission rules of the project |
.coderagent/agents/*.md |
The sub agents of the project |
.coderagent/skills/*/SKILL.md |
The skills of the project |
.coderagent/plugins/*/plugin.py |
The plugins of the project |
.coderagent/commands/*.md |
The commands of the project |
.coderagent/memory/projects.md |
What the agent remembers about the project |
.coderagent/pending-memory.md |
The preferences that wait for a confirmation |
AGENTS.md, CLAUDE.md |
The instructions of the project |
~/.coderagent/config.yaml |
The configuration of the user |
~/.coderagent/litellm_config.yaml |
The aliases of the models |
~/.coderagent/rules.yaml |
The permission rules of the user |
~/.coderagent/CLAUDE.md |
The instructions and the preferences of the user |
~/.coderagent/agents/, ~/.coderagent/skills/, ~/.coderagent/plugins/ |
The extensions of the user |
~/.coderagent/commands/ |
The commands of the user |
~/.coderagent/skills.lock.json |
What was installed from the network, and where it came from |
~/.coderagent/trusted-plugins.json |
The plugins the user trusts |
~/.coderagent/sessions/ |
The event log of the sessions |
~/.coderagent/checkpoints/ |
The checkpoints of the sessions |
MSWEA_CODER_HOME moves the whole user directory somewhere else.