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.

Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
committed 2026-10-19 20:35:13 +02:00
1 parent d3083b7940
commit b715e414dc
8 files changed
+317 -27

No files matched your search

+20 -7
View File
@@ -54,19 +54,25 @@ and 405 for `GET`), because the reason a connection fails is the useful part:
```json
{"ok":true,"model":"Qwen3.8","endpoint":"https://ai.lago.dev/v1/chat/completions",
"latency_ms":412,"reasoning_disabled":true,"reasoning_tokens":0,"content":"OK",
"latency_ms":424,"reasoning_disabled":false,"reasoning_tokens":null,"content":"OK",
"warning":null,"error":null}
```
- `reasoning_tokens` is the provider's own
`usage.completion_tokens_details.reasoning_tokens`, or **`null` when the
provider sent no `usage` block**. `null` is not "off"; `reasoning_disabled` is
`true` only when it is exactly `0`.
`usage.completion_tokens_details.reasoning_tokens`, or **`null` when the provider
does not report one** — no `usage` block, no `completion_tokens_details`, or an
empty one. `reasoning_disabled` is `true` only when the value is exactly `0`.
- `warning` is set **only when reasoning tokens are actually reported and are
non-zero**. "Not reported" is a distinct third state: `ai.lago.dev` answers
`completion_tokens_details: {}`, so treating an absent counter as a warning made
every healthy production connection look broken. The reply above is the real
production shape — the request went out with thinking disabled and came back in
424 ms on 2 completion tokens; the counter simply is not exposed.
- `ok` answers "would generating a summary work?" — transport, auth and parsing
all fine. A working connection whose provider still reports reasoning tokens is
therefore `ok: true` with `reasoning_disabled: false` and a `warning`, so the
therefore `ok: true` with `reasoning_disabled: false` **and** a `warning`, so the
honest signal about cost stays separate from the pass/fail answer. The Admin UI
colours that case amber, not green.
colours that case amber, not green; an unreported counter is neutral.
- It never writes to the database, and the API key never appears in any field:
provider error text is flattened, truncated to 300 characters and the stored key
is replaced with `[redacted]` (a provider that echoes the Authorization header
@@ -91,9 +97,16 @@ Both requests (summaries and the test) are built by one helper,
deliberately not used.
- `max_tokens` is accepted and ignored, so it is not sent.
- **A `200 OK` proves nothing**: this endpoint ignores unknown fields entirely.
Only `usage.completion_tokens_details.reasoning_tokens === 0` is evidence.
Reasoning *levels* are validated though — `reasoning_effort: "banana"` is an
HTTP 400 `unsupported_value`, which is how the field was confirmed to be live.
- **But `reasoning_tokens === 0` is not always obtainable either.** Re-measured
against production after the deploy, a `"Reply with OK"` request returns
`usage.completion_tokens_details: {}` — the gateway reports the *absence* of the
counter, not a zero. Thinking is verifiably off there by other means (2
completion tokens for a one-word reply, 424 ms), but the field cannot be asserted
from the response. So `/llm-test` treats "not reported" as its own state and does
not warn about it; asserting `reasoning_disabled: true` would be a claim the
provider does not support.
The sidecar checks that the event exists and that a selected session belongs to
it. It reads all feedback in ordered 500-row pages, selecting only `rating` and