Uh oh!
There was an error while loading. Please reload this page.
feat: configurable compaction - #4149
Conversation
55d51e3 to
03211faComparerekram1-node
commented
Nov 11, 2025
@maxeonyx have u seen how we handle /init? I was thinking a cleaner solution here would be to make compact a built in slash command, a user could override the prompt by defining their own compact and it wouldn't require additional config fields The main change this would require is allowing slash commands to register functions to execute, which ofc couldn't be done in json but perhaps for now that functionality would remain internal |
maxeonyx
commented
Nov 11, 2025
I haven't seen that, no, but I assumed compact has special handling due to the fact that it replaces the full context window. I am very open to doing this a different way. |
maxeonyx
commented
Nov 11, 2025
@rekram1-node in your suggestion, then, I would define my own |
03211fa to
10a1998Comparef1dc981 to
3e15a39Comparef8ee907 to
6a9856dCompare
I agree, I think I would advocate for trying to build the built-in slash commands such as /compact with the sdk, in other words forcing yourself to use the same functionality that a custom plugin developer would use. That would drive a architecture which makes sure that user custom commands can be just as powerful as the ones provided by default. |
rekram1-node
commented
Dec 1, 2025
Yup total agreement, currently jumping between several fixes and then I can come back to these new feature prs |
I have the new version mostly implemented but I'm on holiday atm - feel free to take it over or close as I won't able to do the final "runnable as functions" part. But I have done the "custom md file to implement custom compact-type command". I can add precedence for overriding /compact - that's a good idea. |
10a1998 to
0ee7d14Compare/compact via markdown filesd47ece7 to
69bcc27Comparemaxeonyx
commented
Dec 8, 2025
@rekram1-node@einarpersson This PR is ready for your review, hope it's what you are imagining. It has turned out pretty clean I think. |
bd56afe to
ec204d7Compare/compact via markdown files/compact commandsb574f2b to
6df3686Comparemaxeonyx
commented
Dec 17, 2025
@rekram1-node Keeping this up-to date is becoming a hassle - would you be able to review? |
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
/compact commandsd9e801f to
6e8d1e1Compare6e8d1e1 to
61cac9eCompare61cac9e to
55cde50Compare
This will help to address the manyissuesaboutcompaction
Closes#3031
I have had great success using this version with a custom "handover" compact prompt.
example: override
/compactwithcompact.mdThis will now affect auto-compaction.
~/.config/opencode/command/compact.mdexample: custom command
/handover~/.config/opencode/command/handover.mdexample: set auto-compact to use
/handover~/.config/opencode/opencode.json{ "compaction": { "command": "handover" } }I have spent a lot of time making this PR as small and well integrated as possible, as I'm relying on it for my day-to-day work.