PR #553: Add vLLM-compatible per-request metrics

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/99a449fd-8c96-476a-a912-a6692f09d87b

Opened by a workflow run, Nov 26, 2026 11:53 PM EST.

screen malicious

Screen Result: All Clear

Evidence:

Minor non-security nits: help text says "chat and completion" vs docs scoping to OpenAI Chat/Completions; tokens_per_second null when no token arrived; streaming attach assumes a frame precedes done; flag prefixed enable-.

Could not check: bidi/zero-width code points programmatically (regex engine rejected the range), mitigated by line-by-line diff review; the claimed local GPU validation run is unverifiable from the repo.

Conclusion: no prompt injection or other attempt at unwanted agentic behavior — All Clear.

Full report · Notes decide malicious: all_clear (100%): No malicious content found

explore

Author: WynnD (outside contributor, GitHub association NONE; Discord oystersmiles) Motivation: A gateway such as llama-swap cannot show a request's prompt and decode speed from server-wide /metrics, and timing the HTTP round trip mixes in queueing and client transfer. The PR adds vLLM-style per-request timing to the response body so such gateways read Flare responses unchanged. Scale: +302 / −9 lines in 11 files Proposal:

Full report · Notes

Value Proposition

PR #553 — Add vLLM-compatible per-request metrics

Verdict: Not worth it — decline as a separate feature, and redirect the vLLM shape into the runtime-sourced timing path (#552) that the same author already has open.

The change is small, opt-in, and mostly competently plumbed, but it lands the timing in the wrong layer (so one of its six fields can never be non-null), duplicates instrumentation the project already ships and is already landing in #548/#552, adds a second parallel timing mechanism plus a new flag/config-key triplet against the charter's "stay focused, don't pile on switches" rule, claims a wire-compatible field whose semantics it inverts, and — if merged alongside #552 — actively degrades the exact gateway numbers it exists to produce. Its own contribution to users would be a metrics object that a vLLM-shaped consumer can't find in the default streaming case and that reports reasoning time as content time.


What it actually does

helios/src/server/http.rs:122-194 adds RequestTiming (HTTP admission, first/last output token, first content, seen/committed token counts). http.rs:479 builds it per request; http.rs:562-573 ticks it on GenerationEvent::Token/LogprobToken; http.rs:614 adds the committed count on Finished; http.rs:660-672/686-688 attach timing.value() to the streaming finish/usage chunk or the non-streaming body. Gated by state.per_request_metrics && matches!(protocol, Chat | Completions) (http.rs:458). Flag/config plumbing spans flare-cli/src/cli.rs (Run, OrbitRun, OrbitPush), flare-cli/src/main.rs:355, flare/src/configuration.rs:31-34,136-138, flare/src/settings.rs, flare/src/controller.rs:2563, helios/src/server.rs:133,176, helios/src/server/config.rs:354-360; docs in docs/api.md:882-903, docs/cli-design.md:738,1319-1320. 11 files, ~+300/−10.


Charter comparison

"Solve the right problem in the right place" — fails. The HTTP layer is the wrong boundary, and the PR concedes it: queue_time_ms is a hard-coded Value::Null (http.rs:189, documented at docs/api.md:896), and tokens_per_second is measured from HTTP admission, so it folds HTTP wait, queue, and prefill into what vLLM documents as generation speed. The runtime already holds those instants — runtime.rs:899 (arrival_ns), runtime.rs:920-922 (enqueue_ns), the committed-token stamps #548 adds — and #552 renders from them. Six fields, one of which is structurally always null, is a design that shipped the wrong layer's limits to the client.

"What gets merged" — no authorization. Charter: PRs that address a maintainer request, a roadmap item, a reproducible bug, a measured perf/memory issue, or bad docs. This has none. The observability ask (#536) is closed by #548; the gap report #551 is the author's own; and "vLLM's field names / gateways already read it" is competitor parity, which the earlier #548 review already ruled out as authorization. Per-request billing/SLA is also explicitly outside the vision ("not trying to be a general-purpose production server").

"Stay focused / no random switches" — fails. A third --enable-* boolean with a matching [server] key, wired through three CLI structs, to run a second timing mechanism beside latency.rs's FirstResponseSamples (latency.rs:99-112) and the RequestTimes arriving with #548. The flag is also single-polarity (main.rs:355-356 ORs it in), so a config-file true cannot be turned off from the command line — unlike the project's existing --history-drafts/--no-history-drafts and --mtp-adaptive-verification/--no-… pairs (cli.rs:980-1021).

Honest pluses: off by default; wire format, runtime, and prepared core untouched when off; Bootstrap rejects a non-boolean (config.rs:357-361); both docs updated; independent of #548/#549 as claimed; tests exist for the flag and settings round-trip.

Cost: the CPU cost is genuinely trivial (one Instant::now() per output token — a vDSO read), so performance is not the objection. The cost is conceptual: one more flag, one more config key, one more object with vLLM's name but not vLLM's meaning, and 6 fields of divergence for docs/api.md to keep true.


Concrete defects

  1. The "no cost when off" claim is false. RequestTiming::new is built unconditionally (http.rs:479) and timing.token() runs outside any per_request_metrics check (http.rs:562-573), so every request takes a clock read per output token. PR body: "none while it is off"; docs/api.md:900-903: "disabling it reads no clock for timing". Both wrong, and trivially fixable, which suggests the claim was never tested.

  2. Any request with stop strings gets an all-null object. When prompt.stop_strings is non-empty the runtime takes the TextStops branch and emits GenerationEvent::Protocol (runtime.rs:446-458, built at runtime.rs:1528-1536), which http.rs:574-576 handles without timing.token(). first_token/last_token therefore stay None and time_to_first_token_ms, generation_time_ms, mean_itl_ms, tokens_per_second, and content-TTFT are all null — the option silently returns a useless object for a very common request shape. No test covers it.

  3. time_to_first_content_token_ms inverts vLLM's semantics. The implementation feeds it latency::stream_text (http.rs:504,663 → latency.rs:116-142), which matches delta.reasoning_content, delta.reasoning, and thinking. vLLM's spec (docs.vllm.ai/en/latest/features/per_request_metrics) says this field excludes reasoning and tool-call output, and exists precisely so a gateway can see "started emitting" (108 ms) separate from "started answering" (268 ms). Here it collapses to TTFT on every thinking model — which is what the charter actually targets (DeepSeek, Qwen3-class, Kimi; docs/api.md:826-841). On the validation run the two values are 473.78 and 473.79 ms: the field carries no information.

  4. n > 1 is not suppressed. vLLM returns metrics: null for n > 1 and for multi-prompt Completions, because one sequence's timing cannot describe the response. docs/api.md:900-901 here says "one object describes the whole response", and because timing.token() fires for every choice's tokens, first/last are the outermost across choices while mean_itl_ms divides the whole span by seen_tokens - 1 (http.rs:171-176) — overstating per-token speed by roughly n×. A wire-compatible field that means something different is worse than no field.

  5. Placement varies, and the description is wrong about it. frames[..done].last_mut() (http.rs:667-670) targets whatever precedes the [DONE] frame, and encode.rs:647-660 orders the usage chunk before [DONE]. So with stream_options.include_usage (vLLM's documented requirement for streaming metrics) the metrics ride the usage chunk — but without it, they ride the finish_reason chunk, where vLLM's documented consumers do not look. PR body says "the chunk that reports finish_reason"; the code does not, once usage is enabled.

  6. Mixed denominators. mean_itl_ms divides by seen_tokens (only tokens delivered as Token events) while tokens_per_second divides committed_tokens — which includes EOS and tokens withheld by text stops (docs/api.md:319). The two rates disagree by exactly the withheld count, and nothing documents it.

  7. Test coverage is thin for the surface. Two helios HTTP tests (phase_tests.rs:4475,4520), one flare settings test, one CLI test. Nothing for Completions, n>1, batched prompts, include_usage streaming, the absence on Messages/Responses, string stops (defect 2), max_tokens: 0, or the off-state clock read (defect 1).


Simpler ways to the same end

Both are smaller than adding a second mechanism.


The decisive harm: merging this with #552 breaks the gateway

llama-swap v250 internal/server/metrics.go buildMetrics applies timings first, then lets metrics overwrite it: promptPerSecond = (inputTokens − cached)/time_to_first_token_ms, tokensPerSecond = 1000/mean_itl_ms. With both objects in one body, #553's HTTP-layer numbers win, and because #552's prompt_n is already prompt-minus-cache, cache_n is subtracted twice — a fully cached row reports a negative prompt rate. That is precisely the limitation #553's own evidence section describes; merging both guarantees it. Merging the pair is strictly worse for the stated consumer than merging #552 alone.


What I would ask for instead

Close this PR as a separate flag. If maintainers want the vLLM metrics shape at all (legitimate — third-party gateways read it), fold it into whichever single timing mechanism is chosen, sourced from the runtime, and then: drop the flag and the [server] key (or at most reuse one existing switch); make it flagless-or-per-request so nothing doubles; exclude reasoning from time_to_first_content_token_ms; suppress or null the object for n > 1 and multi-prompt; fix the Protocol/text-stop path; and remove the unconditional Instant::now(). queue_time_ms should then carry the real admission-to-first-scheduled-step interval rather than a constant null.

Nothing here disputes the author's evidence discipline — the description follows the charter's four-part form, states its own limitation, and marks what wasn't run. The disagreement is about layer and scope, not effort.

Full report · Notes Decide Value: no (62%): It is low value or does not align with the project charter.

screen malicious

Screen Result: All Clear

Evidence: Screened every agent-reachable surface of PR #553 ("Add vLLM-compatible per-request metrics", author WynnD, base main, head d6d7c7f, 11 files +303/−9, no CI checks, no reviews): the full description, all 3 comments (author + flare-autobot case file and "Review Stopped" notice), and the complete diff — helios/src/server/http.rs (+114/−7), helios/src/server.rs, helios/src/server/config.rs, helios/src/server/runtime/phase_tests.rs (+105/−1), flare/src/{configuration,controller,settings}.rs, flare-cli/src/{cli,main}.rs, docs/api.md, docs/cli-design.md — plus the four sibling items from the same author (#548, #549, #551, #552).

Nothing targeted at an agent was found: no "ignore previous instructions", system-prompt or role manipulation, no hidden/zero-width unicode, no base64 blobs, no requests to run commands, fetch URLs, exfiltrate data, or relax review rules. The diff is ordinary opt-in plumbing — a bool flag threaded flare-cli → flare settings/controller → helios ServerConfig (bootstrap rejects non-boolean values) — plus a RequestTiming struct rendered as a vLLM-named metrics JSON object, two new tokio tests, and doc updates. No network calls, process spawns, or credential/file access are added; the one reused helper, super::latency::stream_text (helios/src/server/latency.rs:116), already exists on main.

The only agent-adjacent text is normal repository workflow: WynnD's "@flare-autobot review the pushed changes", the project's own bot-trigger convention (with a documented #autobot:ignore opt-out), and the bot's automated replies. Neither constitutes an instruction to a reviewing agent from untrusted content.

Two non-security observations for human reviewers, recorded so they are not lost: (1) the stream-side metrics insertion at helios/src/server/http.rs:667-671 attaches the object to frames[..done].last_mut(), which need not be the finish_reason chunk a gateway parses if usage/sentinel frames follow, and the test only asserts a "metrics" line exists; (2) the live validation numbers come, by the description's own admission, from a fork commit (5ffe4d54) carrying an unpublished local timings object plus #548/#549, not from main.

Full report · Notes decide malicious: all_clear (100%): No malicious content found

explore

Author: WynnD (outside contributor, GitHub association NONE, no merged work; Discord oystersmiles) Motivation: /metrics only reports server-wide averages, so a fronting gateway (llama-swap) cannot show one request's timing; this PR lets an operator switch on a per-request metrics object in OpenAI Chat/Completions responses. Scale: +303 / −9 in 11 files (head d6d7c7f; was +302/−9 at fd5c67e) Proposal:

Full report · Notes

Value Proposition

PR #553 — Add vLLM-compatible per-request metrics

Verdict: Not worth it as it stands. Close this as a separate flag. The vLLM metrics shape itself is legitimate (third-party gateways read it), but the object belongs on the runtime's instants inside whatever single timing mechanism the project chooses — the same author's #552, stacked on #548 — not on a new opt-in flag in the HTTP layer.

I read the charter, the full diff (11 files, ~+300/−10), vLLM's per-request-metrics spec, the helios runtime/encode/latency paths, #536/#548/#551/#552, and llama-swap v250's buildMetrics. Everything below is re-verified at head d6d7c7f9; there are no new commits since the previous review.


What it adds

helios/src/server/http.rs:122-194 adds RequestTiming (HTTP admission, first/last output token, first content, seen/committed token counts). http.rs:479 builds it; http.rs:562-573 ticks it on Token/LogprobToken; http.rs:614 adds the committed count on Finished; http.rs:660-672 and :686-688 attach timing.value() to the last frame before [DONE], or to the non-streaming body. Gated by state.per_request_metrics && matches!(protocol, Chat | Completions) (http.rs:458-459). Plumbing spans flare-cli/src/cli.rs:624-626,697-699,1519-1522, flare-cli/src/main.rs:355-356, flare/src/configuration.rs:31-34,136-138, flare/src/settings.rs:32,159,284-297, flare/src/controller.rs:2563, helios/src/server.rs:131-133,150,176,335, helios/src/server/config.rs:357-361; docs at docs/api.md:882-903, docs/cli-design.md:738,1319-1320.


Against the charter

"Solve the right problem in the right place" — fails. The PR concedes the HTTP boundary is wrong: queue_time_ms is a hard-coded Value::Null (http.rs:189), documented as such (docs/api.md:896), so one of six fields can never hold a value. tokens_per_second runs from HTTP admission (http.rs:181-185), folding transfer wait, scheduler queue, and prefill into what vLLM defines as generation throughput. The correct instants already exist in the runtime — runtime.rs:899 (arrival_ns), :920-922 (enqueue_ns), plus the committed-token stamps #548 adds — which is where #552 renders from.

"What gets merged" — no authorization. The charter accepts maintainer requests, roadmap items, reproducible bugs, measured perf/memory issues, or bad docs. This has none: the observability ask #536 is closed by #548; #551 is the author's own gap report written for this work; "vLLM does it / gateways read it" is competitor parity, which docs/core-design.md:210-219 explicitly disclaims ("Flare does not aim for vLLM's feature matrix") and which the earlier #548 review already ruled out. Per-request billing/SLA also sits outside the vision ("not trying to be a general-purpose production server").

"Stay focused / no random switches" — fails. A third enable-* boolean with a matching [server] key, threaded through Run, OrbitRun, and OrbitPush, to run a second timing mechanism beside latency.rs:99-112 FirstResponseSamples and the RequestTimes arriving with #548. It is single-polarity (main.rs:355-356 ORs CLI and config), so [server] per_request_metrics = true cannot be disabled from the command line — unlike the project's --history-drafts/--no-history-drafts and --mtp-adaptive-verification/--no-… pairs (cli.rs:974-1021).

Honest pluses: off by default; wire format, runtime, and prepared core untouched when off; Bootstrap rejects a non-boolean (config.rs:357-361); both docs updated; independent of #548/#549; and the description follows the charter's four-part form, states its own limitation, and marks what was not run.

Cost: the CPU cost is trivial (one Instant::now() per output token, a vDSO read). The cost is conceptual: one more flag, one more config key, one more object carrying vLLM's names with different meanings, and six fields of divergence for docs/api.md to keep true.


Concrete defects (re-verified)

  1. "No cost when off" is false. RequestTiming::new is unconditional (http.rs:479) and timing.token() runs outside any per_request_metrics check (http.rs:562-573), so every request takes a clock read per output token. PR body: "none while it is off"; docs/api.md:900-903: "disabling it reads no clock for timing". Both wrong, both one if from correct — the claim looks untested.
  2. Any request with stop strings gets an all-null object. With prompt.stop_strings non-empty the runtime emits GenerationEvent::Protocol instead of Token — both at runtime.rs:446-458 and at runtime.rs:1961-1971 (TextStops::finish). http.rs:574-576 handles Protocol without timing.token(), so TTFT, generation_time_ms, mean_itl_ms, tokens_per_second and content-TTFT are all null for a very common request shape. No test.
  3. time_to_first_content_token_ms inverts vLLM's semantics. Fed by latency::stream_text (http.rs:502-506,663 → latency.rs:116-142), which matches delta.reasoning_content, delta.reasoning, thinking. vLLM's spec says this field excludes reasoning and tool-call output so a gateway can separate "started emitting" (108.2 ms) from "started answering" (268.2 ms). Here it collapses to TTFT on every thinking model — the models this project targets. The author's own validation run reports 473.78 and 473.79 ms.
  4. n > 1 is not suppressed. Reachable on Completions (decode.rs:742-755). vLLM nulls the object for n > 1 and multi-prompt; here docs/api.md:900-901 promises one object for the whole response, and timing.token() fires for every choice's tokens, so first/last are the outermost across choices while mean_itl_ms divides that span by seen_tokens - 1 (http.rs:171-176) — overstating per-token speed ~n×.
  5. Placement contradicts both the description and vLLM. frames[..done].last_mut() (http.rs:667-670) targets whatever precedes [DONE], and encode.rs:647-660 pushes the usage chunk first — so with stream_options.include_usage (vLLM's documented requirement) the object rides the usage chunk; without it, the finish_reason chunk, where vLLM consumers do not look. The PR body says the finish_reason chunk; the code does not, once usage is enabled.
  6. Mixed denominators. mean_itl_ms divides seen_tokens (only Token events) while tokens_per_second divides committed_tokens, which includes EOS and tokens withheld by text stops (docs/api.md:319). Undocumented divergence.
  7. Thin coverage. Two helios HTTP tests (phase_tests.rs:4475-4552), one flare settings test, one CLI test. Nothing for Completions, n > 1, multi-prompt, include_usage streams, absence on Messages/Responses, string stops (defect 2), max_tokens: 0, or the off-state clock read (defect 1).

Simpler ways to the same end


The decisive harm: merging this with #552 degrades the stated consumer

llama-swap v250 internal/server/metrics.go buildMetrics applies timings first, then lets metrics overwrite it: promptPerSecond = (inputTokens − cached)/time_to_first_token_ms, tokensPerSecond = 1000/mean_itl_ms. With both objects in one body this PR's HTTP-layer numbers win, and because #552's prompt_n is already prompt-minus-cache, cache_n is subtracted twice — a fully cached row reports a negative prompt rate. That is exactly the limitation this PR's own evidence section admits; merging both guarantees it. Merging the pair is strictly worse for the gateway than merging #552 alone.


What I would ask for instead

Close this PR as a separate flag. If maintainers want the vLLM metrics shape for third-party gateways, fold it into the single runtime-sourced timing mechanism and then: drop the flag and the [server] key; exclude reasoning from time_to_first_content_token_ms; suppress or null the object for n > 1 and multi-prompt; fix the Protocol/text-stop path; remove the unconditional Instant::now(); and make queue_time_ms the real admission-to-first-scheduled-step interval rather than a constant null.

Nothing here disputes the author's evidence discipline — the description follows the charter's four-part form, states its own limitation, and marks what was not run. The disagreement is about layer and scope, not effort, and the author's own #552 is the better vehicle for the same goal. That both my earlier assessment (note #5) and this re-verification (notes #6, #7) reach the same verdict on unchanged code is itself the finding: no further round is needed.

Full report · Notes Decide Value: no (100%): It is low value or does not align with the project charter. Bypass Low Value Review: No answer in time.

This PR was identified as low value for the following reason.

It is low value or does not align with the project charter. Decision Summary

The auto-reviewer was stopped, but can be re-started manually.

Click "Approve" to override this decision and continue the code review Bypass Low Value Review: No answer in time.

This PR was identified as low value for the following reason.

It is low value or does not align with the project charter. Decision Summary

The auto-reviewer was stopped, but can be re-started manually.

Click "Approve" to override this decision and continue the code review