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:
Lago committed 2026-10-19 20:35:13 +02:00
1 parent fdb6045966
commit d14e1c2ddd
8 files changed
+317 -27

No files matched your search

+23
View File
@@ -159,6 +159,29 @@ test('llm-test reports thinking still on without calling it a clean pass', async
assert.match(verdict.warning, /thinking is still enabled/);
});
test('llm-test treats an unreported reasoning count as unknown, not as a warning', async () => {
// What ai.lago.dev actually answers: a usage block whose
// completion_tokens_details is EMPTY. Reading that as "still thinking" told
// admins their working gateway was misconfigured, so the verdict has to be ok
// with no warning and reasoning_tokens: null — null means "not reported",
// deliberately different from 0, which means "reported and off".
const shapes = [
{ label: 'empty details', usage: { completion_tokens: 2, completion_tokens_details: {} } },
{ label: 'no usage block', usage: undefined },
{ label: 'details absent', usage: { completion_tokens: 2 } },
];
for (const shape of shapes) {
const { api } = fixture({ providerFetch: async () => new Response(JSON.stringify({
choices: [{ message: { content: 'OK' } }], usage: shape.usage,
})) });
const verdict = await api.handle(request(), '/llm-test');
assert.equal(verdict.ok, true, shape.label);
assert.equal(verdict.reasoning_tokens, null, shape.label);
assert.equal(verdict.reasoning_disabled, false, shape.label);
assert.equal(verdict.warning, null, shape.label);
}
});
test('llm-test answers ok:false for unconfigured settings, provider errors and blocked endpoints', async () => {
const cases = [
{ label: 'no settings stored', options: { noSettings: true }, match: /No LLM endpoint and model are configured/ },