r/opencode • • 10d ago

A different way to handle context in OpenCode: /rollover

Post image

I've been getting a bit tired of constantly dealing with context in OpenCode. Compaction, context limits, token costs, manually opening new sessions and then trying to get the new session up to speed again.

I wanted to get away from that workflow, so I built a /rollover method.

It basically monitors context usage and automatically transitions to a fresh context when needed, without interrupting the current task. It carries over the relevant context and keeps the same session ID, so you don't have to keep creating new sessions manually.Just published it on GitHub and npm.

GitHub: https://github.com/omeryasirkucuk/context-rollover

npm: https://www.npmjs.com/package/context-rollover

Give it a try if you're running into the same issues. You'll be first testers of it. So I need to hear from u. I'd really appreciate some feedback, especially from people using OpenCode for longer coding sessions. Let me know what you think or if you run into any issues.

5 Upvotes

8 comments sorted by

2

u/deleted-account69420 9d ago

That does look it breaks cache.

1

u/omeryasirkucuk 9d ago

Fair point. Cache efficiency is definitely a trade-off here. I'm more focused on avoiding the constant cycle of compaction, losing context, and starting new sessions. I'd rather explore a different context management strategy than keep working around the limitations of the existing ones.

1

u/omeryasirkucuk 9d ago

I know it's an mvp, but one of my main goals was to get away from manually managing context. I got tired of constantly deciding when to compact, monitoring token usage, and switching sessions. I wanted to automate that whole process.

3

u/deleted-account69420 9d ago

I'd take a look on how https://github.com/cortexkit/magic-context handles this.
DCP is an alternative, but worse in cache management.

1

u/omeryasirkucuk 9d ago

Oh thanks, I haven't heard it yet. I'll definitely look at that

2

u/[deleted] 9d ago

[removed] — view removed comment

1

u/deleted-account69420 9d ago

Magic Context does dynamic context pruning that does not break cache.

2

u/ccss2 9d ago edited 9d ago

..