The agent loop
Messages and events in a session form a tree. Each path from the root to an entry is a branch. The branch ending at the current entry is the active branch and supplies conversation history for the next model request. When you submit a message, Atomic runs a turn loop:1
Record and assemble the request
Atomic appends your message to the active branch, builds the system prompt and model-compatible conversation history, attaches active tool definitions and model settings, and sends the request to the selected provider.
2
Stream the response and execute tools
The provider streams assistant text, optional reasoning blocks, and tool calls. Atomic records the response, runs each tool call in your environment, and records each tool result. That completes one turn.
3
Continue or finish
If tool results or queued messages require another model call, Atomic starts another turn automatically. Otherwise, the run finishes and waits for your next prompt.
Steering, follow-ups, and cancellation
You do not have to wait for a run to finish before guiding it:
See Interactive mode and Keybindings for full queueing and shortcut details.
Two-process interactive architecture
In interactive mode, Atomic runs two cooperating processes:- The terminal UI host owns your screen, input editor, scrolling transcript, overlays, and keyboard shortcuts.
- The background session engine owns model requests, tool execution, extensions, and session storage.
/tasks, queue messages, or cancel a stuck turn even while a model call, tool, or extension is busy. If a cancellation stalls or the background engine exits unexpectedly, the terminal host recovers cleanly and preserves any unsent text in your editor.
Context assembly pipeline
Before every model request, Atomic builds two inputs: the system prompt and the conversation history.System prompt order
Atomic assembles system prompt sections in cache-friendly order so stable instructions stay cached across turns and sessions:- Base prompt, tools, and guidelines: Atomic’s default instructions (or a replacement from
SYSTEM.mdor--system-prompt), summaries of active tools, coding guidelines, and anyAPPEND_SYSTEM.mdor--append-system-promptaddendum. - Built-in documentation pointers: Paths to Atomic’s local guides so the agent can look up Atomic features accurately when asked.
- Project context files: Discovered
AGENTS.override.md,AGENTS.md, orCLAUDE.mdfiles concatenated top-down from global config and ancestor directories to your working directory (see Add project instructions). - Skill catalog: Short descriptions of discovered skills. Full
SKILL.mdinstructions load on demand only when you invoke/skill:<name>or the agent reads the skill. - Dynamic session metadata: The active model and reasoning level, current working directory, session folder, and current date. Placing these last prevents directory or date changes from invalidating earlier prompt-cache prefixes.
Conversation history and input expansion
Atomic reconstructs conversation history from the active branch on each turn:- Input expansion: Prompt templates (
/template) and skill commands (/skill:<name>) expand before reaching the model.@filereferences, pasted images, and!shell command outputs attach directly to the conversation, while!!shell commands run locally without entering model context. - Active branch conversion: Session entries convert into model-compatible user, assistant, and tool-result messages, stopping at the most recent compaction boundary and skipping failed turns that Atomic automatically recovered from (while keeping them in raw history for inspection).
- Extension hooks: Extensions can inspect or transform input and context before a request leaves Atomic.
Sessions, trees, snapshots, and persistence
Because every session is a tree of entries linked to their parents, you can explore alternative approaches without losing earlier work:- Branching in place (
/tree): Jump back to any earlier entry and continue from there to create a new branch inside the same session. - Forking and cloning (
/fork,/clone): Create a new session starting from an earlier user message (/fork) or duplicating your current position (/clone). Forked sessions share their parent’s stored history efficiently. - Subagent sessions: Subagents run in child sessions—either fresh or forked from the parent conversation—persisted in the same store so you can inspect, resume, and export them alongside your main session.
- Storage backends: By default, Atomic saves sessions in a local SQLite database (
~/.atomic/workflows/journal.sqlite) with fast search and session memory recall. You can also choose per-session JSONL files or a shared PostgreSQL database to resume sessions across machines (see Storage). - Worktree snapshots: In Git repositories, Atomic can record repository state alongside session turns so resuming a session—locally or on another machine—can restore matching files and run
.atomic/blueprint.yamlsetup steps (see Worktree snapshots and Resume sessions on any machine).
Context limits and compaction
Every model has a finite context window. When active context nears the limit—or when you run/compact—Atomic writes a compaction boundary without deleting prior messages from session history:
- Memory compaction (default): Clears the active context window with no extra model call and inserts a recovery boundary pointing to session history (
history://). The agent reads or searches exact earlier turns on demand instead of relying on a lossy summary. - Custom compaction models: Sends the active context once to a dedicated remote compactor (such as built-in Morph or your own endpoint) and falls back automatically to memory compaction if that endpoint fails or times out.
- Branch summaries: When
/treeleaves a branch, Atomic can optionally generate a separate summary of the abandoned branch and attach it to your new branch position.
One runtime, five interfaces
Interactive chat, CLI automation, and embedded apps all run on the same agent loop, tool system, extensions, and session storage:
See Non-interactive mode and Programmatic modes to choose an integration path.
Extensions and bundled capabilities
Extensions are TypeScript modules loaded into the session engine. They can register tools, slash commands, keyboard shortcuts, model providers, event handlers, and custom terminal views. Atomic also ships its built-in integrations—subagents, Intercom, MCP servers, web access, andllama.cpp—as lazy bundled extensions. Their tools and slash commands are visible immediately, while their full runtimes load only when first used so startup stays fast.
For lighter customization without writing TypeScript, use skills, prompt templates, themes, and Atomic packages.
Project trust vs. OS permissions
Before loading project-controlled configuration, Atomic resolves a project trust decision for your working directory:- Blocked until trusted: Project
settings.json, extensions, skills, prompt templates, themes, subagents,mcp.json,blueprint.yaml,SYSTEM.md,APPEND_SYSTEM.md, and project and ancestor context files (AGENTS.md/CLAUDE.md). - Always loaded: Your global configuration and global context files in
~/.atomic/agent/. - Not a sandbox: Trust controls which project files Atomic loads automatically—it does not restrict what enabled tools (
bash,read,edit,write) or loaded extensions can access on your machine. Use/trustto update saved decisions,--approve/--no-approvefor one-off CLI overrides, and containers when you need OS-level isolation.
Next steps
Use interactive mode
Learn the editor, queueing, file references, and everyday shortcuts.
Manage sessions
Resume, search, branch with
/tree, fork, and recall past sessions.Context and compaction
See how memory compaction and custom compactors keep long runs fast.
Slash commands
Browse every built-in and bundled extension slash command.