Repository navigation
Conversation
…ping During an agent run most output is tool-call arguments (e.g. a file body for write/edit). OpenCode V2 streams those as session.tool.input.delta, which the meter ignored, so the live rate fell to "-" while the model was busy writing. Count them like text and reasoning deltas. Local models served by llama-swap are worse off: llama-server holds a tool call back until it is complete, so OpenCode emits no events at all while one is generated. With the new opt-in llamaSwapProviders option the meter polls llama-server's per-slot n_decoded counter through llama-swap from step start to execution end and records exact decoded tokens; event deltas remain the fallback when llama-swap does not answer. The meter text also no longer wraps onto a second row when the prompt.footer.status slot gets narrow.
This branch has not been deployed
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.
Problem
On OpenCode V2 the live rate drops to
tok/s -for most of an agent run, even while the model is generating:session.tool.input.delta.wireV2only listens tosession.text.deltaandsession.reasoning.delta, so afteridleTimeoutMsthe rate falls to-during the "Preparing write…" phase./api/eventon OpenCode 2.3.2:session.tool.input.started→endedarrive together at the end, with no deltas in between, while llama-server's/slotsshowedn_decodedclimbing at about 37 tok/s the whole time. No event-based meter can see those tokens.Changes
src/v2.tssession.tool.input.deltaand record it like the other deltas.llamaSwapProviders, pollGET {llamaSwapUrl}/upstream/<model>/slotseveryllamaSwapPollMsfromsession.step.starteduntil the execution ends, and record the growth of the processing slot'sn_decoded(exact token counts). The first reading only sets the baseline, and a newid_task(the next step of a tool loop) counts from zero. While llama-swap answers, its counter replaces event deltas so nothing is counted twice. If it fails or is unreachable, event deltas are used as before. Polling stops on execution end, onsession.deletedand on dispose.fetch/nowcan be injected (optional 4th parameter) so the poller is testable.src/tui.tsx: the meter<text>getswrapMode="none"andflexShrink={0}. A narrowprompt.footer.statusused to wrap the line onto two rows (… · cache/82%).New options (V2 only, polling is off by default):
llamaSwapUrl"http://127.0.0.1:8080"llamaSwapProviders[]llamaSwapPollMs250Testing
npm test: 125 pass. New tests cover tool-input deltas, polling across an execution, slot-counter precedence over deltas, a new request on the slot, no polling when it isn't configured or for remote providers, and the llama-swap-down fallback plus stopping on dispose.npm run typecheck: clean.tok/s -the whole time. After: the live rate tracked llama-server's own decode speed (about 36–37 tok/s, graph and trend updating).npm run smokefails on my machine (npm 11 / Node 26) the same way onmainwithout these changes, at thenpm pack --jsonparsing inscripts/smoke.mjs. CI's Node 20/22 should be unaffected.