fix(openrouter): reconcile streamed generation cost#91073
Conversation
|
Land-ready proof for #68066: Behavior addressed: completed OpenRouter streaming chat completions now reconcile Real environment tested: yes, with stored Exact commands run after this patch: node scripts/run-vitest.mjs extensions/openrouter/index.test.ts extensions/openrouter/provider-runtime.contract.test.ts
node scripts/run-vitest.mjs extensions/openrouter
pnpm exec oxfmt --check extensions/openrouter/stream.ts extensions/openrouter/index.test.ts
git diff --check
/Users/steipete/Projects/agent-scripts/skills/autoreview/scripts/autoreview --mode local --prompt-file /tmp/openrouter-autoreview-evidence.mdObserved result after fix: focused OpenRouter provider tests passed, full OpenRouter extension tests passed (8 files / 79 tests), formatting and diff whitespace checks passed, and autoreview reported no accepted/actionable findings after the accepted abort-path fix. What was not tested: I did not rerun the expensive long-context tiered-pricing repro from #68066; the live test covered the real response-id to generation-metadata contract and the patch covers the persisted final message path. |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(openrouter): reconcile streamed generation cost This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Found 2 test failures on Blacksmith runners: Failures
|
|
CI note before landing: Relevant proof for this PR passed:
CI failures inspected from run
|
Summary
total_costbefore the final assistant message is emitted.Fixes #68066.
Verification
/api/v1/generation?id=...returns request/usage metadata includingtotal_cost: https://openrouter.ai/docs/api/api-reference/generations/get-generationOPENROUTER_API_KEY: streamedgoogle/gemini-2.5-flashchat completion returned HTTP 200,gen-...response id,finish=stop, streamed cost0.0000049; delayed generation lookup returned HTTP 200 with matching id,streamed=true,cancelled=false,total_cost=0.0000049.node scripts/run-vitest.mjs extensions/openrouter/index.test.ts extensions/openrouter/provider-runtime.contract.test.tsnode scripts/run-vitest.mjs extensions/openrouterpnpm exec oxfmt --check extensions/openrouter/stream.ts extensions/openrouter/index.test.tsgit diff --checksrc/agents/embedded-agent-runner/stream-resolution.tsand existingstream-resolution.test.tsresolved-key coverage.Not Tested