Instructions
This page defines the system prompt sent with every model request. Rendering
lives in robi-core::prompt. The sources that fill those blocks live in
crates/robi/src/agent/prompt/. The adapter still injects the finished string, as
providers-streaming.md describes.
What this page does not cover
| Topic | Where it belongs |
|---|---|
| How the request prepends the string | providers-streaming.md |
| Which tools exist | read-tools.md, editing-tools.md |
| Skills | skills.md |
| A trust decision before reading a project file | roadmap M8 |
| Mode prefixes | agent-modes.md |
Problem
The transcript has no system role, so the model only learns what Robi is, which tools this session registered, and which project rules apply if something else says so. That text has several owners: the binary, the user, and the workspace. A later owner is more specific, and a missing file must not block a turn.
Decision
PromptAssembler holds an ordered list of PromptSource values. Each source
returns one block or nothing. render joins the blocks that have text. The
default chain, built by assemble_session when a session actor starts, is:
- Built-in. Identity, rules, an
<access>section, and one line per registered tool (nameanddescription). The access section tells the model how allow and deny rules rank, to callgrantwhen a tool refuses a path, and howshellstays inside the sandbox unless the user approves a wider call. Whendelegateis in the registry, the rules tell the model to usedelegatewith modeexplorefor a search that spans more than a couple of files. Whenrgis on the hostPATH, one rule says to prefer it togrepand to fall back togrepwhen it is missing, which a container image may be. When the mechanism iscontainer, one rule says every command starts in/workspaceand forbids acdthere, and the<cwd>block is dropped because the host path it names is not mounted at that path. An empty registry says that no tools are registered. - User setting. The
system_promptsettings key, when it is non-empty, wrapped in<user_prompt>. ~/.robi/system.md. The same tag, when the file exists.~/.robi/AGENTS.md. Wrapped in<user_agents>.- Project chain. From the git root down to the workspace, root first, in
<project_agents>.AGENTS.override.mdin a directory replacesAGENTS.mdin that directory only.fallback_filesonProjectAgentsadds extra names beside those two. The default chain passes an empty list. - Working directory. The workspace root, in
<cwd>. - Skills. Name and description of each skill the model may load, in
<skills>. The block is omitted when that list is empty. See skills.md. - Mode. The active mode, in
<mode>. See agent-modes.md.
There is no plan-checklist source. Since S9 the plan and its TODO.md are files
in the workspace the shell reads, so nothing is injected from a stored path. See
agent-modes.md.
A source is added with PromptAssembler::source. A new kind of instruction is
another type that implements PromptSource. It does not edit the built-in text.
Each file block is capped at 32 KiB. Over that, the tail is kept and prefixed
with [earlier instructions truncated]. The project chain is one block, so a
short budget drops the root file before the closest one.
SettingsModelSource::model receives the session tool registry, the
workspace root, and the active mode. It assembles this chain and stores it on
ProviderSettings. The provider prepends it as a system message. The transcript
does not store it.
Instruction text cannot add a tool or change a path rule. The built-in rules say so, and the tools do not read the prompt to decide.
Rejected alternatives
- A single string constant. Adding
AGENTS.mdwould mean editing the constant, and the tool list would drift from the registry. - Putting file reads in
robi-core. The core renders blocks. OpeningAGENTS.mdis I/O, so the sources stay incrates/robi. - Replacing the built-in prompt with the user file. The tool list would disappear as soon as someone wrote a preamble.
Failure modes
- A missing file is skipped.
- A file that cannot be read is skipped, and a warning is logged. The turn still starts.
- No workspace root skips the project chain, the working-directory block, and the plan checklist. Tests that build a model without a session take that path.
- A plan file that cannot be read, or whose frontmatter does not parse, skips the checklist. A warning is logged. The turn still starts.
- No home directory skips
~/.robi/system.mdand~/.robi/AGENTS.md.