[PR #5907] feat(plugin): allow compaction hook to replace prompt entirely #11636

Closed
opened 2026-02-16 18:16:32 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/5907

State: closed
Merged: Yes


Summary

Extends the experimental.session.compacting hook to support full prompt replacement via output.prompt.

This was explicitly called out by @rekram1-node in #5698:

I imagine there are people who'd wanna override the instructions instead of just append and this hook doesn't support that but we prolly wouldn't want a brand new one

Changes

File Change
packages/plugin/src/index.ts Add optional prompt?: string to hook output type
packages/opencode/src/session/compaction.ts Use output.prompt if set, otherwise default + context
packages/web/src/content/docs/plugins.mdx Document prompt replacement usage

Hook Behavior

  • output.context - appends to default prompt (unchanged)
  • output.prompt - replaces entire prompt (context ignored when set)

Example

"experimental.session.compacting": async (input, output) => {
  output.prompt = `
You are generating a continuation prompt for a multi-agent swarm session.
Summarize the current task, file reservations, and next steps.
`
}
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/5907 **State:** closed **Merged:** Yes --- ## Summary Extends the `experimental.session.compacting` hook to support full prompt replacement via `output.prompt`. This was explicitly called out by @rekram1-node in #5698: > I imagine there are people who'd wanna override the instructions instead of just append and this hook doesn't support that but we prolly wouldn't want a brand new one ## Changes | File | Change | |------|--------| | `packages/plugin/src/index.ts` | Add optional `prompt?: string` to hook output type | | `packages/opencode/src/session/compaction.ts` | Use `output.prompt` if set, otherwise default + context | | `packages/web/src/content/docs/plugins.mdx` | Document prompt replacement usage | ## Hook Behavior - `output.context` - appends to default prompt (unchanged) - `output.prompt` - replaces entire prompt (`context` ignored when set) ## Example ```typescript "experimental.session.compacting": async (input, output) => { output.prompt = ` You are generating a continuation prompt for a multi-agent swarm session. Summarize the current task, file reservations, and next steps. ` } ```
yindo added the pull-request label 2026-02-16 18:16:32 -05:00
yindo closed this issue 2026-02-16 18:16:32 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11636