diff options
| author | Joel Hooks <[email protected]> | 2025-12-22 20:19:14 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-12-22 22:19:14 -0600 |
| commit | eab177f5e7ae91bdd7679867b43f77a479aefb74 (patch) | |
| tree | a793dfd57d07d168b9f434bae1c0fcb2ecb54be5 /packages/web/src/content | |
| parent | 279dc04b3c2faa634352a3782e313321eef5acc9 (diff) | |
| download | opencode-eab177f5e7ae91bdd7679867b43f77a479aefb74.tar.gz opencode-eab177f5e7ae91bdd7679867b43f77a479aefb74.zip | |
feat(plugin): allow compaction hook to replace prompt entirely (#5907)
Diffstat (limited to 'packages/web/src/content')
| -rw-r--r-- | packages/web/src/content/docs/plugins.mdx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/web/src/content/docs/plugins.mdx b/packages/web/src/content/docs/plugins.mdx index 6982b4c93..6be545482 100644 --- a/packages/web/src/content/docs/plugins.mdx +++ b/packages/web/src/content/docs/plugins.mdx @@ -233,3 +233,30 @@ Include any state that should persist across compaction: ``` The `experimental.session.compacting` hook fires before the LLM generates a continuation summary. Use it to inject domain-specific context that the default compaction prompt would miss. + +You can also replace the compaction prompt entirely by setting `output.prompt`: + +```ts title=".opencode/plugin/custom-compaction.ts" +import type { Plugin } from "@opencode-ai/plugin" + +export const CustomCompactionPlugin: Plugin = async (ctx) => { + return { + "experimental.session.compacting": async (input, output) => { + // Replace the entire compaction prompt + output.prompt = ` +You are generating a continuation prompt for a multi-agent swarm session. + +Summarize: +1. The current task and its status +2. Which files are being modified and by whom +3. Any blockers or dependencies between agents +4. The next steps to complete the work + +Format as a structured prompt that a new agent can use to resume work. +` + }, + } +} +``` + +When `output.prompt` is set, it completely replaces the default compaction prompt. The `output.context` array is ignored in this case. |
