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

+12 -7
View File
@@ -300,19 +300,24 @@ a verdict rather than an exception, so the UI can name the reason:
| What you see | Meaning |
|---|---|
| "Connection works — replied in 412 ms" | Endpoint, key and response parsing are all fine, and the provider reported **0 reasoning tokens**. |
| "Connection works, but the model is still thinking" | The transport is fine but reasoning tokens came back, so summaries will be slow and costly. The endpoint is ignoring the thinking-off fields. |
| "Connection failed" + one line of detail | No settings saved yet, a non-2xx from the provider (a wrong key reads as `HTTP 401: …`), an endpoint that failed validation, a timeout, or a reply with no content. |
| **Green** "Connection works — replied in 412 ms" | Endpoint, key and response parsing are fine, **and** the provider reported `reasoning_tokens: 0`. |
| **Neutral** "Connection works — replied in 424 ms", with "This endpoint does not report a reasoning-token count…" | The transport is fine; the provider simply does not return a reasoning counter. **This is the normal state for `ai.lago.dev`**, which answers `usage.completion_tokens_details: {}`. Thinking is still sent disabled; it just cannot be confirmed from the usage block. |
| **Amber** "Connection works, but the model is still thinking" | The transport is fine but non-zero reasoning tokens came back, so summaries will be slow and costly — the endpoint is ignoring the thinking-off fields. |
| **Red** "Connection failed" + one line of detail | No settings saved yet, a non-2xx from the provider (a wrong key reads as `HTTP 401: …`), an endpoint that failed validation, a timeout, or a reply with no content. |
Three things are deliberate here:
- The button is **disabled while the form has unsaved changes**. The key never
reaches the browser, so a test can only ever exercise what is stored — being
able to press it against half-typed values would report on the wrong endpoint.
- `reasoning_tokens: null` means the provider sent no `usage` block at all. It is
shown as "not reported by this endpoint", never as zero: **only `0` proves
thinking is off**, since these gateways answer `200 OK` while silently ignoring
fields they do not implement.
- The reasoning verdict is **three-state, not two**. `0` means "reported and
off"; `null` means "this provider does not report it"; only a reported
non-zero value raises the warning. Collapsing `null` into the warning was the
first implementation and it was wrong: measured against the production
gateway, which omits the counter entirely, every healthy connection showed a
"still thinking" warning. `null` is never displayed as zero — **only `0`
proves thinking is off**, because these gateways answer `200 OK` while
silently ignoring fields they do not implement.
- The verdict is rendered on the page, not as a toast — the latency and the
reasoning line are worth reading twice, and a toast expires.