Documentation Index
Fetch the complete documentation index at: https://docs.openclaw.ai/llms.txt
Use this file to discover all available pages before exploring further.
This is a contributor guide for OpenClaw core developers. If you are
building an external plugin, see Building plugins
instead. For the deep architecture reference (capability model, ownership,
load pipeline, runtime helpers), see Plugin internals.
- plugin = ownership boundary
- capability = shared core contract
When to create a capability
Create a new capability when all of these are true:- More than one vendor could plausibly implement it.
- Channels, tools, or feature plugins should consume it without caring about the vendor.
- Core needs to own fallback, policy, config, or delivery behavior.
The standard sequence
- Define the typed core contract.
- Add plugin registration for that contract.
- Add a shared runtime helper.
- Wire one real vendor plugin as proof.
- Move feature/channel consumers onto the runtime helper.
- Add contract tests.
- Document the operator-facing config and ownership model.
What goes where
Core:- Request/response types.
- Provider registry + resolution.
- Fallback behavior.
- Config schema with propagated
title/descriptiondocs metadata on nested object, wildcard, array-item, and composition nodes. - Runtime helper surface.
- Vendor API calls.
- Vendor auth handling.
- Vendor-specific request normalization.
- Registration of the capability implementation.
- Calls
api.runtime.*or the matchingplugin-sdk/*-runtimehelper. - Never calls a vendor implementation directly.
Provider and harness seams
Use provider hooks when the behavior belongs to the model provider contract rather than the generic agent loop. Examples include provider-specific request params after transport selection, auth-profile preference, prompt overlays, and follow-up fallback routing after model/profile failover. Use agent harness hooks when the behavior belongs to the runtime that is executing a turn. Harnesses can classify successful-but-unusable attempt results such as empty, reasoning-only, or planning-only responses so the outer model fallback policy can make the retry decision. Keep both seams narrow:- Core owns the retry/fallback policy.
- Provider plugins own provider-specific request/auth/routing hints.
- Harness plugins own runtime-specific attempt classification.
- Third-party plugins return hints, not direct mutations of core state.
File checklist
For a new capability, expect to touch these areas:src/<capability>/types.tssrc/<capability>/...registry/runtime.tssrc/plugins/types.tssrc/plugins/registry.tssrc/plugins/captured-registration.tssrc/plugins/contracts/registry.tssrc/plugins/runtime/types-core.tssrc/plugins/runtime/index.tssrc/plugin-sdk/<capability>.tssrc/plugin-sdk/<capability>-runtime.ts- One or more bundled plugin packages.
- Config, docs, tests.
Worked example: image generation
Image generation follows the standard shape:- Core defines
ImageGenerationProvider. - Core exposes
registerImageGenerationProvider(...). - Core exposes
runtime.imageGeneration.generate(...). - The
openai,google,fal, andminimaxplugins register vendor-backed implementations. - Future vendors register the same contract without changing channels/tools.
agents.defaults.imageModelanalyzes images.agents.defaults.imageGenerationModelgenerates images.
Review checklist
Before shipping a new capability, verify:- No channel/tool imports vendor code directly.
- The runtime helper is the shared path.
- At least one contract test asserts bundled ownership.
- Config docs name the new model/config key.
- Plugin docs explain the ownership boundary.
Related
- Plugin internals — capability model, ownership, load pipeline, runtime helpers.
- Building plugins — first-plugin tutorial.
- SDK overview — import map and registration API reference.
- Creating skills — companion contributor surface.