feat(opencode): show round usage metadata - #1668
Open
junmo-kim wants to merge 2 commits into
Open
Conversation
This was referenced Aug 22, 2026
There was a problem hiding this comment.
Findings
- [Major] Keep telemetry off the prompt critical path —
captureOpencodeRoundSnapshot()performs a full/messagefetch and JSON parse beforesession.onThinkingChange(true)andbackend.prompt(). Its deadline is 1 second, so a slow/unavailable OpenCode HTTP API delays every user prompt by up to a second; because the endpoint returns the complete history, the work also grows with session length. Evidence:cli/src/opencode/opencodeRemoteLauncher.ts:627,cli/src/opencode/utils/opencodeRoundSummary.ts:81,cli/src/opencode/utils/opencodeRoundSummary.ts:90.
Suggested fix:private nextRoundSnapshot: OpencodeRoundSnapshot | null = null const roundSnapshot = this.nextRoundSnapshot ?? await captureOpencodeRoundSnapshot({ baseUrl, sessionId: acpSessionId, signal }) this.nextRoundSnapshot = null // Return the validated post-fetch ID snapshot alongside the optional summary. const result = await fetchOpencodeRoundSummary({ ...options, snapshot: roundSnapshot }) if (result) { this.nextRoundSnapshot = result.snapshot if (result.summary) this.handleAgentMessage({ type: 'round_summary', summary: result.summary }) }
Summary
- Review mode: initial
- One major performance regression found in the OpenCode prompt path.
Testing
- Not run (automation). GitHub
test,integration, anddrift-gatechecks pass. - Add a launcher regression test proving a second prompt reuses the prior post-fetch snapshot and does not wait on another pre-prompt full-history request.
HAPI Bot
There was a problem hiding this comment.
Findings
- No high-confidence issues found in the latest diff.
Summary
Review mode: follow-up after new commits
The prior Major finding is addressed: the launcher now reuses the validated post-fetch snapshot for subsequent prompts and invalidates it before explicit compaction. Residual risk remains around compatibility with OpenCode's internal message API; the implementation fails closed by omitting metadata.
Testing
- Local tests not run: Bun is unavailable in the review environment.
- GitHub
test,integration, and fixturedrift-gatechecks pass. git diff --checkpasses.
HAPI Bot
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
OpenCode previously exposed only the final ACP usage row to the UI. Tool-loop calls, compaction summaries, and synthetic continuations could therefore be omitted from the response metadata popover.
Solution
This change snapshots OpenCode persisted message IDs before each prompt, fetches the post-prompt delta, and aggregates every valid assistant row by provider/model. It sends an HAPI-owned
round-summarycarrier before ready and reuses the existing response-group metadata popover. Malformed data, duplicate IDs, unavailable APIs, parse failures, timeouts, and aborted requests fail closed by omitting only the summary.Screenshots
Tests
bun typecheckbun run testbun run buildgit diff --checkopencode/big-pickleend-to-end on desktop and mobile viewports, including a two-step tool loop and summary-before-ready ordering.