Repository navigation
opencode: hand over a quiet session, and follow the session's model in side calls - #230
Open
Have-Purple wants to merge 2 commits into
Open
Have-Purple wants to merge 2 commits into
Have-Purple wants to merge 2 commits into
Conversation
On 2.x 'opencode run' and the TUI are the same background service, so mode() cannot tell them apart: a headless run only folded at the next session start. A session quiet for TE's own recovery rule (fold.STALE_S, 600 s; TE_OPENCODE_QUIET_MS overrides it) is now handed over on a timer. Where mode()=='run' can still be detected, the immediate hand-over is unchanged, and any prompt or tool call resets the timer.
With neither opencode_paid_model nor paid_model set, a side call ran 'opencode run' with no --model and took the CLI's configured default. That default can be a free model the session has already moved past; the free tier's 429 then looked like the plugin was broken while the session ran fine on a paid provider. The 2.x plugin now reports the model from session.step.started (provider/model#variant) with each hook; the session state keeps it, and the loop guard's judge and the micro-skills proposer use it where no paid_model is set. An explicit paid_model still wins, and the other hosts keep their own defaults (Claude's haiku): the fallback is opencode-only.
|
Have-Purple please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Author
|
@microsoft-github-policy-service agree |
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.
Two small fixes for 2.x. They touch different code paths and can be split if you'd rather take one.
1. A quiet session is handed over
mode()readsprocess.argvfor"run", but 2.x runs plugins in the background service:opencode runand the TUI are both the sameserve --serviceprocess, so the plugin cannot tell a headless run from an interactive one. A headless run therefore only folded at the next session start, through the recovery path.A session quiet for
fold.STALE_S(600 s) is now handed over on a timer, matching TE's own recovery rule.TE_OPENCODE_QUIET_MSoverrides the window (floor 10 s). Wheremode() == "run"can still be detected, the immediate hand-over is unchanged.2. Side calls follow the session's model
With neither
opencode_paid_modelnorpaid_modelset, the plugin ranopencode runwith no--model, so TE used the CLI's configured default. That default can be a free model the session has already moved past — the resulting 429s looked like TE being broken while the session was running fine on a paid provider.The plugin now reports the model from
session.step.startedasprovider/model#variantwith each hook. The session state keeps it; the loop guard's judge and the micro-skills proposer use it when nopaid_modelis set. An explicitpaid_modelstill wins, and other hosts keep their own defaults (Claude'shaiku) — the fallback is opencode-only.Design notes
fold.STALE_S; the model fallback changes cost semantics. Both can be gated behind config, or this PR can be split, if that fits the project better.100755), so the 1.x/shpath is untouched.Tests
end_reason == "idle"after the window, while the process is still up;session.step.startedwith its hooks (end-to-end under opencode's runtime);paid_modelwins, Claude stayshaiku;Verification
opencode 2.3.0, Python 3.15, Windows. The full offline suite is green locally. I could not reproduce CI's opencode 2.2.5 matrix here, so that run is the one thing I'd watch on the PR.