Repository navigation
fix: keep the Auto route across plugin reloads - #8
Merged
Merged
Conversation
opencode reloads plugins on every config change and recycles idle instances. That dropped every pinned route, so the next turn routed again on whatever was typed last and could switch the model mid-conversation, losing its prompt cache. Routes are now kept per session and auto, with their session token, in routes.json next to the plugin log (mode 0600, written atomically) until the token expires. A restored route the auto can no longer send is routed again, and a compaction marks restored routes for re-routing too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
opencode reloads plugins on every config change and recycles idle instances. Each reload dropped the pinned route, so the next turn routed again on the last prompt alone and could switch the model mid-conversation (seen in the plugin log:
gpt-6-luna → gpt-6.1-solafter a config change, back togpt-6-lunaon an 8-character prompt the next morning), losing the prompt cache.Evidence
66 pass, 4 failbun run typecheck && bun run build && bun test→75 pass, 0 failThe other new tests guard behaviour that must not change: an expiring token, a model the anchor can no longer send, and a compaction before or after the reload all still route again.
Merge Danger
Door: two-way
Revert and the plugin ignores
routes.jsonagain. The file holds only Auto session tokens (24 h, routing only, not the GitHub credential), owner-only.Blast Radius: routing
A bad restore would pin a conversation to a stale model until its token expires. Restores are checked for expiry and servability; a failed write is logged and never breaks a turn.
🤖 Generated with Claude Code