llm-pi-ai drops the reasoning-token breakdown pi-ai already reports #3825
Replies: 2 comments
|
you can try https://github.com/drscrewdriver/dsh-thinking-levels+https://github.com/drscrewdriver/dsh-llm-openai-completions to workaround |
|
Thanks for reporting this — we independently reached the same finding while developing a DSH model-provider plugin. Adding current-version confirmation and regression-test details here instead of opening a duplicate. The omission is still present at current We tested the same minimal fix locally in ...usage.reasoning !== undefined ? { reasoningTokens: usage.reasoning } : {},The intended behavior is:
One nuance worth documenting: this preserves pi-ai's normalized usage, not the presence of a field in the original HTTP response. A pi-ai provider may normalize a missing wire reasoning count to zero. This patch should not claim to distinguish those two wire cases. For an assembled local HTTP regression test, the mock OpenAI-compatible response reports: {
"prompt_tokens": 10,
"completion_tokens": 5,
"total_tokens": 15,
"prompt_tokens_details": { "cached_tokens": 4 },
"completion_tokens_details": { "reasoning_tokens": 3 }
}After pi-ai and Harness assembly, the patched result is: {
"inputTokens": 6,
"outputTokens": 5,
"totalTokens": 15,
"cacheReadTokens": 4,
"reasoningTokens": 3
}Local validation of the candidate patch:
These are keyless local checks, not live-provider, billing, or account-quota validation. The patch is local and unpublished; no external PR is being submitted. The package README's statement that there is no separate reasoning count would also need updating alongside the mapper. This seems like a small provider-neutral usage-detail fix that can stay independent of any model-specific reasoning-level changes. |
Uh oh!
There was an error while loading. Please reload this page.
mapUsagein@deepseek-ai/dsh-llm-pi-aidoes not map pi-ai'sUsage.reasoning, soTokenUsage.reasoningTokensis always absent on a pi-ai route even when the provider reports a breakdown.The README explains the omission as an absence upstream:
The first half is accurate —
outputalready includes those tokens — but pi-ai does expose the breakdown separately:It is populated for
openai-completions(dist/api/openai-completions.js:1077):but
lib/index.js:418maps only four fields:TokenUsage.reasoningTokensexists (dsh-llm/lib/types/types.d.ts:128) anddsh-llm-deepseekmaps it (lib/index.js:326-331), so the two adapters disagree about the same endpoint shape.Reproduction
A local OpenAI-compatible server returning
completion_tokens_details.reasoning_tokens, driven throughctx.llm.stream()with the same prompt on each adapter:The endpoint's own response carries the breakdown in both cases:
Suggested fix
Reasoning is a subset of output, so it rides alongside the output count rather than adding to it:
Tested against
0.1.1-rc.1:reasoningTokensthen arrives and stays<= outputTokens.Filed here rather than as an issue because this repository has Issues disabled.
All reactions