[Fix] Fast mode underreports inference costs during multi-agent turns - #1632
Closed
roomote-roomote[bot] wants to merge 1 commit into
Closed
[Fix] Fast mode underreports inference costs during multi-agent turns#1632roomote-roomote[bot] wants to merge 1 commit into
roomote-roomote[bot] wants to merge 1 commit into
Conversation
Contributor
|
|
||
| await recordNonTaskOpenCodeUsage(params, model, promptResult.data.info); | ||
|
|
||
| if (options.onSubagentSessionReady) { |
Contributor
There was a problem hiding this comment.
The reconciliation only runs after the parent prompt succeeds. If Fast delegates to an advisor/judge, their completion events are missed, and the parent then returns an error or times out, control jumps to the outer catch before this block and none of the completed child usage is recovered. Those failed turns still incur provider cost, so move reconciliation into a finally/error-safe path (while retaining the original prompt error) and add a regression case for a failed parent after a completed child.
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.
What changed
llm_usage_events.non-task:<source>:<session>:<message>keys, preserving user, source, optional task, provider, model, agent, token, and cost attribution through idempotent upserts.Why this change was made
Fast previously persisted only the final parent prompt result. Intermediate parent model calls and advisor/judge sessions could therefore be billed by the provider without appearing in Roomote Costs analytics.
Impact
Fast multi-step and multi-agent turns now produce complete non-task inference cost rows, including user attribution and the expected
fast_agentsource. Existing standard-task accounting and the database schema are unchanged.OpenCode 1.18.10 does not expose an upstream OpenRouter request or generation identifier on assistant-message or step-finish events. Exact row-level provider reconciliation remains a focused follow-up: when the SDK exposes that identifier, persist it in the existing usage
detailsorpricingMetadatafields without adding another usage table.