You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mapUsage(): use === undefined, not > 0, for reasoningTokens (follow-up to #7110)
#10840
Follow-up to #3825 and #7110 — same defect, one new detail.
I filed this before searching, so it duplicates the two existing reports. Reporting it again would only add noise, so here is the only part that isnotalready on record.
@earendil-works/pi-ai1.3.0,dist/types.d.ts:279-292, documents the field'spresenceas the signal:
Reasoning/thinking tokens, when the provider reports them. This is a subset ofoutput… Set to a number (possibly 0) by providers that expose a reasoning breakdown;leftundefinedby providers that don't.
So0andundefinedmean different things — "provider reported zero reasoning tokens" vs "provider does not report a breakdown at all" — andusage.reasoning > 0collapses them, discarding the legitimate0case. The cache fields above use> 0only because they arenumber(neverundefined);reasoningisreasoning?: number, so the guard has to be an existence test:
outputTokensmust stayusage.output: pi-ai's ownopenai-completions.jsalready carriescompletion_tokensintooutputinclusive of reasoning tokens, so adding reasoning there would double-count it. The nested conditional is intentional — spreading{}keeps the fieldabsentrather than emittingreasoningTokens: undefined.
One data point on the effect
Privately patched into the packagedapp.asar(DSH Desktop 0.2.1-rc.2, Windows,alibaba-cn/deepseek-v4.1-flash-1017), same session rebuilt after a restart:
| usage records | records carrying reasoningTokens
-- | -- | --
before | 219 | 0
after | 171 | 41 (values 1516, 1516, 224, 224, 385, 385 …)
That is enough for me to confirm the one-line fix resolves it end to end, from the adapter throughLedger.account()intodays[].reasoning.
Please treat this as a duplicate
Closing it in favour of #7110 (with the>= 0/=== undefinedcorrection above folded in) is the right outcome. I am not asking for a second fix — #3825 already has the diagnosis and #7110 already has a proposed patch; the only actionable delta is the guard.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Follow-up to #3825 and #7110 — same defect, one new detail.
I filed this before searching, so it duplicates the two existing reports. Reporting it again would only add noise, so here is the only part that is not already on record.
The snippet in #7110 is unsafe
#7110 suggests:
@earendil-works/pi-ai1.3.0,dist/types.d.ts:279-292, documents the field's presence as the signal:So
0andundefinedmean different things — "provider reported zero reasoning tokens" vs "provider does not report a breakdown at all" — andusage.reasoning > 0collapses them, discarding the legitimate0case. The cache fields above use> 0only because they arenumber(neverundefined);reasoningisreasoning?: number, so the guard has to be an existence test:outputTokensmust stayusage.output: pi-ai's ownopenai-completions.jsalready carriescompletion_tokensintooutputinclusive of reasoning tokens, so adding reasoning there would double-count it. The nested conditional is intentional — spreading{}keeps the field absent rather than emittingreasoningTokens: undefined.One data point on the effect
Privately patched into the packaged
app.asar(DSH Desktop 0.2.1-rc.2, Windows,alibaba-cn/deepseek-v4.1-flash-1017), same session rebuilt after a restart:That is enough for me to confirm the one-line fix resolves it end to end, from the adapter through
Ledger.account()intodays[].reasoning.Please treat this as a duplicate
Closing it in favour of #7110 (with the
>= 0/=== undefinedcorrection above folded in) is the right outcome. I am not asking for a second fix — #3825 already has the diagnosis and #7110 already has a proposed patch; the only actionable delta is the guard.All reactions