fix(llm-test): an unreported reasoning-token counter is not a warning
Measured against the gateway this deployment actually uses (ai.lago.dev), a
"Reply with OK" request comes back with usage.completion_tokens_details: {} --
the provider does not report a reasoning counter at all. Thinking is
verifiably off there (2 completion tokens, 424 ms, versus ~235 tokens and
~3.5x latency when on), but reasoning_tokens is undefined, not 0.
The verdict had two states, so a healthy production connection rendered amber
with "the model is still thinking" -- the button would have reported a working
configuration as broken. The reasoning verdict is now three-state:
- reported 0 -> reasoning_disabled: true, green
- not reported -> reasoning_tokens: null, no warning, neutral card that
says it cannot be confirmed from the usage block
- reported and > 0 -> amber + the existing warning
Only a reported 0 asserts reasoning_disabled, so the UI still never claims
thinking is off without evidence.
Sidecar 34 -> 35 tests (all three unreported shapes assert no warning); new
e2e/tests/llm-connection-test.spec.ts, 6 tests, covering the three verdict
tones, the failure case, the dirty-form lock and the in-flight state.
This commit is contained in:
1 parent
fdb6045966
commit
d14e1c2ddd
8 files changed
+317
-27
No files matched your search
@@ -95,16 +95,29 @@ function createFeedbackApi({ supabaseFetch, supabaseUrl, serviceRoleKey, fetchIm
|
||||
if (typeof content !== 'string' || !content.trim()) {
|
||||
return { ...base, endpoint: config.endpoint, latency_ms: latency, error: 'LLM endpoint responded but the reply contained no message content' };
|
||||
}
|
||||
// The only honest signal that thinking is off (a 200 proves nothing — this
|
||||
// endpoint ignores unknown fields).
|
||||
// Three-state reasoning verdict, because all three shapes occur in the wild
|
||||
// and they do not mean the same thing:
|
||||
// reasoning_tokens === 0 -> the provider reports it, and thinking is off.
|
||||
// reasoning_tokens > 0 -> thinking is still on; that IS a warning.
|
||||
// key absent / details empty -> the provider does not report reasoning tokens
|
||||
// at all. ai.lago.dev does exactly this (it answers
|
||||
// `completion_tokens_details: {}`), so this is the normal case for us, not
|
||||
// an edge case. Reading "not reported" as "still thinking" tells an admin
|
||||
// that a working configuration is broken, which is a false alarm — so the
|
||||
// warning is limited to tokens actually being reported.
|
||||
// A 200 alone still proves nothing (this endpoint ignores unknown fields), so
|
||||
// only a reported 0 asserts `reasoning_disabled`.
|
||||
const reasoningTokens = payload?.usage?.completion_tokens_details?.reasoning_tokens;
|
||||
const reported = Number.isInteger(reasoningTokens);
|
||||
const reasoningDisabled = reasoningTokens === 0;
|
||||
return {
|
||||
...base, ok: true, error: null, endpoint: config.endpoint, latency_ms: latency,
|
||||
reasoning_disabled: reasoningDisabled,
|
||||
reasoning_tokens: Number.isInteger(reasoningTokens) ? reasoningTokens : null,
|
||||
reasoning_tokens: reported ? reasoningTokens : null,
|
||||
content: safeProviderText(content, config.api_key).slice(0, 500),
|
||||
warning: reasoningDisabled ? null : 'The connection works but reasoning tokens were reported, so thinking is still enabled — summaries will be slow and costly.',
|
||||
warning: reported && !reasoningDisabled
|
||||
? 'The connection works but reasoning tokens were reported, so thinking is still enabled — summaries will be slow and costly.'
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user