The Coding Agent Loop is a language-agnostic specification for building an autonomous coding agent. Unlike a CLI, it is designed as a programmable library that a host application (like an IDE, Web UI, or CLI) controls.
An agent takes a natural language instruction, plans a solution, and executes it by interleaving LLM calls with tool execution (reading files, editing code, running commands).
Key Architectural Concepts:
- Session: Manages conversation history, a steering queue for mid-task intervention, and event emission.
- Provider Profiles: Ensures the agent uses tools and system prompts optimized for specific model families (e.g., OpenAI/codex, Anthropic/Claude Code, Gemini/gemini-cli).
- Tool Registry: Handles tool dispatch, validation, and context truncation.
- Execution Environment: An abstraction that allows tools to run anywhere (local, Docker, Kubernetes, WASM, or SSH) without changing the tool logic.
- Event-Driven Interface: The loop emits typed events for every action (thinking, tool calls, output), allowing host applications to observe and react in real time.
/* Conceptual Architecture Diagram */
+--------------------------------------------------+
| Host Application (CLI, IDE, Web UI) |
+--------------------------------------------------+
| ^
| submit(input) | events
v |
+--------------------------------------------------+
| Coding Agent Loop |
| +--------------------+ +---------------------+ |
| | Session | | Provider Profiles | |
| | - history | | - OpenAI (codex) | |
| | - steering queue | | - Anthropic (cc) | |
| | - event emitter | | - Gemini (cli) | |
| +--------------------+ +---------------------+ |
| +--------------------+ | Execution Env | |
| | Tool Registry | | - local (default) | |
| | - tool dispatch | | - docker | |
| | - truncation | | - k8s / wasm / ssh | |
| | - validation | +---------------------+ |
| +--------------------+ |
+--------------------------------------------------+
|
v
+--------------------------------------------------+
| Unified LLM SDK (Client.complete / stream) |
+--------------------------------------------------+
|
v
| LLM Provider APIs |
+--------------------------------------------------+