Skip to content

Conversation

@maxeonyx
Copy link

@maxeonyx maxeonyx commented Nov 10, 2025

This will help to address the many issues about compaction

Closes #3031

I have had great success using this version with a custom "handover" compact prompt.

example: override /compact with compact.md

This will now affect auto-compaction.

~/.config/opencode/command/compact.md

---
description: my custom compact
compact: true
---

Provide a detailed summary focusing on ...

example: custom command /handover

~/.config/opencode/command/handover.md

---
description: handover to new agent
compact: true
---

Produce a handoff note from this conversation ...

example: 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.

@maxeonyx maxeonyx changed the title feat: add handover mode to /compact command feat: make /compact prompt configurable via compactPrompt config Nov 10, 2025
@maxeonyx maxeonyx force-pushed the feature/compact-handover-mode branch from 55d51e3 to 03211fa Compare November 10, 2025 00:34
@rekram1-node
Copy link
Collaborator

@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
Copy link
Author

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
Copy link
Author

@rekram1-node in your suggestion, then, I would define my own /handover slash command, with a different prompt, and configured to remove the rest of the context same as /compact (and we would also make /compact be implemented the same way)

@maxeonyx maxeonyx force-pushed the feature/compact-handover-mode branch from 03211fa to 10a1998 Compare November 11, 2025 23:23
@github-actions github-actions bot force-pushed the dev branch 3 times, most recently from f1dc981 to 3e15a39 Compare November 22, 2025 18:07
@github-actions github-actions bot force-pushed the dev branch 3 times, most recently from f8ee907 to 6a9856d Compare November 27, 2025 01:29
@einarpersson
Copy link

einarpersson commented Nov 28, 2025

@rekram1-node

@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

I agree, I think
1.compact should be a default includes slash command
2. Default included slash commands should be able to be overriden by user custom commands
3. User custom commands should be able to run as functions, something like #4411

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

Yup total agreement, currently jumping between several fixes and then I can come back to these new feature prs

@maxeonyx
Copy link
Author

maxeonyx commented Dec 2, 2025

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.

@maxeonyx maxeonyx force-pushed the feature/compact-handover-mode branch from 10a1998 to 0ee7d14 Compare December 7, 2025 23:25
@maxeonyx maxeonyx marked this pull request as draft December 7, 2025 23:36
@maxeonyx maxeonyx changed the title feat: make /compact prompt configurable via compactPrompt config feat: support custom compact commands via markdown files Dec 7, 2025
@maxeonyx maxeonyx changed the title feat: support custom compact commands via markdown files feat: support custom /compact via markdown files Dec 7, 2025
@maxeonyx maxeonyx marked this pull request as ready for review December 8, 2025 02:36
@maxeonyx maxeonyx force-pushed the feature/compact-handover-mode branch from d47ece7 to 69bcc27 Compare December 8, 2025 03:36
@maxeonyx
Copy link
Author

maxeonyx 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.

@maxeonyx maxeonyx force-pushed the feature/compact-handover-mode branch 2 times, most recently from bd56afe to ec204d7 Compare December 12, 2025 01:23
@maxeonyx maxeonyx changed the title feat: support custom /compact via markdown files feat: support custom /compact commands via configuration Dec 12, 2025
@maxeonyx maxeonyx changed the title feat: support custom /compact commands via configuration feat: support custom /compact commands Dec 12, 2025
@maxeonyx maxeonyx force-pushed the feature/compact-handover-mode branch from b574f2b to 6df3686 Compare December 16, 2025 03:07
@maxeonyx
Copy link
Author

@rekram1-node Keeping this up-to date is becoming a hassle - would you be able to review?

@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@maxeonyx maxeonyx changed the title feat: support custom /compact commands feat: configurable compaction Jan 12, 2026
@maxeonyx maxeonyx force-pushed the feature/compact-handover-mode branch from 3426717 to 0560497 Compare January 14, 2026 09:15
@maxeonyx maxeonyx force-pushed the feature/compact-handover-mode branch from 0560497 to d9e801f Compare January 14, 2026 09:35
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.

Model in BUILD mode does not have enough context to continue after compaction

3 participants