Two kinds of hooks in WednesdayAI: in-plugin lifecycle hooks via api.on(), and standalone HOOK.md event hooks.
Hooks
WednesdayAI has two distinct hook systems. They share the word “hook” but are registered, discovered, and fired differently. Pick the one that matches your use case.
Lifecycle hooks
Standalone hooks
Where
Inside a plugin
A HOOK.md + handler directory
Registered via
api.on(name, handler)
Auto-discovery of HOOK.md
Fires on
33 typed runtime events
Coarse gateway/command events
Typical use
Transform LLM input/output, observe model calls, context lifecycle
Run code on /new, /reset, gateway start
Can mutate the run?
Yes (some hooks)
No — side-effect automation
There is no exported HookContext type. Lifecycle hook handlers receive a typed
event and a typed ctx per hook name (see PluginHookHandlerMap). Standalone
HOOK.md handlers receive their own runtime context. Do not import { HookContext }
from the SDK — it does not exist.
Lifecycle hooks (in-plugin, via api.on)
Inside a plugin’s register function, attach a handler to a named lifecycle event:
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";export default function register(api: OpenClawPluginApi): void { api.on("transform_llm_input", (event) => { // event.messages, event.provider, event.model are typed. // Return a modified messages array to mutate the run. return { messages: event.messages }; }); api.on("model_call_ended", (event) => { // Observe-only: read usage, headers, timing. api.logger.info(`model call ${event.outcome} in ${event.durationMs}ms`); });}
api.on(name, handler, opts?) is fully typed: the event and ctx arguments are inferred from the hook name, and the allowed return type is enforced per hook. An optional { priority } controls ordering when multiple plugins hook the same event.
Mutation semantics
Lifecycle hooks fall into three categories:
Mutating — the handler’s return value replaces or amends the run. Examples: transform_llm_input / transform_llm_output (rewrite messages/output), before_tool_call (rewrite params or block), before_message_write (rewrite or block the message), before_prompt_build (append system prompt / context), before_model_resolve (override model/provider), before_context_send (return { messages? } to replace the outgoing message list), message_sending (rewrite or cancel), and the context.* / compaction.plan lifecycle hooks (contribute context, prune, plan compaction).
Observe-only — the return value is ignored. Examples: llm_input, llm_output, model_call_ended (read usage/headers), agent_end, session_start / session_end, gateway_start / gateway_stop.
Short-circuiting — before_tool_call may return { block: true, blockReason } to stop a tool call; before_message_write may return { block: true } to drop a message.
model_call_ended is observe-only for run control but may mutate usage and
proxyMetadata in place — core reads proxyMetadata back afterwards to record the
actual provider/model. It fires once per run attempt (after the full tool-use loop),
not once per individual LLM API call, and runs serially because of these in-place
mutation semantics.
Lifecycle hook catalogue
These are the PluginHookName values accepted by api.on(...). Fire timing and whether the return value is honoured are noted.
Hook
Fires
Return honoured
before_model_resolve
Before the model/provider is chosen for a run
Yes — override modelOverride / providerOverride
before_prompt_build
Before the system prompt and context are assembled
Yes — systemPrompt (appended after built sections), prependContext (inserted before the user turn)
before_context_send
Just before messages are sent to the model
Yes — replace messages
before_agent_start
Legacy combined pre-run hook
Yes — combines prompt-build and model-resolve results
llm_input
After input is prepared for the model
No (observe)
llm_output
After the model returns
No (observe)
model_call_ended
Once per run attempt, after the tool-use loop
Observe; may mutate usage / proxyMetadata in place (serial)
agent_end
When an agent run finishes
No (observe)
before_compaction
Before context compaction runs
No (observe)
after_compaction
After compaction completes
No (observe)
before_reset
On /new or /reset, before the session clears
No (observe)
message_received
An inbound message is received
No (observe)
message_sending
Before an outbound message is sent
Yes — rewrite content or cancel
message_sent
After an outbound message is sent
No (observe)
before_tool_call
Before a tool executes
Yes — rewrite params, or block with blockReason
after_tool_call
After a tool executes
No (observe)
tool_result_persist
Before a tool result is written to the transcript
Yes — replace the message
before_message_write
Before any message is written to the JSONL transcript
Yes — block or replace the message
session_start
A session starts
No (observe)
session_end
A session ends
No (observe)
subagent_spawning
A subagent is about to spawn
Yes — { status: "ok"; threadBindingReady?: boolean } to allow, or { status: "error"; error: string } to block
The core idle monitor crosses an idle threshold or a schedule window opens
No (observe)
task_outcome
A task or subagent run completes with an outcome
No (observe)
before_prompt_build example
api.on("before_prompt_build", (event, ctx) => { // event.systemPrompt — the assembled system prompt (read-only; do not mutate) // event.messages — session messages prepared for this run return { // Appended after the built system prompt sections: systemPrompt: "Always respond in the user's language.", // Inserted before the user turn in the message list: prependContext: `Current user timezone: ${getUserTimezone(ctx.sessionKey)}`, };});
Both systemPrompt and prependContext are optional — return either, both, or neither. systemPrompt is appended once per run after the full section build; prependContext is a plaintext string inserted into the context immediately before the user’s message.
The context.* and compaction.plan hooks are the context-engine surface. A plugin that
fully owns compaction can set ownsCompaction: true in its plugin definition (or return
compactionHandled: true from context.prune) so the runtime skips its built-in compaction
trigger and avoids double-compaction races.
Runtime and turn identity context
Agent, message (message_*), tool, and before_message_write hook contexts carry two optional identity objects alongside their per-hook fields:
ctx.runtimeIdentity?: PluginRuntimeIdentity — who and where: agentId, sessionKey, channel ids, sender fields (senderId, senderName, senderE164, canonicalIdentity), and the privacy-safe digests providerConversationId / hashedUserId (truncated SHA-256, never raw provider ids). identitySource ("sender" | "parent-session" | "job-config") is the provenance of canonicalIdentity and is never defaulted — absent provenance means the emitting seam did not know it.
ctx.turn?: PluginTurnIdentity — correlation for the current turn: turnId (falls back to the run id), runId, sessionId, turnNumber, inboundMessageId, userEntryId / assistantEntryId, and per-session plus global sequence numbers.
Treat every field as optional: hooks fired outside a channel run (gateway start, cron) may carry neither object. See the plugin hooks reference for the full typed contract.
Inbound channel replies
message_sending and message_sent fire not only on adapter-initiated outbound sends but also on replies to inbound channel messages — every built-in channel (Telegram, Discord, Slack, Signal, iMessage, WhatsApp web, Matrix, MS Teams) routes inbound reply delivery through the same shared helpers (applyMessageSendingHook / createMessageSentEmitter, re-exported from openclaw/plugin-sdk).
Hook
Event
Result
message_sending
{ to, content, metadata? } before each payload chunk is sent
{ content?, cancel? } — rewrite the text or cancel the send
message_sent
{ to, content, success, error? } after the actual send attempt
void (observe)
message_sending rewrites payload text only — media is never rewritten. A throwing handler is logged and the original payload still sends. message_sent fires only after a real send attempt, including after partial sends of chunked replies.
Standalone hooks (HOOK.md)
Standalone hooks are directories auto-discovered by the gateway. They run side-effect automation on coarse events and do not modify the run.
HOOK.md frontmatter declares the events the hook handles:
---name: my-hookdescription: "Saves a marker when the session resets"metadata: { "openclaw": { "emoji": "💾", "events": ["command:new", "command:reset"] } }---
Common standalone events include command:new, command:reset, command:stop, agent:bootstrap, gateway:startup, message:received, message:transcribed, message:preprocessed, and message:sent. The handler exports a function (default export, or the name given by metadata.openclaw.export) that runs when a declared event fires.message:transcribed fires when an inbound audio message has been transcribed. message:preprocessed fires after the message has been enriched with links, images, and transcripts — immediately before routing. Both are useful for logging pipelines and external integrations that need the enriched message body without modifying the run.
Bundled standalone hooks
WednesdayAI ships several bundled hooks, disabled by default. Enable them with the CLI:
openclaw hooks list # see all discovered hooks + statusopenclaw hooks enable session-memoryopenclaw hooks info session-memoryopenclaw hooks check
session-memory and session-journal are both session-reset hooks — session-memory writes a structured summary of the conversation, while session-journal makes an LLM call to produce a reflective journal entry. session-journal is enabled per-agent via sessionJournal.enabled: true in the agent config rather than via hooks.internal.entries. See the Hooks catalogue for the full list and configuration details.
Discovery and precedence
Standalone hooks are discovered from (highest precedence first):
openclaw hooks install runs npm install --ignore-scripts. Keep dependencies to pure JS/TS with no postinstall build steps.
Which hook should I use?
Need to transform the run (rewrite LLM input/output, gate tool calls, shape context, observe model usage)? Use a lifecycle hook in a plugin via api.on(...).
Need to run a side effect on a coarse event (/new, /reset, gateway start) without modifying the run? Use a standalone HOOK.md hook.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"WednesdayAI","description":"The AI platform that stays yours. Documentation for administrators, users, and developers.","colors":{"primary":"#6366f1","light":"#818cf8","dark":"#4f46e5"},"logo":{"light":"https://mintcdn.com/expansionxpartners/dow-8PUnQ_SAIAho/assets/logo-light.svg?fit=max\u0026auto=format\u0026n=dow-8PUnQ_SAIAho\u0026q=85\u0026s=8b9f28296cca622a181934acf27d274b","dark":"https://mintcdn.com/expansionxpartners/dow-8PUnQ_SAIAho/assets/logo-dark.svg?fit=max\u0026auto=format\u0026n=dow-8PUnQ_SAIAho\u0026q=85\u0026s=635a03b67088a77559481dfab5e1e12f"},"favicon":"https://mintcdn.com/expansionxpartners/dow-8PUnQ_SAIAho/assets/favicon.svg?fit=max\u0026auto=format\u0026n=dow-8PUnQ_SAIAho\u0026q=85\u0026s=88396129c7038fbb5e487a35b26b1ffd","background":{"color":{"dark":"#0f172a"}},"navbar":{"links":[{"icon":"github","href":"https://github.com/ExpansionX/WednesdayAI-core","label":"GitHub"},{"icon":"discord","href":"https://discord.gg/wednesdayai","label":"Discord"}],"primary":{"type":"button","label":"Get started","href":"/admin/getting-started"}},"search":{"prompt":"Search WednesdayAI docs..."},"seo":{"indexing":"navigable"},"fonts":{"heading":{"family":"Space Grotesk"},"body":{"family":"Inter"}},"icons":{"library":"lucide"},"styling":{"codeblocks":"dark","latex":true},"banner":{"content":"Latest release: WednesdayAI v0.6.1 ([release notes](https://github.com/ExpansionX/WednesdayAI-core/releases/tag/v0.6.1)). Use the version menu for unreleased (next) or older docs.","dismissible":true},"navigation":{"global":{"anchors":[{"anchor":"Changelog","icon":"megaphone","href":"/changelog"},{"anchor":"GitHub","icon":"github","href":"https://github.com/ExpansionX/WednesdayAI-core"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"expansionxpartners","hasAudioNarration":false,"actualSubdomain":"expansionxpartners","customDomains":["docs.wednesdayai.dev"],"gitSource":{"type":"github","owner":"expansionx","repo":"wednesdayai-docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6afc0b28959cb52827702c74","clientVersion":"0.0.4227","searchFilterCounts":[{"language":"default","tag":"Administrators","count":366},{"language":"default","tag":"Users","count":298},{"language":"default","tag":"Developers","count":212},{"language":"default","tag":"CLI command reference","count":90},{"language":"default","tag":"AI providers","count":66},{"language":"default","tag":"Gateway (synced pages)","count":62},{"language":"default","tag":"Core concepts (developer)","count":58},{"language":"default","tag":"More agent tools","count":56},{"language":"default","tag":"Extension points","count":50},{"language":"default","tag":"Channels (synced pages)","count":40}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":true},"customCss":[{"filePath":"style.css","content":":root{--wai-indigo: #6366f1;--wai-indigo-400: #818cf8;--wai-indigo-600: #5457e5;--wai-violet: #8b5cf6;--wai-pink: #f472b6;--wai-slate-950: #0f172a;--wai-radius: 12px;--wai-ease: cubic-bezier(0.16, 1, 0.3, 1)}h1,h2,h3,.prose h1,.prose h2,.prose h3{letter-spacing:-0.025em}h1,.prose h1{letter-spacing:-0.035em}.eyebrow,[data-eyebrow]{text-transform:uppercase;letter-spacing:0.08em;font-weight:600}a[class*=\"card\"],div[class*=\"card\"],.card{border-radius:var(--wai-radius);transition:border-color 200ms var(--wai-ease),\n transform 120ms var(--wai-ease),\n box-shadow 200ms var(--wai-ease)}@media (prefers-reduced-motion: no-preference){a[class*=\"card\"]:hover,div[class*=\"card\"]:hover,.card:hover{transform:translateY(-1px);border-color:var(--wai-indigo-400);box-shadow:0 4px 12px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(99, 102, 241, 0.25)}}a:hover{text-decoration-color:var(--wai-indigo)}a:focus-visible,button:focus-visible,[tabindex]:focus-visible{outline:none;box-shadow:0 0 0 2px var(--wai-slate-950), 0 0 0 4px var(--wai-indigo);border-radius:6px}:root[class~=\"light\"] a:focus-visible,:root[class~=\"light\"] button:focus-visible{box-shadow:0 0 0 2px #ffffff, 0 0 0 4px var(--wai-indigo)}@media (prefers-reduced-motion: no-preference){a[class*=\"primary\"]:hover,button[class*=\"primary\"]:hover{box-shadow:0 8px 24px rgba(99, 102, 241, 0.4);transform:translateY(-1px)}}pre ::selection,code ::selection{background:rgba(99, 102, 241, 0.28)}[aria-current=\"page\"]{--tw-text-opacity: 1}header,nav[class*=\"navbar\"]{background-image:radial-gradient(60% 120% at 12% 0%, rgba(99, 102, 241, 0.10), transparent 60%)}.brand-accent,.nav__title b{color:var(--wai-pink)}"}]}
{"page":{"pagePath":"developers/hooks","slug":"/developers/hooks","pageMetadata":{"title":"Hooks","description":"Two kinds of hooks in WednesdayAI: in-plugin lifecycle hooks via api.on(), and standalone HOOK.md event hooks.","audience":"developer","href":"/developers/hooks"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Two kinds of hooks in WednesdayAI: in-plugin lifecycle hooks via api.on(), and standalone HOOK.md event hooks.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Note,Table,Tip,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Tip)_missingMdxReference(`Tip`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`1`,id:`hooks`,children:`Hooks`}),`\n`,_jsxs(_components.p,{children:[`WednesdayAI has `,_jsx(_components.strong,{children:`two distinct hook systems`}),`. They share the word “hook” but are registered, discovered, and fired differently. Pick the one that matches your use case.`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{}),_jsx(_components.th,{children:`Lifecycle hooks`}),_jsx(_components.th,{children:`Standalone hooks`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Where`}),_jsx(_components.td,{children:`Inside a plugin`}),_jsxs(_components.td,{children:[`A `,_jsx(_components.code,{children:`HOOK.md`}),` + handler directory`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Registered via`}),_jsx(_components.td,{children:_jsx(_components.code,{children:`api.on(name, handler)`})}),_jsxs(_components.td,{children:[`Auto-discovery of `,_jsx(_components.code,{children:`HOOK.md`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Fires on`}),_jsx(_components.td,{children:`33 typed runtime events`}),_jsx(_components.td,{children:`Coarse gateway/command events`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Typical use`}),_jsx(_components.td,{children:`Transform LLM input/output, observe model calls, context lifecycle`}),_jsxs(_components.td,{children:[`Run code on `,_jsx(_components.code,{children:`/new`}),`, `,_jsx(_components.code,{children:`/reset`}),`, gateway start`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Can mutate the run?`}),_jsx(_components.td,{children:`Yes (some hooks)`}),_jsx(_components.td,{children:`No — side-effect automation`})]})]})]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`There is no exported `,_jsx(_components.code,{children:`HookContext`}),` type. Lifecycle hook handlers receive a typed\n`,_jsx(_components.code,{children:`event`}),` and a typed `,_jsx(_components.code,{children:`ctx`}),` per hook name (see `,_jsx(_components.code,{children:`PluginHookHandlerMap`}),`). Standalone\n`,_jsx(_components.code,{children:`HOOK.md`}),` handlers receive their own runtime context. Do not `,_jsx(_components.code,{children:`import { HookContext }`}),`\nfrom the SDK — it does not exist.`]})}),`\n`,_jsxs(Heading,{level:`2`,id:`lifecycle-hooks-in-plugin-via-api-on`,children:[`Lifecycle hooks (in-plugin, via `,_jsx(_components.code,{children:`api.on`}),`)`]}),`\n`,_jsxs(_components.p,{children:[`Inside a plugin’s `,_jsx(_components.code,{children:`register`}),` function, attach a handler to a named lifecycle event:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`14`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`14`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:` type`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`OpenClawPluginApi`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` \"openclaw/plugin-sdk\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:` default`}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:` function`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:` register`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`api`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`OpenClawPluginApi`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`): `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`void`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` api`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`on`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"transform_llm_input\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, (`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`event`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:` // event.messages, event.provider, event.model are typed.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:` // Return a modified messages array to mutate the run.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`messages:`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` event`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`messages`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` };`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` });`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` api`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`on`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"model_call_ended\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, (`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`event`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:` // Observe-only: read usage, headers, timing.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` api`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`logger`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`info`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:\"`model call \"}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`event`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`outcome`}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` in `}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`event`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`durationMs`}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:\"ms`\"}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` });`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`api.on(name, handler, opts?)`}),` is fully typed: the `,_jsx(_components.code,{children:`event`}),` and `,_jsx(_components.code,{children:`ctx`}),` arguments are inferred from the hook name, and the allowed return type is enforced per hook. An optional `,_jsx(_components.code,{children:`{ priority }`}),` controls ordering when multiple plugins hook the same event.`]}),`\n`,_jsx(Heading,{level:`3`,id:`mutation-semantics`,children:`Mutation semantics`}),`\n`,_jsx(_components.p,{children:`Lifecycle hooks fall into three categories:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Mutating`}),` — the handler’s return value replaces or amends the run. Examples: `,_jsx(_components.code,{children:`transform_llm_input`}),` / `,_jsx(_components.code,{children:`transform_llm_output`}),` (rewrite messages/output), `,_jsx(_components.code,{children:`before_tool_call`}),` (rewrite params or `,_jsx(_components.code,{children:`block`}),`), `,_jsx(_components.code,{children:`before_message_write`}),` (rewrite or `,_jsx(_components.code,{children:`block`}),` the message), `,_jsx(_components.code,{children:`before_prompt_build`}),` (append system prompt / context), `,_jsx(_components.code,{children:`before_model_resolve`}),` (override model/provider), `,_jsx(_components.code,{children:`before_context_send`}),` (return `,_jsx(_components.code,{children:`{ messages? }`}),` to replace the outgoing message list), `,_jsx(_components.code,{children:`message_sending`}),` (rewrite or `,_jsx(_components.code,{children:`cancel`}),`), and the `,_jsx(_components.code,{children:`context.*`}),` / `,_jsx(_components.code,{children:`compaction.plan`}),` lifecycle hooks (contribute context, prune, plan compaction).`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Observe-only`}),` — the return value is ignored. Examples: `,_jsx(_components.code,{children:`llm_input`}),`, `,_jsx(_components.code,{children:`llm_output`}),`, `,_jsx(_components.code,{children:`model_call_ended`}),` (read usage/headers), `,_jsx(_components.code,{children:`agent_end`}),`, `,_jsx(_components.code,{children:`session_start`}),` / `,_jsx(_components.code,{children:`session_end`}),`, `,_jsx(_components.code,{children:`gateway_start`}),` / `,_jsx(_components.code,{children:`gateway_stop`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Short-circuiting`}),` — `,_jsx(_components.code,{children:`before_tool_call`}),` may return `,_jsx(_components.code,{children:`{ block: true, blockReason }`}),` to stop a tool call; `,_jsx(_components.code,{children:`before_message_write`}),` may return `,_jsx(_components.code,{children:`{ block: true }`}),` to drop a message.`]}),`\n`]}),`\n`,_jsx(Note,{children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`model_call_ended`}),` is observe-only for run control but `,_jsx(_components.strong,{children:`may`}),` mutate `,_jsx(_components.code,{children:`usage`}),` and\n`,_jsx(_components.code,{children:`proxyMetadata`}),` in place — core reads `,_jsx(_components.code,{children:`proxyMetadata`}),` back afterwards to record the\nactual provider/model. It fires once per run attempt (after the full tool-use loop),\nnot once per individual LLM API call, and runs serially because of these in-place\nmutation semantics.`]})}),`\n`,_jsx(Heading,{level:`3`,id:`lifecycle-hook-catalogue`,children:`Lifecycle hook catalogue`}),`\n`,_jsxs(_components.p,{children:[`These are the `,_jsx(_components.code,{children:`PluginHookName`}),` values accepted by `,_jsx(_components.code,{children:`api.on(...)`}),`. Fire timing and whether the return value is honoured are noted.`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Hook`}),_jsx(_components.th,{children:`Fires`}),_jsx(_components.th,{children:`Return honoured`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`before_model_resolve`})}),_jsx(_components.td,{children:`Before the model/provider is chosen for a run`}),_jsxs(_components.td,{children:[`Yes — override `,_jsx(_components.code,{children:`modelOverride`}),` / `,_jsx(_components.code,{children:`providerOverride`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`before_prompt_build`})}),_jsx(_components.td,{children:`Before the system prompt and context are assembled`}),_jsxs(_components.td,{children:[`Yes — `,_jsx(_components.code,{children:`systemPrompt`}),` (appended after built sections), `,_jsx(_components.code,{children:`prependContext`}),` (inserted before the user turn)`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`before_context_send`})}),_jsx(_components.td,{children:`Just before messages are sent to the model`}),_jsxs(_components.td,{children:[`Yes — replace `,_jsx(_components.code,{children:`messages`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`before_agent_start`})}),_jsx(_components.td,{children:`Legacy combined pre-run hook`}),_jsx(_components.td,{children:`Yes — combines prompt-build and model-resolve results`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`llm_input`})}),_jsx(_components.td,{children:`After input is prepared for the model`}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`llm_output`})}),_jsx(_components.td,{children:`After the model returns`}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`model_call_ended`})}),_jsx(_components.td,{children:`Once per run attempt, after the tool-use loop`}),_jsxs(_components.td,{children:[`Observe; may mutate `,_jsx(_components.code,{children:`usage`}),` / `,_jsx(_components.code,{children:`proxyMetadata`}),` in place (serial)`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`agent_end`})}),_jsx(_components.td,{children:`When an agent run finishes`}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`before_compaction`})}),_jsx(_components.td,{children:`Before context compaction runs`}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`after_compaction`})}),_jsx(_components.td,{children:`After compaction completes`}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`before_reset`})}),_jsxs(_components.td,{children:[`On `,_jsx(_components.code,{children:`/new`}),` or `,_jsx(_components.code,{children:`/reset`}),`, before the session clears`]}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`message_received`})}),_jsx(_components.td,{children:`An inbound message is received`}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`message_sending`})}),_jsx(_components.td,{children:`Before an outbound message is sent`}),_jsxs(_components.td,{children:[`Yes — rewrite `,_jsx(_components.code,{children:`content`}),` or `,_jsx(_components.code,{children:`cancel`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`message_sent`})}),_jsx(_components.td,{children:`After an outbound message is sent`}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`before_tool_call`})}),_jsx(_components.td,{children:`Before a tool executes`}),_jsxs(_components.td,{children:[`Yes — rewrite `,_jsx(_components.code,{children:`params`}),`, or `,_jsx(_components.code,{children:`block`}),` with `,_jsx(_components.code,{children:`blockReason`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`after_tool_call`})}),_jsx(_components.td,{children:`After a tool executes`}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`tool_result_persist`})}),_jsx(_components.td,{children:`Before a tool result is written to the transcript`}),_jsxs(_components.td,{children:[`Yes — replace the `,_jsx(_components.code,{children:`message`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`before_message_write`})}),_jsx(_components.td,{children:`Before any message is written to the JSONL transcript`}),_jsxs(_components.td,{children:[`Yes — `,_jsx(_components.code,{children:`block`}),` or replace the `,_jsx(_components.code,{children:`message`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`session_start`})}),_jsx(_components.td,{children:`A session starts`}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`session_end`})}),_jsx(_components.td,{children:`A session ends`}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`subagent_spawning`})}),_jsx(_components.td,{children:`A subagent is about to spawn`}),_jsxs(_components.td,{children:[`Yes — `,_jsx(_components.code,{children:`{ status: \"ok\"; threadBindingReady?: boolean }`}),` to allow, or `,_jsx(_components.code,{children:`{ status: \"error\"; error: string }`}),` to block`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`subagent_delivery_target`})}),_jsx(_components.td,{children:`Resolving where a subagent reply is delivered`}),_jsxs(_components.td,{children:[`Yes — override `,_jsx(_components.code,{children:`origin`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`subagent_spawned`})}),_jsx(_components.td,{children:`A subagent has spawned`}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`subagent_ended`})}),_jsx(_components.td,{children:`A subagent ended`}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`gateway_start`})}),_jsx(_components.td,{children:`The gateway process starts`}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`gateway_stop`})}),_jsx(_components.td,{children:`The gateway process stops`}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`transform_llm_input`})}),_jsx(_components.td,{children:`Mutate the message list before the model call`}),_jsxs(_components.td,{children:[`Yes — return `,_jsx(_components.code,{children:`messages`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`transform_llm_output`})}),_jsx(_components.td,{children:`Mutate assistant output after the model call`}),_jsxs(_components.td,{children:[`Yes — return `,_jsx(_components.code,{children:`assistantTexts`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`storage.afterAppend`})}),_jsx(_components.td,{children:`After a conversation entry is appended to storage`}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`context.collect`})}),_jsx(_components.td,{children:`Collecting context for the current turn`}),_jsxs(_components.td,{children:[`Yes — return a `,_jsx(_components.code,{children:`PromptContribution`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`context.project`})}),_jsx(_components.td,{children:`Projecting collected contributions into messages`}),_jsxs(_components.td,{children:[`Yes — `,_jsx(_components.code,{children:`messages`}),`, `,_jsx(_components.code,{children:`projection`}),`, `,_jsx(_components.code,{children:`contribution`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`context.prune`})}),_jsx(_components.td,{children:`Pruning context under token pressure`}),_jsxs(_components.td,{children:[`Yes — `,_jsx(_components.code,{children:`messages`}),`, `,_jsx(_components.code,{children:`dropped`}),`, `,_jsx(_components.code,{children:`compactionHandled`}),`, `,_jsx(_components.code,{children:`contribution?`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`compaction.plan`})}),_jsx(_components.td,{children:`Planning a compaction pass`}),_jsxs(_components.td,{children:[`Yes — `,_jsx(_components.code,{children:`plan`}),`, `,_jsx(_components.code,{children:`messages`}),`, `,_jsx(_components.code,{children:`contribution`})]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`agent_idle`})}),_jsx(_components.td,{children:`The core idle monitor crosses an idle threshold or a schedule window opens`}),_jsx(_components.td,{children:`No (observe)`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`task_outcome`})}),_jsx(_components.td,{children:`A task or subagent run completes with an outcome`}),_jsx(_components.td,{children:`No (observe)`})]})]})]}),`\n`,_jsxs(Heading,{level:`3`,id:`before_prompt_build-example`,children:[_jsx(_components.code,{children:`before_prompt_build`}),` example`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`12`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`12`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`api`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`on`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"before_prompt_build\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, (`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`event`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:` // event.systemPrompt — the assembled system prompt (read-only; do not mutate)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:` // event.messages — session messages prepared for this run`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:` // Appended after the built system prompt sections:`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` systemPrompt:`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` \"Always respond in the user's language.\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:` // Inserted before the user turn in the message list:`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` prependContext:`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:\" `Current user timezone: \"}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`getUserTimezone`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`ctx`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`sessionKey`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`)`}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` };`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Both `,_jsx(_components.code,{children:`systemPrompt`}),` and `,_jsx(_components.code,{children:`prependContext`}),` are optional — return either, both, or neither. `,_jsx(_components.code,{children:`systemPrompt`}),` is appended once per run after the full section build; `,_jsx(_components.code,{children:`prependContext`}),` is a plaintext string inserted into the context immediately before the user’s message.`]}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`context.*`}),` and `,_jsx(_components.code,{children:`compaction.plan`}),` hooks are the context-engine surface. A plugin that\nfully owns compaction can set `,_jsx(_components.code,{children:`ownsCompaction: true`}),` in its plugin definition (or return\n`,_jsx(_components.code,{children:`compactionHandled: true`}),` from `,_jsx(_components.code,{children:`context.prune`}),`) so the runtime skips its built-in compaction\ntrigger and avoids double-compaction races.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`runtime-and-turn-identity-context`,children:`Runtime and turn identity context`}),`\n`,_jsxs(_components.p,{children:[`Agent, message (`,_jsx(_components.code,{children:`message_*`}),`), tool, and `,_jsx(_components.code,{children:`before_message_write`}),` hook contexts carry two optional identity objects alongside their per-hook fields:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:_jsx(_components.code,{children:`ctx.runtimeIdentity?: PluginRuntimeIdentity`})}),` — who and where: `,_jsx(_components.code,{children:`agentId`}),`, `,_jsx(_components.code,{children:`sessionKey`}),`, channel ids, sender fields (`,_jsx(_components.code,{children:`senderId`}),`, `,_jsx(_components.code,{children:`senderName`}),`, `,_jsx(_components.code,{children:`senderE164`}),`, `,_jsx(_components.code,{children:`canonicalIdentity`}),`), and the privacy-safe digests `,_jsx(_components.code,{children:`providerConversationId`}),` / `,_jsx(_components.code,{children:`hashedUserId`}),` (truncated SHA-256, never raw provider ids). `,_jsx(_components.code,{children:`identitySource`}),` (`,_jsx(_components.code,{children:`\"sender\" | \"parent-session\" | \"job-config\"`}),`) is the provenance of `,_jsx(_components.code,{children:`canonicalIdentity`}),` and is never defaulted — absent provenance means the emitting seam did not know it.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:_jsx(_components.code,{children:`ctx.turn?: PluginTurnIdentity`})}),` — correlation for the current turn: `,_jsx(_components.code,{children:`turnId`}),` (falls back to the run id), `,_jsx(_components.code,{children:`runId`}),`, `,_jsx(_components.code,{children:`sessionId`}),`, `,_jsx(_components.code,{children:`turnNumber`}),`, `,_jsx(_components.code,{children:`inboundMessageId`}),`, `,_jsx(_components.code,{children:`userEntryId`}),` / `,_jsx(_components.code,{children:`assistantEntryId`}),`, and per-session plus global sequence numbers.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`Treat every field as optional: hooks fired outside a channel run (gateway start, cron) may carry neither object. See the `,_jsx(_components.a,{href:`/reference/plugin-hooks`,children:`plugin hooks reference`}),` for the full typed contract.`]}),`\n`,_jsx(Heading,{level:`2`,id:`inbound-channel-replies`,children:`Inbound channel replies`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`message_sending`}),` and `,_jsx(_components.code,{children:`message_sent`}),` fire not only on adapter-initiated outbound sends but also on `,_jsx(_components.strong,{children:`replies to inbound channel messages`}),` — every built-in channel (Telegram, Discord, Slack, Signal, iMessage, WhatsApp web, Matrix, MS Teams) routes inbound reply delivery through the same shared helpers (`,_jsx(_components.code,{children:`applyMessageSendingHook`}),` / `,_jsx(_components.code,{children:`createMessageSentEmitter`}),`, re-exported from `,_jsx(_components.code,{children:`openclaw/plugin-sdk`}),`).`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Hook`}),_jsx(_components.th,{children:`Event`}),_jsx(_components.th,{children:`Result`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`message_sending`})}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`{ to, content, metadata? }`}),` before each payload chunk is sent`]}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`{ content?, cancel? }`}),` — rewrite the text or cancel the send`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`message_sent`})}),_jsxs(_components.td,{children:[_jsx(_components.code,{children:`{ to, content, success, error? }`}),` after the actual send attempt`]}),_jsx(_components.td,{children:`void (observe)`})]})]})]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`message_sending`}),` rewrites payload text only — media is never rewritten. A throwing handler is logged and the original payload still sends. `,_jsx(_components.code,{children:`message_sent`}),` fires only after a real send attempt, including after partial sends of chunked replies.`]}),`\n`,_jsx(Heading,{level:`2`,id:`standalone-hooks-hook-md`,children:`Standalone hooks (HOOK.md)`}),`\n`,_jsx(_components.p,{children:`Standalone hooks are directories auto-discovered by the gateway. They run side-effect automation on coarse events and do not modify the run.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`my-hook/`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`├── HOOK.md # metadata + docs (frontmatter drives discovery)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`└── handler.ts # handler module`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`HOOK.md`}),` frontmatter declares the events the hook handles:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`markdown`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`markdown`,children:_jsxs(_components.code,{language:`markdown`,numberOfLines:`5`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`---`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`name`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`my-hook`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`description`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"Saves a marker when the session resets\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`metadata`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`: { `}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"openclaw\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`: { `}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"emoji\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"💾\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"events\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`: [`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"command:new\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"command:reset\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`] } }`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`---`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Common standalone events include `,_jsx(_components.code,{children:`command:new`}),`, `,_jsx(_components.code,{children:`command:reset`}),`, `,_jsx(_components.code,{children:`command:stop`}),`, `,_jsx(_components.code,{children:`agent:bootstrap`}),`, `,_jsx(_components.code,{children:`gateway:startup`}),`, `,_jsx(_components.code,{children:`message:received`}),`, `,_jsx(_components.code,{children:`message:transcribed`}),`, `,_jsx(_components.code,{children:`message:preprocessed`}),`, and `,_jsx(_components.code,{children:`message:sent`}),`. The handler exports a function (default export, or the name given by `,_jsx(_components.code,{children:`metadata.openclaw.export`}),`) that runs when a declared event fires.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`message:transcribed`}),` fires when an inbound audio message has been transcribed. `,_jsx(_components.code,{children:`message:preprocessed`}),` fires after the message has been enriched with links, images, and transcripts — immediately before routing. Both are useful for logging pipelines and external integrations that need the enriched message body without modifying the run.`]}),`\n`,_jsx(Heading,{level:`3`,id:`bundled-standalone-hooks`,children:`Bundled standalone hooks`}),`\n`,_jsx(_components.p,{children:`WednesdayAI ships several bundled hooks, disabled by default. Enable them with the CLI:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`openclaw`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` hooks`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` list`}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:` # see all discovered hooks + status`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`openclaw`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` hooks`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` enable`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` session-memory`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`openclaw`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` hooks`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` info`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` session-memory`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`openclaw`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` hooks`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` check`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`session-memory`}),` and `,_jsx(_components.code,{children:`session-journal`}),` are both session-reset hooks — `,_jsx(_components.code,{children:`session-memory`}),` writes a structured summary of the conversation, while `,_jsx(_components.code,{children:`session-journal`}),` makes an LLM call to produce a reflective journal entry. `,_jsx(_components.code,{children:`session-journal`}),` is enabled `,_jsx(_components.strong,{children:`per-agent`}),` via `,_jsx(_components.code,{children:`sessionJournal.enabled: true`}),` in the agent config rather than via `,_jsx(_components.code,{children:`hooks.internal.entries`}),`. See the `,_jsx(_components.a,{href:`/reference/hooks-catalogue`,children:`Hooks catalogue`}),` for the full list and configuration details.`]}),`\n`,_jsx(Heading,{level:`3`,id:`discovery-and-precedence`,children:`Discovery and precedence`}),`\n`,_jsx(_components.p,{children:`Standalone hooks are discovered from (highest precedence first):`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`\u003cworkspace>/hooks/`}),` — per-agent hooks`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`~/.openclaw/hooks/`}),` — user-installed shared hooks`]}),`\n`,_jsx(_components.li,{children:`bundled hooks shipped with WednesdayAI`}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`installing-hook-packs`,children:`Installing hook packs`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`openclaw`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` hooks`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` @wednesdayai/my-hook-pack`}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:` # npm pack`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`openclaw`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` hooks`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` ./path/to/my-hook`}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:` # local directory`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`openclaw hooks install`}),` runs `,_jsx(_components.code,{children:`npm install --ignore-scripts`}),`. Keep dependencies to pure JS/TS with no postinstall build steps.`]}),`\n`,_jsx(Heading,{level:`2`,id:`which-hook-should-i-use`,children:`Which hook should I use?`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Need to `,_jsx(_components.strong,{children:`transform the run`}),` (rewrite LLM input/output, gate tool calls, shape context, observe model usage)? Use a `,_jsx(_components.strong,{children:`lifecycle hook`}),` in a plugin via `,_jsx(_components.code,{children:`api.on(...)`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Need to `,_jsx(_components.strong,{children:`run a side effect on a coarse event`}),` (`,_jsx(_components.code,{children:`/new`}),`, `,_jsx(_components.code,{children:`/reset`}),`, gateway start) without modifying the run? Use a `,_jsx(_components.strong,{children:`standalone HOOK.md hook`}),`.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`what’s-next`,children:`What’s next`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/developers/plugins/your-first-plugin`,children:`Write your first plugin`}),` — where `,_jsx(_components.code,{children:`api.on(...)`}),` lives`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/developers/agent-tools`,children:`Agent tools`}),` — register tools the AI can call`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/developers/sdk`,children:`Plugin SDK reference`}),` — the full exported surface`]}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":"dark","config":{},"pageMetadata":{"title":"Hooks","description":"Two kinds of hooks in WednesdayAI: in-plugin lifecycle hooks via api.on(), and standalone HOOK.md event hooks.","audience":"developer","href":"/developers/hooks"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Hooks","slug":"hooks","depth":1,"children":[]},{"title":"Lifecycle hooks (in-plugin, via api.on)","slug":"lifecycle-hooks-in-plugin-via-api-on","depth":2,"children":[{"title":"Mutation semantics","slug":"mutation-semantics","depth":3,"children":[]},{"title":"Lifecycle hook catalogue","slug":"lifecycle-hook-catalogue","depth":3,"children":[]},{"title":"before_prompt_build example","slug":"before_prompt_build-example","depth":3,"children":[]}]},{"title":"Runtime and turn identity context","slug":"runtime-and-turn-identity-context","depth":2,"children":[]},{"title":"Inbound channel replies","slug":"inbound-channel-replies","depth":2,"children":[]},{"title":"Standalone hooks (HOOK.md)","slug":"standalone-hooks-hook-md","depth":2,"children":[{"title":"Bundled standalone hooks","slug":"bundled-standalone-hooks","depth":3,"children":[]},{"title":"Discovery and precedence","slug":"discovery-and-precedence","depth":3,"children":[]},{"title":"Installing hook packs","slug":"installing-hook-packs","depth":3,"children":[]}]},{"title":"Which hook should I use?","slug":"which-hook-should-i-use","depth":2,"children":[]},{"title":"What’s next","slug":"what’s-next","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"expansionxpartners","siteName":"WednesdayAI","title":"Hooks - WednesdayAI","navMaps":{"firstHrefInVersion":{"v0.6.1":{"href":"/developers/hooks","matchLevel":0},"next":{"href":"/next/developers/hooks","matchLevel":1}},"firstHrefInLanguage":{}},"lastModified":"2026-11-14T21:17:28.665Z","originalFileLocation":"developers/hooks.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Two kinds of hooks in WednesdayAI: in-plugin lifecycle hooks via api.on(), and standalone HOOK.md event hooks.\">\u003cmeta data-mint-head name=\"application-name\" content=\"WednesdayAI\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/expansionxpartners/ueEk4c188hOwlmD6/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/expansionxpartners/ueEk4c188hOwlmD6/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/expansionxpartners/ueEk4c188hOwlmD6/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/expansionxpartners/ueEk4c188hOwlmD6/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/expansionxpartners/ueEk4c188hOwlmD6/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/expansionxpartners/ueEk4c188hOwlmD6/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/expansionxpartners/ueEk4c188hOwlmD6/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/expansionxpartners/ueEk4c188hOwlmD6/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/expansionxpartners/ueEk4c188hOwlmD6/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Hooks - WednesdayAI\">\u003cmeta data-mint-head property=\"og:description\" content=\"Two kinds of hooks in WednesdayAI: in-plugin lifecycle hooks via api.on(), and standalone HOOK.md event hooks.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"WednesdayAI\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.wednesdayai.dev/developers/hooks\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://expansionxpartners.mintlify.site/_mintlify/api/og/v2?division=Extension+points\u0026amp;title=Hooks\u0026amp;description=Two+kinds+of+hooks+in+WednesdayAI%3A+in-plugin+lifecycle+hooks+via+api.on%28%29%2C+and+standalone+HOOK.md+event+hooks.\u0026amp;theme=723ad5e52117fba83642fb4a\u0026amp;signature=19d1aa15837ae3a7cb4168c1e202da68eeffbe2d897b8baee75d6029d4327100\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Hooks - WednesdayAI\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Two kinds of hooks in WednesdayAI: in-plugin lifecycle hooks via api.on(), and standalone HOOK.md event hooks.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://expansionxpartners.mintlify.site/_mintlify/api/og/v2?division=Extension+points\u0026amp;title=Hooks\u0026amp;description=Two+kinds+of+hooks+in+WednesdayAI%3A+in-plugin+lifecycle+hooks+via+api.on%28%29%2C+and+standalone+HOOK.md+event+hooks.\u0026amp;theme=723ad5e52117fba83642fb4a\u0026amp;signature=19d1aa15837ae3a7cb4168c1e202da68eeffbe2d897b8baee75d6029d4327100\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/expansionxpartners/ueEk4c188hOwlmD6/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"WednesdayAI\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#6366f1\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.wednesdayai.dev/developers/hooks\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/developers/hooks.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.wednesdayai.dev/#organization\",\"name\":\"WednesdayAI\",\"url\":\"https://docs.wednesdayai.dev\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/expansionxpartners/dow-8PUnQ_SAIAho/assets/logo-light.svg?fit=max\u0026auto=format\u0026n=dow-8PUnQ_SAIAho\u0026q=85\u0026s=8b9f28296cca622a181934acf27d274b\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.wednesdayai.dev#website\",\"name\":\"WednesdayAI\",\"url\":\"https://docs.wednesdayai.dev\",\"publisher\":{\"@id\":\"https://docs.wednesdayai.dev/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.wednesdayai.dev/developers/hooks#webpage\",\"url\":\"https://docs.wednesdayai.dev/developers/hooks\",\"name\":\"Hooks\",\"description\":\"Two kinds of hooks in WednesdayAI: in-plugin lifecycle hooks via api.on(), and standalone HOOK.md event hooks.\",\"dateModified\":\"2026-11-14T21:17:28.665Z\",\"isPartOf\":{\"@id\":\"https://docs.wednesdayai.dev#website\"},\"breadcrumb\":{\"@id\":\"https://docs.wednesdayai.dev/developers/hooks#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.wednesdayai.dev/developers/hooks#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"WednesdayAI\",\"item\":\"https://docs.wednesdayai.dev\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hooks\",\"item\":\"https://docs.wednesdayai.dev/developers/hooks\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.wednesdayai.dev/developers/hooks#article\",\"headline\":\"Hooks\",\"name\":\"Hooks\",\"description\":\"Two kinds of hooks in WednesdayAI: in-plugin lifecycle hooks via api.on(), and standalone HOOK.md event hooks.\",\"url\":\"https://docs.wednesdayai.dev/developers/hooks\",\"mainEntityOfPage\":{\"@id\":\"https://docs.wednesdayai.dev/developers/hooks#webpage\"},\"dateModified\":\"2026-11-14T21:17:28.665Z\",\"publisher\":{\"@id\":\"https://docs.wednesdayai.dev/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.wednesdayai.dev#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"WednesdayAI\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"WednesdayAI\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/developers/hooks.md","siteName":"WednesdayAI","nav":{"global":{"anchors":[{"anchor":"Changelog","icon":"megaphone","href":"/changelog"},{"anchor":"GitHub","icon":"github","href":"https://github.com/ExpansionX/WednesdayAI-core"}]},"versions":[{"version":"v0.6.1","default":true,"tag":"Latest","tabs":[{"tab":"Administrators","icon":"server-cog","pages":[{"title":"Administrators","href":"/admin/getting-started"}]},{"tab":"Users","icon":"user-round","pages":[{"title":"Users","href":"/users/what-is-wednesdayai"}]},{"tab":"Developers","icon":"code","groups":[{"group":"Getting started","icon":"rocket","pages":[{"title":"Developer overview","href":"/developers/overview"},{"title":"Write your first plugin","href":"/developers/plugins/your-first-plugin"},{"title":"Plugin Manifest","href":"/developers/plugins/manifest"},{"title":"Versioned Kernel Contracts","href":"/developers/plugins/contracts"},{"title":"Hook parity with upstream openclaw","href":"/developers/plugins/hook-parity"},{"title":null,"href":"/developers/plugins/session-identity-keying"},{"title":"Publishing a plugin","description":"Publish a WednesdayAI plugin to npm and understand the managed install lifecycle: install, enable, update, uninstall.","href":"/developers/plugins/publishing"}]},{"group":"Extension points","icon":"puzzle","pages":[{"title":"Hooks","href":"/developers/hooks"},{"title":"Task pipeline","sidebarTitle":"Task pipeline","description":"The background task pass contract: TaskPass and PassContext types, registration, budgets, preemption, retry, and crash recovery semantics for plugin authors.","href":"/developers/tasks"},{"title":"Channel adapters","href":"/developers/channel-adapters"},{"title":"Agent tools","href":"/developers/agent-tools"},{"title":"Plugin Analysis Runtime","href":"/developers/analysis-runtime"},{"title":"Agent signals","href":"/developers/agent-signals"},{"title":"Session storage","href":"/developers/plugins/session-store"},{"title":"Logging","href":"/developers/plugins/logging"},{"title":"Chat commands","href":"/developers/plugins/register-command"},{"title":"Web search providers","href":"/developers/plugins/web-search-provider"},{"title":"Session analytics","href":"/developers/plugins/session-analytics"},{"title":"Cognitive Substrate Backbone","sidebarTitle":"Backbone message bus","href":"/developers/plugins/backbone"},{"title":"Agent-turn runner","href":"/developers/plugins/agent-turn-runner"},{"title":null,"href":"/developers/plugins/session-consumer-claims"},{"title":"Chunk delivery","href":"/developers/plugins/chunk-delivery"},{"title":"Plugin Media Understanding Providers","href":"/developers/plugins/media-understanding-providers"},{"title":"Auto-reply pipeline","href":"/developers/auto-reply"},{"title":"Context engine","href":"/developers/context-engine"},{"title":"Deep observability runtime metrics","sidebarTitle":"Runtime metrics","href":"/developers/deep-observability"},{"title":"Exec and plugin tools","sidebarTitle":"Exec","href":"/developers/exec"},{"title":"Config writes","sidebarTitle":"Config writes","href":"/developers/config-writes"},{"title":"Redis session cache","href":"/developers/redis-session-cache"},{"title":"Realtime voice API","sidebarTitle":"Realtime voice API","href":"/developers/realtime-voice-api"},{"title":"Learning Core internals","sidebarTitle":"Learning Core","href":"/developers/learning"},{"title":"Product naming","href":"/developers/product-naming"}]},{"group":"Channel references","icon":"messages-square","pages":[{"title":"WhatsApp channel — developer reference","href":"/developers/channels/whatsapp"},{"title":"Telegram channel — developer reference","href":"/developers/channels/telegram"}]},{"group":"SDK reference","icon":"boxes","pages":[{"title":"Plugin SDK","href":"/developers/sdk/index"}]},{"group":"Contributing","icon":"git-pull-request","pages":[{"title":"Contributing","href":"/developers/contributing"},{"title":"Coding style","href":"/developers/contributing/coding-style"},{"title":"Testing policy","href":"/developers/contributing/testing"},{"title":"Secure development","href":"/developers/contributing/secure-development"},{"title":"Measuring performance","href":"/developers/contributing/performance"},{"title":"Documentation","href":"/developers/contributing/documentation"},{"title":"Release Checklist","href":"/developers/contributing/release"}]},{"group":"Core concepts (developer)","pages":[{"title":"Agent Runtime","href":"/developers/concepts/agent"},{"title":"Agent Loop","href":"/developers/concepts/agent-loop"},{"title":"Agent Workspace","href":"/developers/concepts/agent-workspace"},{"title":"Gateway Architecture","href":"/developers/concepts/architecture"},{"title":"Compaction","href":"/developers/concepts/compaction"},{"title":"Context","href":"/developers/concepts/context"},{"title":"Features","href":"/developers/concepts/features"},{"title":"Markdown Formatting","href":"/developers/concepts/markdown-formatting"},{"title":"Memory","href":"/developers/concepts/memory"},{"title":"Messages","href":"/developers/concepts/messages"},{"title":"Model Failover","href":"/developers/concepts/model-failover"},{"title":"Model Providers","href":"/developers/concepts/model-providers"},{"title":"Models CLI","href":"/developers/concepts/models"},{"title":"Multi-Agent Routing","href":"/developers/concepts/multi-agent"},{"title":"OAuth","href":"/developers/concepts/oauth"},{"title":"Command Queue","href":"/developers/concepts/queue"},{"title":"Retry Policy","href":"/developers/concepts/retry"},{"title":"Session Management","href":"/developers/concepts/session"},{"title":"Session Analytics — Economics, Turns, and FTS","href":"/developers/concepts/session-analytics"},{"title":"Session History Hygiene — Clean Replay and Turn Provenance","href":"/developers/concepts/session-history-hygiene"},{"title":"Session Journal","href":"/developers/concepts/session-journal"},{"title":"Session Pruning","href":"/developers/concepts/session-pruning"},{"title":"Session Tools","href":"/developers/concepts/session-tool"},{"title":"Streaming and Chunking","href":"/developers/concepts/streaming"},{"title":"Timezones","href":"/developers/concepts/timezone"},{"title":"TypeBox","href":"/developers/concepts/typebox"},{"title":"Typing Indicators","href":"/developers/concepts/typing-indicators"},{"title":"Usage Tracking","href":"/developers/concepts/usage-tracking"},{"title":"Workspace Lanes","href":"/developers/concepts/workspace-lanes"}]},{"group":"More plugins","pages":[{"title":"Community plugins","href":"/developers/plugins/community"},{"title":"Learning Core","href":"/developers/plugins/learning-core"},{"title":"OpenProse","href":"/developers/plugins/open-prose"},{"title":"Phone Control","href":"/developers/plugins/phone-control"},{"title":"Thread Ownership","href":"/developers/plugins/thread-ownership"},{"title":"Voice Call plugin","href":"/developers/plugins/voice-call"},{"title":"Zalo Personal Plugin","href":"/developers/plugins/zalouser"}]},{"group":"Developer reference","pages":[{"title":"Default AGENTS.md","href":"/developers/reference/AGENTS.default"},{"title":"API Usage and Costs","href":"/developers/reference/api-usage-costs"},{"title":"Device Model Database","href":"/developers/reference/device-models"},{"title":"Prompt Caching","href":"/developers/reference/prompt-caching"},{"title":"RPC Adapters","href":"/developers/reference/rpc"},{"title":"SecretRef Credential Surface","href":"/developers/reference/secretref-credential-surface"},{"title":"Session Management Deep Dive","href":"/developers/reference/session-management-compaction"},{"title":"Tests","href":"/developers/reference/test"},{"title":"Trusted npm publishing for contributors","href":"/developers/reference/trusted-npm-publishing-developer"},{"title":"Token Use and Costs","href":"/developers/reference/token-use"},{"title":"Transcript Hygiene","href":"/developers/reference/transcript-hygiene"},{"title":"Onboarding Wizard Reference","sidebarTitle":"Wizard Reference","href":"/developers/reference/wizard"},{"title":"Brand tokens","href":"/developers/reference/brand-tokens"},{"title":"Web client components","href":"/developers/reference/web-client-components"}]},{"group":"Prompt templates","pages":[{"title":"AGENTS.md Template","href":"/developers/reference/templates/AGENTS"},{"title":null,"href":"/developers/reference/templates/AGENTS.dev"},{"title":"BOOT.md Template","href":"/developers/reference/templates/BOOT"},{"title":"BOOTSTRAP.md Template","href":"/developers/reference/templates/BOOTSTRAP"},{"title":"HEARTBEAT.md Template","href":"/developers/reference/templates/HEARTBEAT"},{"title":null,"href":"/developers/reference/templates/IDENTITY"},{"title":null,"href":"/developers/reference/templates/IDENTITY.dev"},{"title":"SOUL.md Template","href":"/developers/reference/templates/SOUL"},{"title":null,"href":"/developers/reference/templates/SOUL.dev"},{"title":"TOOLS.md Template","href":"/developers/reference/templates/TOOLS"},{"title":null,"href":"/developers/reference/templates/TOOLS.dev"},{"title":null,"href":"/developers/reference/templates/USER"},{"title":null,"href":"/developers/reference/templates/USER.dev"}]},{"group":"Shohin","pages":[{"title":"Shohin developer notes","href":"/developers/shohin"}]}]},{"tab":"Reference","icon":"book-open","pages":[{"title":"Reference","href":"/reference/config"}]}]},{"version":"next","tag":"Unreleased","pages":[{"title":"next","href":"/next/developers/hooks"}]}]},"basePath":"","title":"Hooks - WednesdayAI","deploymentId":"dpl_vSEmv961Ncyvz1psVwgUnTXQMSYk","buildId":"dpl_vSEmv961Ncyvz1psVwgUnTXQMSYk","dynamics":["10e4515597"],"chunks":["BannerMarkdown-DnSAhvaM.js","dist-DIfYWxfm.js","lib-DMeTj1gb.js","lib-B8HbPgcC.js","katex-Dbtb6Wk7.js","html-void-elements-mCSPHezU.js","marked.esm-CZWythHk.js"]}