Skip to content

Conversation

@joelhooks
Copy link
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
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
Collaborator

/review

@github-actions
Copy link
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
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 🙏

@rekram1-node rekram1-node merged commit eab177f into sst:dev Dec 23, 2025
2 checks passed
VenTheZone added a commit to VenTheZone/opencode that referenced this pull request Dec 23, 2025
feat(plugin): allow compaction hook to replace prompt entirely (sst#5907)
iljod pushed a commit to iljod/opencode that referenced this pull request Dec 23, 2025
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