Agent runtime architecture
OpenClaw includes a built-in agent runtime that executes AI assistant sessions. The runtime owns the full agent turn cycle: it streams model responses, invokes tools, manages transcript state, applies compaction, selects models, and wires output to sessions and channels.
Runtime responsibilities
The built-in runtime provides:
- The main agent attempt loop that drives sequential turns.
- Provider stream adapters that handle model-specific streaming and fallbacks.
- Compaction logic that summarizes older transcript content while preserving key state.
- Model selection and session integration that respects per-agent configuration.
Sessions handle persistence, load extensions (skills, prompts, themes), discover resources, and render tools for the TUI. A reusable agent core supplies lower-level contracts for messages, compaction helpers, prompt templates, and tool/session interfaces. OpenClaw exposes a facade layer plus local proxy utilities on top of this core.
OpenClaw-owned tools are defined with schemas, policy rules, before/after hook adapters, and host edit support. Built-in runtime hooks enforce compaction safeguards and context pruning. The model and provider layer maintains the registry, transport helpers, and provider-specific stream implementations.
Resource manifests
Resource packages and plugins declare OpenClaw resources in their package metadata. The package manager also discovers conventional directories.
{
"openclaw": {
"extensions": ["extensions/index.ts"],
"skills": ["skills/*.md"],
"prompts": ["prompts/*.md"],
"themes": ["themes/*.json"]
}
}
Runtime selection
The default built-in runtime identifier is openclaw. Plugin harnesses can register additional runtime identifiers. The special value auto selects a supporting plugin harness when one is present and falls back to the built-in OpenClaw runtime otherwise.
Boundaries and plugin usage
Core code calls the built-in runtime through OpenClaw modules and SDK barrels. Plugins must use the documented entrypoints under openclaw/plugin-sdk/* and must not import internal modules.
A third-party TUI library is used as a terminal component toolkit by the local TUI and session renderers.