docs/tools/capability-cookbook.md
Use this when OpenClaw needs a new domain such as image generation, video generation, or some future vendor-backed feature area.
The rule:
That means you should not start by wiring a vendor directly into a channel or a tool. Start by defining the capability.
Create a new capability when all of these are true:
If the work is vendor-only and no shared contract exists yet, stop and define the contract first.
Core:
title / description docs metadata on nested object, wildcard, array-item, and composition nodesVendor plugin:
Feature/channel plugin:
api.runtime.* or the matching plugin-sdk/*-runtime helperUse 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:
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.tsImage generation follows the standard shape:
ImageGenerationProviderregisterImageGenerationProvider(...)runtime.imageGeneration.generate(...)openai, google, fal, and minimax plugins register vendor-backed implementationsThe config key is separate from vision-analysis routing:
agents.defaults.imageModel = analyze imagesagents.defaults.imageGenerationModel = generate imagesKeep those separate so fallback and policy remain explicit.
Before shipping a new capability, verify:
If a PR skips the capability layer and hardcodes vendor behavior into a channel/tool, send it back and define the contract first.