Primary finding
OpenAIProvider does not check options.signal.aborted before estimating output tokens on aborted streams
- src/providers/openai.ts:148-161
If a request is aborted before the server returned a usage block, both inputTokens and outputTokens default to 0 and are then estimated from messages.length / responseText.length. For aborted requests, this leads to charging the user for ~all of their input even though the request may not have been billed by the upstream provider. Conversely, an unestimated aborted output looks like 'zero output' which pricing.calculateCost will then treat as truly zero.
Recommendation
Skip estimation (or mark usage as undefined/unknown) when options.signal.aborted is true; only estimate on successful completions lacking usage info.