How Agent Preset Modes Work: Declarative Runtime Assembly for Coding Agents
This article explains how preset modes bring structure to coding agents by turning runtime assembly into declarative, versionable configuration. It covers what a mode directory contains, how process-level single mounting and session-scoped state keys work, why a mode locks once a session produces output, and how to choose among the standard, code, minimal, and cordis modes. It also outlines practical guidance and common pitfalls for reproducible agent behavior.
1. Background: Why Agents Need a “Mode” Layer
A recurring tension shows up in real-world coding tools: the stronger the model and the more tools you attach, the longer the prompt grows, and the harder it becomes for the model to make the right decision in a single session. Tool proliferation creates selection ambiguity, layered prompts create conflicting instructions, and always-on capabilities such as context compaction and skill discovery continuously consume context budget. If every session uses the same “full configuration,” generality looks best on paper, but stability on specific tasks is actually at its worst.
The Agent Preset is an engineering response to this tension. Its core idea is to extract the runtime assembly information a session needs out of the code and into declarative, versionable configuration files, divided by task type into several mutually exclusive tiers. Assembly happens once at session startup, and all subsequent behavior is interpreted under that assembly result.
2. Assembly Unit: What Is Inside a Mode Directory
Each mode corresponds to a separate directory. Inside the directory is an assembly file, typically a YAML declaration, that describes four categories of elements for the session:
- Persona: The first line of the system prompt. It defines the model’s identity and default behavioral tendencies, and acts as the “tone baseline” for every prompt section that follows.
- Tool list: Declares the set of tools the model can call. The key point is not “which tools exist” but “what the tool schema looks like from the model’s perspective,” because the schema directly shapes the model’s mental model for calling tools.
- Prompt sections: Rule blocks split by function, such as constraints for plan mode, standards for code modification, and retrieval priority order. They can be freely added or removed per mode.
- Always-on capabilities: Supporting capabilities that are unrelated to a single task but remain in effect continuously, typically context compaction, skill discovery, and memory maintenance.
The value of this declarative assembly is that mode differences are consolidated at the configuration layer instead of scattered across code branches. Adding a new mode essentially means adding a declaration file, not modifying core logic.
# Skeleton of a mode assembly file (fields are generic illustrations)persona: "You are a coding assistant focused on verifiability"tools:- shell_session # persistent command execution- file_edit # precise string-replacement editing- search_index # retrievalprompts:- planning_rules- edit_safety_rulescapabilities:- context_compaction- skill_discovery
3. Key Mechanism 1: Process-Level Single Mount with Session-Scoped State Keys
Mode assembly follows the principle of mounting only once per process. The resident scope is established only once during the process lifecycle, and all sessions that select the same mode share the same mount result. This design addresses two types of cost at once: the assembly overhead itself (parsing, validation, dependency injection) is amortized at the process level; and the reduced memory footprint from sharing makes it possible to run multiple sessions concurrently on the same machine.
Sharing does not mean cross-talk. State keys are split along session and agent dimensions, and each holds its own independent context, variables, and execution state. You can think of it as “one class definition, multiple instances”: the assembly result is a read-only shared asset, while runtime state is mutually isolated private data. One engineering requirement is that the assembly output must be immutable. Any attempt to write to shared structures across sessions breaks isolation.
4. Key Mechanism 2: Output Locks the Mode
The mode determines the tool schema and prompt sections visible to the model. Once a session has produced content, its context is built on top of that schema. Switching modes at that point is equivalent to replacing the interpreter on top of an existing semantic context, and the tools and rules referenced in historical messages lose their corresponding definitions. The system therefore adopts a conservative strategy: once a session produces content, the mode is locked. Switching is only allowed in a blank session, and out-of-bounds requests are rejected directly by the gateway with an error along the lines of “preset is locked.”
This constraint looks limiting, but it is actually a guarantee of reproducibility. It turns a vague “switch gears midway” need into a clear operating rule: choose a mode first, then start a new session; when you need to switch, carry context forward in the new session using a summary or output files.
5. The Four Modes and How to Choose
| Mode | Identifier | Order | Positioning |
|---|---|---|---|
| Standard mode | standard | 1 | Full-featured general coding tier, the default option |
| Code orchestration mode | code | 2 | Adds programmatic orchestration on top of standard capabilities; the model writes a script to complete multiple steps in a single round trip |
| Minimal mode | minimal | 3 | Fixed prompt, two tools (persistent command execution + precise editing), no compaction and no skill discovery |
| Creation mode | cordis | 4 | Opens runtime read/write tools on top of standard capabilities, used to let an agent construct new agents |
The default tier comes from user-side settings. The local configuration file points the default preset to standard mode, so sessions that do not explicitly specify a mode run in standard mode.
Selection guidance is as follows: use standard mode for everyday development and troubleshooting; choose code orchestration mode when you need bulk, deterministic multi-step changes, replacing multiple rounds of tool calls with a script to significantly reduce round-trip overhead; use minimal mode when debugging the prompt itself or doing minimal verification in a constrained environment, since it offers the highest determinism and the fewest variables; use creation mode when you need to generate new agent definitions or adjust runtime assembly.
6. Practical Tips and Common Pitfalls
- A mode is not a capability switch but a contract boundary. When comparing results across modes, you must first align the tool set and prompts; otherwise the conclusions do not transfer.
- Locking is not a defect. If you truly need to switch midway, the correct approach is to persist existing conclusions as artifacts and rebuild context in a new session.
- Shared mounting requires read-only assembly. Any session-level mutable state should live under a private key to avoid polluting other sessions.
- Minimal mode is good for a baseline. When investigating “abnormal model behavior,” first use minimal mode to confirm the tool chain works, then add capabilities back layer by layer.
- Configuration should be version-controlled. Mode files are part of the behavior definition and should be treated the same as code, so the team can achieve reproducibility and rollback.
In summary, the value of preset modes is not “a few more options” but turning the capability boundaries of the agent runtime into explicit, versionable, and reproducible configuration assets, using two constraints, single mounting and output locking, in exchange for isolation and determinism.
