Skip to content

Core Runtime

The LightMem2 core runtime is the host-independent execution engine that loads, manages, and runs plugins. It sits between the agent host and the plugins, providing a consistent environment regardless of which host the user is running.

Responsibilities

ResponsibilityDescription
Plugin loadingDiscovers, validates, and loads plugins from configured directories
Lifecycle managementCalls plugin hooks at the right time: install, enable, session start, session end, disable, uninstall
ConfigurationMerges host config, plugin config, and user overrides into a resolved configuration
Event routingDispatches host events (messages, tool calls, session state changes) to plugins
Resource isolationEnsures plugins cannot interfere with each other or the host

How It Fits Together

text
┌──────────────────────────────────────────┐
│              Agent Host                   │
│   (OpenClaw / Codex / Claude Code)        │
└────────────────┬─────────────────────────┘
                 │ Host events & messages
┌────────────────▼─────────────────────────┐
│          Host Adapter                     │
│   Translates host-specific events         │
└────────────────┬─────────────────────────┘
                 │ Standardized events
┌────────────────▼─────────────────────────┐
│          Core Runtime                     │
│   Plugin lifecycle · Config · Routing     │
└────┬──────────────┬──────────────┬───────┘
     │              │              │
┌────▼───┐   ┌──────▼──────┐   ┌──▼────────┐
│Plugin A│   │  Plugin B   │   │ Plugin C   │
└────────┘   └─────────────┘   └───────────┘

The core runtime never talks to the host directly — it always goes through the host adapter. This is what enables a plugin written once to run on any supported host.

Key Design Decisions

  • No network dependency. The runtime runs entirely locally inside the host process or as a sidecar proxy.
  • Plugin isolation. Plugins don't import each other; communication happens through well-defined events.
  • Configuration cascade. Defaults → host config → plugin config → user overrides, with later layers taking precedence.

Current Implementation

The core runtime is implemented across these workspace packages:

PackagePurpose
kernelShared types, interfaces, events, and runtime contracts
runtime-coreHost-agnostic runtime engine and shared execution logic
host-adapterShared host-adapter contracts and path-resolution interfaces
layers/historyCanonical state, raw semantic turns, task registry
layers/decisionPolicy analysis, reduction/eviction decisions, estimator
layers/memory experimentalDistillation and retrieval (in progress)

Next

Released under the MIT License.