How WednesdayAI assembles per-turn context: the collect → project → prune → compaction lifecycle, PromptContribution blocks, and how to take over compaction from a plugin.
Context engine
Every agent run assembles a fresh context: the system prompt (built from sections), the session transcript, workspace files, tool schemas, and contributions from plugins. The context engine is the pipeline that collects those pieces, projects them into the message list, prunes under token pressure, and compacts when the window is full. Plugins join it through four lifecycle hooks — context.collect, context.project, context.prune, and compaction.plan — all registered with api.on(...) and imported only from openclaw/plugin-sdk.This page documents the engine contract: the hook order, the typed events, the contribution shape, and the takeover rules for plugins that own compaction.
Pipeline
inbound turn └─ context.collect plugins contribute PromptContribution blocks └─ context.project contributions projected into the outgoing message list └─ (model call) └─ context.prune token-pressure pruning (in-memory, per turn) └─ compaction.plan summarisation planning (persists to the transcript)
Each lifecycle hook runs handlers sequentially in registration order (ties broken by the optional { priority } on api.on).
Context lifecycle handlers are awaited with a 5 000 ms default timeout; a handler that exceeds it is logged and skipped. Return promptly — do background work outside the handler.
context.prune and compaction.plan only run under token pressure; a turn with plenty of window skips both.
The contribution contract
context.collect handlers return a PromptContribution. Merge order and block placement are owned by the engine.
import type { PromptContribution } from "openclaw/plugin-sdk";const contribution: PromptContribution = { // Context blocks, merged by placement field and sorted by priority (desc, stable): prependSystemPrompt: [], // before the built system prompt systemPrompt: undefined, // plain string — last writer wins on merge appendSystemPrompt: [], // after the built system prompt prependContext: [], // before the user turn appendContext: [], // after the user turn prependBeforeMetadata: [], // before the metadata block group injectAfterMetadata: [], // after the metadata block group appendAfterUserMessage: [],// after the clean user message metadata: [], // metadata lane blocks pluginData: {}, // merged into stored entries for later reads};
Each block is a ContextBlock:
type ContextBlock = { id?: string; source: string; // your plugin id — label for /context reporting text: string; priority?: number; // higher sorts earlier within a placement field tokenEstimate?: number; metadata?: Record<string, unknown>;};
When multiple plugins contribute, blocks in the same placement field are sorted by priority descending (registration order breaks ties). pluginData objects merge with last-writer-wins per key.
The lifecycle context
All four hooks receive a ContextLifecycleContext as the handler’s second argument:
turnNumber and sessionCreatedAt are undefined on the default JSONL backend and on
storage lookup failure. Always guard:
if ((ctx.turnNumber ?? 0) < 10) and if (ctx.sessionCreatedAt).
Hook reference
context.collect
Fires while the turn’s prompt envelope is built. Event: { prompt, cleanUserMessage, messages, envelope, storage? }. Return a PromptContribution (or void).
context.project
Fires as contributions are projected into the outgoing message list. Event: { messages, contributions, envelope, storage? }. Return { messages?, projection?, contribution? } — replace the message list, attach a JSON projection (cached and replayable), or amend the contribution.
context.prune
Fires under token pressure, in-memory only (the transcript is not rewritten). Event: { messages, tokenWindow?, usage?, storage? }. Return { messages?, dropped?, contribution?, compactionHandled? }.compactionHandled: true tells the runtime the context is sufficiently pruned and compaction.plan should not fire this turn. It is only effective as a per-turn fallback — the stable way to suppress built-in compaction is declaring ownership (below).
compaction.plan
Fires when compaction is being planned. Event: { messages, tokenWindow?, usage?, storageCursor? }. Return { plan?, messages?, contribution? }.
Observing without mutating
before_compaction / after_compaction (observe) fire around the compaction pass with { messageCount, tokenCount?, sessionFile?, ... }. All pre-compaction messages are already on disk when they fire, so heavy post-processing can read sessionFile asynchronously without blocking the pipeline. storage.afterAppend (observe) fires after each conversation entry is appended, with the stored entry and storage cursor — use turn.turnId plus entry id or rawSha256 to dedupe append fan-out.
Taking over compaction
A plugin that fully owns compaction declares it in its definition:
import type { OpenClawPluginDefinition } from "openclaw/plugin-sdk";export default { name: "my-compactor", ownsCompaction: true, // runtime skips its built-in compaction trigger async register(api) { api.on("context.prune", (event) => { // your pruning policy; returning compactionHandled is redundant here return { messages: event.messages.slice(-20) }; }); api.on("compaction.plan", (event) => { // your summarisation planning }); },} satisfies OpenClawPluginDefinition;
Without ownsCompaction, returning compactionHandled: true from context.prune suppresses compaction.plan for that turn only. Mixing both signals correctly avoids double-compaction races.
What the engine does when plugins don’t
Context windows come from the provider’s model catalog; when multiple providers expose the same model id with different windows, the smaller window wins (fail-safe budgeting). agents.defaults.contextTokens overrides the estimate.
Replay: prior turns replay from storage in "clean" mode by default (channel-framing-free enriched messages); agents.defaults.ctx.replayMode: "framed" restores raw entries.
Compaction (agents.defaults.compaction): summarises older history into a persistent summary entry. Defaults: enabled: true, mode: "safeguard", maxHistoryShare: 0.5, identifierPolicy: "strict" (summaries are instructed to preserve opaque identifiers — UUIDs, hashes, hostnames — verbatim), memoryFlush.enabled: true (a silent pre-compaction turn that encourages durable notes).
Session pruning (agents.defaults.contextPruning, opt-in) trims old tool results in-memory per request; it never rewrites history.
Post-compaction re-anchor: the ## Session Startup and ## Red Lines sections of the workspace AGENTS.md are re-injected after compaction so critical rules survive summarisation. Any workspace file relying on this must keep those headings byte-identical.
Async safety
Hook handlers may be sync or async, but they run sequentially on the turn’s critical path — a slow handler delays the model call, and one exceeding the 5 000 ms context-hook timeout is abandoned. Do not perform blocking I/O; offload heavy work to sessionFile reads after after_compaction, or to your own background queue keyed by turnId.Do not do this:
api.on("context.collect", async (event) => { const big = await fetchExternalGraph(event.prompt); // network call on the critical path return { appendContext: [{ source: "my-plugin", text: big }] };});
Do this instead: cache contributions in register() or a background task, and keep context.collect a cheap lookup.
System prompt — how the built sections are assembled
Sessions — storage backends and transcript persistence
{"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":"control","enabled":true,"payload":{"type":"string","value":"control"},"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/context-engine","slug":"/developers/context-engine","pageMetadata":{"title":"Context engine","description":"How WednesdayAI assembles per-turn context: the collect → project → prune → compaction lifecycle, PromptContribution blocks, and how to take over compaction from a plugin.","audience":"developer","doc-schema-version":1,"href":"/developers/context-engine"},"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: \"How WednesdayAI assembles per-turn context: the collect → project → prune → compaction lifecycle, PromptContribution blocks, and how to take over compaction from a plugin.\"\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`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`1`,id:`context-engine`,children:`Context engine`}),`\n`,_jsxs(_components.p,{children:[`Every agent run assembles a fresh context: the system prompt (built from sections), the session transcript, workspace files, tool schemas, and contributions from plugins. The context engine is the pipeline that collects those pieces, projects them into the message list, prunes under token pressure, and compacts when the window is full. Plugins join it through four lifecycle hooks — `,_jsx(_components.code,{children:`context.collect`}),`, `,_jsx(_components.code,{children:`context.project`}),`, `,_jsx(_components.code,{children:`context.prune`}),`, and `,_jsx(_components.code,{children:`compaction.plan`}),` — all registered with `,_jsx(_components.code,{children:`api.on(...)`}),` and imported only from `,_jsx(_components.code,{children:`openclaw/plugin-sdk`}),`.`]}),`\n`,_jsx(_components.p,{children:`This page documents the engine contract: the hook order, the typed events, the contribution shape, and the takeover rules for plugins that own compaction.`}),`\n`,_jsx(Heading,{level:`2`,id:`pipeline`,children:`Pipeline`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,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:`7`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`inbound turn`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` └─ context.collect plugins contribute PromptContribution blocks`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` └─ context.project contributions projected into the outgoing message list`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` └─ (model call)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` └─ context.prune token-pressure pruning (in-memory, per turn)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` └─ compaction.plan summarisation planning (persists to the transcript)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`Each lifecycle hook runs handlers `,_jsx(_components.strong,{children:`sequentially`}),` in registration order (ties broken by the optional `,_jsx(_components.code,{children:`{ priority }`}),` on `,_jsx(_components.code,{children:`api.on`}),`).`]}),`\n`,_jsxs(_components.li,{children:[`Context lifecycle handlers are awaited with a `,_jsx(_components.strong,{children:`5 000 ms default timeout`}),`; a handler that exceeds it is logged and skipped. Return promptly — do background work outside the handler.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`context.prune`}),` and `,_jsx(_components.code,{children:`compaction.plan`}),` only run under token pressure; a turn with plenty of window skips both.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`the-contribution-contract`,children:`The contribution contract`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`context.collect`}),` handlers return a `,_jsx(_components.code,{children:`PromptContribution`}),`. Merge order and block placement are owned by the engine.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`15`,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:`15`,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:`PromptContribution`}),_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:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:` contribution`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`PromptContribution`}),_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:` // Context blocks, merged by placement field and sorted by priority (desc, stable):`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` prependSystemPrompt:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` [], `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// before the built system prompt`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` systemPrompt:`}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:` undefined`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// plain string — last writer wins on merge`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` appendSystemPrompt:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` [], `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// after the built system prompt`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` prependContext:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` [], `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// before the user turn`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` appendContext:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` [], `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// after the user turn`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` prependBeforeMetadata:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` [], `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// before the metadata block group`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` injectAfterMetadata:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` [], `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// after the metadata block group`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` appendAfterUserMessage:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` [],`}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// after the clean user message`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` metadata:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` [], `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// metadata lane blocks`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` pluginData:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {}, `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// merged into stored entries for later reads`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`};`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Each block is a `,_jsx(_components.code,{children:`ContextBlock`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`8`,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:`8`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`type`}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:` ContextBlock`}),_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:` id`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_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:` source`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// your plugin id — label for /context reporting`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` text`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_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:` priority`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`number`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// higher sorts earlier within a placement field`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` tokenEstimate`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`number`}),_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:` metadata`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`Record`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`unknown`}),_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:[`When multiple plugins contribute, blocks in the same placement field are sorted by `,_jsx(_components.code,{children:`priority`}),` descending (registration order breaks ties). `,_jsx(_components.code,{children:`pluginData`}),` objects merge with last-writer-wins per key.`]}),`\n`,_jsx(Heading,{level:`2`,id:`the-lifecycle-context`,children:`The lifecycle context`}),`\n`,_jsxs(_components.p,{children:[`All four hooks receive a `,_jsx(_components.code,{children:`ContextLifecycleContext`}),` as the handler’s second argument:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`18`,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:`18`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`type`}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:` ContextLifecycleContext`}),_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:` agentId`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_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:` sessionId`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_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:` sessionKey`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_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:` runId`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// stable across retries within the turn`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` workspaceDir`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_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:` trigger`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// \"user\" | \"heartbeat\" | \"cron\" | \"steer\" | \"memory\" | \"internal\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` channelId`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_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:` modelId`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_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:` provider`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_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:` tokenWindow`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: { `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`modelId`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`provider`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`contextWindowTokens`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`number`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`reservedOutputTokens`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`number`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`estimatedInputTokens`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`number`}),_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:` usage`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: { `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`input`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`number`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`output`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`number`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`cacheRead`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`number`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`cacheWrite`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`number`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`total`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`number`}),_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:` storageCursor`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: { `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`backend`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"fs-jsonl\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` | `}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"sqlite\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` | `}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"postgres\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`sessionId`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`seq`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`number`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`entryId`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`string`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`/* ... */`}),_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:` turnNumber`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`number`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// completed user-message turns; DB backends only`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` sessionCreatedAt`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`Date`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`; `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// DB backends only`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` runtimeIdentity`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`PluginRuntimeIdentity`}),_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:` turn`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`?: `}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`PluginTurnIdentity`}),_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`,_jsx(Warning,{children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`turnNumber`}),` and `,_jsx(_components.code,{children:`sessionCreatedAt`}),` are `,_jsx(_components.code,{children:`undefined`}),` on the default JSONL backend and on\nstorage lookup failure. Always guard:\n`,_jsx(_components.code,{children:`if ((ctx.turnNumber ?? 0) \u003c 10)`}),` and `,_jsx(_components.code,{children:`if (ctx.sessionCreatedAt)`}),`.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`hook-reference`,children:`Hook reference`}),`\n`,_jsx(Heading,{level:`3`,id:`context-collect`,children:_jsx(_components.code,{children:`context.collect`})}),`\n`,_jsxs(_components.p,{children:[`Fires while the turn’s prompt envelope is built. Event: `,_jsx(_components.code,{children:`{ prompt, cleanUserMessage, messages, envelope, storage? }`}),`. Return a `,_jsx(_components.code,{children:`PromptContribution`}),` (or void).`]}),`\n`,_jsx(Heading,{level:`3`,id:`context-project`,children:_jsx(_components.code,{children:`context.project`})}),`\n`,_jsxs(_components.p,{children:[`Fires as contributions are projected into the outgoing message list. Event: `,_jsx(_components.code,{children:`{ messages, contributions, envelope, storage? }`}),`. Return `,_jsx(_components.code,{children:`{ messages?, projection?, contribution? }`}),` — replace the message list, attach a JSON projection (cached and replayable), or amend the contribution.`]}),`\n`,_jsx(Heading,{level:`3`,id:`context-prune`,children:_jsx(_components.code,{children:`context.prune`})}),`\n`,_jsxs(_components.p,{children:[`Fires under token pressure, in-memory only (the transcript is not rewritten). Event: `,_jsx(_components.code,{children:`{ messages, tokenWindow?, usage?, storage? }`}),`. Return `,_jsx(_components.code,{children:`{ messages?, dropped?, contribution?, compactionHandled? }`}),`.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`compactionHandled: true`}),` tells the runtime the context is sufficiently pruned and `,_jsx(_components.code,{children:`compaction.plan`}),` should not fire this turn. It is only effective as a per-turn fallback — the stable way to suppress built-in compaction is declaring ownership (below).`]}),`\n`,_jsx(Heading,{level:`3`,id:`compaction-plan`,children:_jsx(_components.code,{children:`compaction.plan`})}),`\n`,_jsxs(_components.p,{children:[`Fires when compaction is being planned. Event: `,_jsx(_components.code,{children:`{ messages, tokenWindow?, usage?, storageCursor? }`}),`. Return `,_jsx(_components.code,{children:`{ plan?, messages?, contribution? }`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`observing-without-mutating`,children:`Observing without mutating`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`before_compaction`}),` / `,_jsx(_components.code,{children:`after_compaction`}),` (observe) fire around the compaction pass with `,_jsx(_components.code,{children:`{ messageCount, tokenCount?, sessionFile?, ... }`}),`. All pre-compaction messages are already on disk when they fire, so heavy post-processing can read `,_jsx(_components.code,{children:`sessionFile`}),` asynchronously without blocking the pipeline. `,_jsx(_components.code,{children:`storage.afterAppend`}),` (observe) fires after each conversation entry is appended, with the stored entry and storage cursor — use `,_jsx(_components.code,{children:`turn.turnId`}),` plus entry id or `,_jsx(_components.code,{children:`rawSha256`}),` to dedupe append fan-out.`]}),`\n`,_jsx(Heading,{level:`2`,id:`taking-over-compaction`,children:`Taking over compaction`}),`\n`,_jsx(_components.p,{children:`A plugin that fully owns compaction declares it in its definition:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`15`,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:`15`,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:`OpenClawPluginDefinition`}),_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:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` name:`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` \"my-compactor\"`}),_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:` ownsCompaction:`}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:` true`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// runtime skips its built-in compaction trigger`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:` async`}),_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:`) {`})]}),`\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:`\"context.prune\"`}),_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:` // your pruning policy; returning compactionHandled is redundant here`})}),`\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:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`slice`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(-`}),_jsx(_components.span,{style:{color:`#B5CEA8`,\"--shiki-dark\":`#B5CEA8`},children:`20`}),_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`,_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:`\"compaction.plan\"`}),_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:` // your summarisation planning`})}),`\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`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`} `}),_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:`satisfies`}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:` OpenClawPluginDefinition`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Without `,_jsx(_components.code,{children:`ownsCompaction`}),`, returning `,_jsx(_components.code,{children:`compactionHandled: true`}),` from `,_jsx(_components.code,{children:`context.prune`}),` suppresses `,_jsx(_components.code,{children:`compaction.plan`}),` for that turn only. Mixing both signals correctly avoids double-compaction races.`]}),`\n`,_jsx(Heading,{level:`2`,id:`what-the-engine-does-when-plugins-don’t`,children:`What the engine does when plugins don’t`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Context windows`}),` come from the provider’s model catalog; when multiple providers expose the same model id with different windows, the `,_jsx(_components.strong,{children:`smaller`}),` window wins (fail-safe budgeting). `,_jsx(_components.code,{children:`agents.defaults.contextTokens`}),` overrides the estimate.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Replay`}),`: prior turns replay from storage in `,_jsx(_components.code,{children:`\"clean\"`}),` mode by default (channel-framing-free enriched messages); `,_jsx(_components.code,{children:`agents.defaults.ctx.replayMode: \"framed\"`}),` restores raw entries.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Compaction`}),` (`,_jsx(_components.code,{children:`agents.defaults.compaction`}),`): summarises older history into a persistent summary entry. Defaults: `,_jsx(_components.code,{children:`enabled: true`}),`, `,_jsx(_components.code,{children:`mode: \"safeguard\"`}),`, `,_jsx(_components.code,{children:`maxHistoryShare: 0.5`}),`, `,_jsx(_components.code,{children:`identifierPolicy: \"strict\"`}),` (summaries are instructed to preserve opaque identifiers — UUIDs, hashes, hostnames — verbatim), `,_jsx(_components.code,{children:`memoryFlush.enabled: true`}),` (a silent pre-compaction turn that encourages durable notes).`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Session pruning`}),` (`,_jsx(_components.code,{children:`agents.defaults.contextPruning`}),`, opt-in) trims old `,_jsx(_components.strong,{children:`tool results`}),` in-memory per request; it never rewrites history.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Post-compaction re-anchor`}),`: the `,_jsx(_components.code,{children:`## Session Startup`}),` and `,_jsx(_components.code,{children:`## Red Lines`}),` sections of the workspace `,_jsx(_components.code,{children:`AGENTS.md`}),` are re-injected after compaction so critical rules survive summarisation. Any workspace file relying on this must keep those headings byte-identical.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`async-safety`,children:`Async safety`}),`\n`,_jsxs(_components.p,{children:[`Hook handlers may be sync or async, but they run `,_jsx(_components.strong,{children:`sequentially on the turn’s critical path`}),` — a slow handler delays the model call, and one exceeding the 5 000 ms context-hook timeout is abandoned. Do not perform blocking I/O; offload heavy work to `,_jsx(_components.code,{children:`sessionFile`}),` reads after `,_jsx(_components.code,{children:`after_compaction`}),`, or to your own background queue keyed by `,_jsx(_components.code,{children:`turnId`}),`.`]}),`\n`,_jsx(_components.p,{children:_jsx(_components.strong,{children:`Do not do this:`})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,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:`4`,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:`\"context.collect\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`async`}),_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`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:` big`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = `}),_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:`await`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:` fetchExternalGraph`}),_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:`prompt`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`); `}),_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:`// network call on the critical path`})]}),`\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:`appendContext:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` [{ `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`source:`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` \"my-plugin\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`text:`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` big`}),_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.strong,{children:`Do this instead:`}),` cache contributions in `,_jsx(_components.code,{children:`register()`}),` or a background task, and keep `,_jsx(_components.code,{children:`context.collect`}),` a cheap lookup.`]}),`\n`,_jsx(Heading,{level:`2`,id:`related`,children:`Related`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/developers/hooks`,children:`Hooks`}),` — the `,_jsx(_components.code,{children:`api.on`}),` guide and full hook catalogue`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/reference/plugin-hooks`,children:`Plugin hooks reference`}),` — exhaustive event/result types`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/admin/gateway/system-prompt`,children:`System prompt`}),` — how the built sections are assembled`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.a,{href:`/admin/session`,children:`Sessions`}),` — storage backends and transcript persistence`]}),`\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":"Context engine","description":"How WednesdayAI assembles per-turn context: the collect → project → prune → compaction lifecycle, PromptContribution blocks, and how to take over compaction from a plugin.","audience":"developer","doc-schema-version":1,"href":"/developers/context-engine"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Context engine","slug":"context-engine","depth":1,"children":[]},{"title":"Pipeline","slug":"pipeline","depth":2,"children":[]},{"title":"The contribution contract","slug":"the-contribution-contract","depth":2,"children":[]},{"title":"The lifecycle context","slug":"the-lifecycle-context","depth":2,"children":[]},{"title":"Hook reference","slug":"hook-reference","depth":2,"children":[{"title":"context.collect","slug":"context-collect","depth":3,"children":[]},{"title":"context.project","slug":"context-project","depth":3,"children":[]},{"title":"context.prune","slug":"context-prune","depth":3,"children":[]},{"title":"compaction.plan","slug":"compaction-plan","depth":3,"children":[]}]},{"title":"Observing without mutating","slug":"observing-without-mutating","depth":2,"children":[]},{"title":"Taking over compaction","slug":"taking-over-compaction","depth":2,"children":[]},{"title":"What the engine does when plugins don’t","slug":"what-the-engine-does-when-plugins-don’t","depth":2,"children":[]},{"title":"Async safety","slug":"async-safety","depth":2,"children":[]},{"title":"Related","slug":"related","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"expansionxpartners","siteName":"WednesdayAI","title":"Context engine - WednesdayAI","navMaps":{"firstHrefInVersion":{"v0.6.1":{"href":"/developers/context-engine","matchLevel":0},"next":{"href":"/next/developers/context-engine","matchLevel":1}},"firstHrefInLanguage":{}},"lastModified":"2026-09-20T21:29:43.839Z","originalFileLocation":"developers/context-engine.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=\"How WednesdayAI assembles per-turn context: the collect → project → prune → compaction lifecycle, PromptContribution blocks, and how to take over compaction from a plugin.\">\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=\"Context engine - WednesdayAI\">\u003cmeta data-mint-head property=\"og:description\" content=\"How WednesdayAI assembles per-turn context: the collect → project → prune → compaction lifecycle, PromptContribution blocks, and how to take over compaction from a plugin.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"WednesdayAI\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.wednesdayai.dev/developers/context-engine\">\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=Context+engine\u0026amp;description=How+WednesdayAI+assembles+per-turn+context%3A+the+collect+%E2%86%92+project+%E2%86%92+prune+%E2%86%92+compaction+lifecycle%2C+PromptContribution+blocks%2C+and+how+to+take+over+compaction+fro\u0026amp;theme=723ad5e52117fba83642fb4a\u0026amp;signature=ad5ff19ba31ada92b953c18b2d978b6ebbb4307031a8af0c09d50a4dda146576\">\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=\"Context engine - WednesdayAI\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"How WednesdayAI assembles per-turn context: the collect → project → prune → compaction lifecycle, PromptContribution blocks, and how to take over compaction from a plugin.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://expansionxpartners.mintlify.site/_mintlify/api/og/v2?division=Extension+points\u0026amp;title=Context+engine\u0026amp;description=How+WednesdayAI+assembles+per-turn+context%3A+the+collect+%E2%86%92+project+%E2%86%92+prune+%E2%86%92+compaction+lifecycle%2C+PromptContribution+blocks%2C+and+how+to+take+over+compaction+fro\u0026amp;theme=723ad5e52117fba83642fb4a\u0026amp;signature=ad5ff19ba31ada92b953c18b2d978b6ebbb4307031a8af0c09d50a4dda146576\">\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/context-engine\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/developers/context-engine.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/context-engine#webpage\",\"url\":\"https://docs.wednesdayai.dev/developers/context-engine\",\"name\":\"Context engine\",\"description\":\"How WednesdayAI assembles per-turn context: the collect → project → prune → compaction lifecycle, PromptContribution blocks, and how to take over compaction from a plugin.\",\"dateModified\":\"2026-09-20T21:29:43.839Z\",\"isPartOf\":{\"@id\":\"https://docs.wednesdayai.dev#website\"},\"breadcrumb\":{\"@id\":\"https://docs.wednesdayai.dev/developers/context-engine#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.wednesdayai.dev/developers/context-engine#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Extension points\",\"item\":\"https://docs.wednesdayai.dev/developers/hooks\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Context engine\",\"item\":\"https://docs.wednesdayai.dev/developers/context-engine\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.wednesdayai.dev/developers/context-engine#article\",\"headline\":\"Context engine\",\"name\":\"Context engine\",\"description\":\"How WednesdayAI assembles per-turn context: the collect → project → prune → compaction lifecycle, PromptContribution blocks, and how to take over compaction from a plugin.\",\"url\":\"https://docs.wednesdayai.dev/developers/context-engine\",\"mainEntityOfPage\":{\"@id\":\"https://docs.wednesdayai.dev/developers/context-engine#webpage\"},\"dateModified\":\"2026-09-20T21:29:43.839Z\",\"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/context-engine.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","href":"/developers/plugins/publishing"}]},{"group":"Extension points","icon":"puzzle","pages":[{"title":"Hooks","href":"/developers/hooks"},{"title":"Task pipeline","sidebarTitle":"Task pipeline","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","description":"How an inbound message becomes outbound replies: dispatch stages, the GetReplyOptions contract, run kinds, typing policy, and bootstrap context modes.","href":"/developers/auto-reply"},{"title":"Context engine","href":"/developers/context-engine"},{"title":"Deep observability runtime metrics","sidebarTitle":"Runtime metrics","description":"The Node.js runtime metric surface exported by the diagnostics-otel extension: event loop, GC, heap, CPU, and process counters.","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/context-engine"}]}]},"basePath":"","title":"Context engine - 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"]}