Skip to content

feat(plugin): allow compaction hook to replace prompt entirely - #5907

Merged
rekram1-node merged 1 commit into
anomalyco:devfrom
joelhooks:feat/compaction-hook-replace
Dec 23, 2025
Merged

rekram1-node merged 1 commit into
anomalyco:devfrom
joelhooks:feat/compaction-hook-replace

Conversation

@joelhooks

Copy link
Copy Markdown
Contributor

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.
`
}

@joelhooks
joelhooks marked this pull request as ready for review December 21, 2025 16:24
@joelhooks

Copy link
Copy Markdown
Contributor Author

@rekram1-node that was a good point about wanting to replace the prompt, I actually do 😅

this makes it a lot more robust.

@rekram1-node

Copy link
Copy Markdown
Member

/review

@github-actions

Copy link
Copy Markdown
Contributor

lgtm

@joelhooks
joelhooks marked this pull request as draft December 21, 2025 19:01
@joelhooks
joelhooks marked this pull request as ready for review December 21, 2025 19:02
@joelhooks

Copy link
Copy Markdown
Contributor Author

@rekram1-node need anything from me here? this one is a huge unlock for me and a better implementation than the first pass 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants