diff --git a/Cargo.lock b/Cargo.lock index 5535df50..96644b93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2492,7 +2492,7 @@ dependencies = [ [[package]] name = "tw-api" -version = "0.53.0" +version = "0.54.0" dependencies = [ "serde", "serde_json", @@ -2502,7 +2502,7 @@ dependencies = [ [[package]] name = "tw-breaker" -version = "0.53.0" +version = "0.54.0" dependencies = [ "serde", "serde_json", @@ -2510,7 +2510,7 @@ dependencies = [ [[package]] name = "tw-config" -version = "0.53.0" +version = "0.54.0" dependencies = [ "blake3", "libc", @@ -2534,7 +2534,7 @@ dependencies = [ [[package]] name = "tw-control" -version = "0.53.0" +version = "0.54.0" dependencies = [ "axum", "base64", @@ -2573,7 +2573,7 @@ dependencies = [ [[package]] name = "tw-dialect" -version = "0.53.0" +version = "0.54.0" dependencies = [ "serde", "serde_json", @@ -2581,7 +2581,7 @@ dependencies = [ [[package]] name = "tw-engine" -version = "0.53.0" +version = "0.54.0" dependencies = [ "serde", "serde_json", @@ -2594,7 +2594,7 @@ dependencies = [ [[package]] name = "tw-gateway" -version = "0.53.0" +version = "0.54.0" dependencies = [ "arc-swap", "async-stream", @@ -2639,7 +2639,7 @@ dependencies = [ [[package]] name = "tw-guard" -version = "0.53.0" +version = "0.54.0" dependencies = [ "base64", "regex", @@ -2652,7 +2652,7 @@ dependencies = [ [[package]] name = "tw-link" -version = "0.53.0" +version = "0.54.0" dependencies = [ "serde", "serde_json", @@ -2666,7 +2666,7 @@ dependencies = [ [[package]] name = "tw-observe" -version = "0.53.0" +version = "0.54.0" dependencies = [ "tokio", "tracing", @@ -2675,7 +2675,7 @@ dependencies = [ [[package]] name = "tw-pricing" -version = "0.53.0" +version = "0.54.0" dependencies = [ "arc-swap", "flate2", @@ -2688,14 +2688,14 @@ dependencies = [ [[package]] name = "tw-secret" -version = "0.53.0" +version = "0.54.0" dependencies = [ "thiserror", ] [[package]] name = "tw-store" -version = "0.53.0" +version = "0.54.0" dependencies = [ "bytes", "rusqlite", @@ -2712,7 +2712,7 @@ dependencies = [ [[package]] name = "tw-types" -version = "0.53.0" +version = "0.54.0" dependencies = [ "serde", "serde_json", @@ -2721,7 +2721,7 @@ dependencies = [ [[package]] name = "tw-watch" -version = "0.53.0" +version = "0.54.0" dependencies = [ "notify", "tempfile", @@ -2731,7 +2731,7 @@ dependencies = [ [[package]] name = "tw-yaml" -version = "0.53.0" +version = "0.54.0" dependencies = [ "saphyr-parser", "serde_yaml_ng", @@ -2741,7 +2741,7 @@ dependencies = [ [[package]] name = "twcore" -version = "0.53.0" +version = "0.54.0" dependencies = [ "anyhow", "axum", diff --git a/Cargo.toml b/Cargo.toml index 616d931b..e395cc5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ categories = ["network-programming", "web-programming::http-server"] # 二进制走 CalVer,crate 走 SemVer —— 两者是两回事,卖给不同的人。 # 这里是 crate 的版本。 -version = "0.53.0" +version = "0.54.0" [workspace.dependencies] # ── 内部 crate ─────────────────────────────────────────── diff --git a/release-notes/0.54.0.md b/release-notes/0.54.0.md new file mode 100644 index 00000000..4ca5c4a2 --- /dev/null +++ b/release-notes/0.54.0.md @@ -0,0 +1,18 @@ +This release records when each response's first token arrives and how fast the response is generated, and corrects the generation rate that `GET /live` reports. + +**Upgrade notes** + +- The control-plane protocol version (`CONTROL_API_VERSION`) is now 27. ThinkWatch Lite connects only to a core with the same protocol version, and has to regenerate its protocol types from this release to use it. ThinkWatch Lite 2026.9.21 includes 0.53.0 (protocol 26) and does not connect to 0.54.0: a server used with it stays on 0.53.0 until the app is updated to a release that includes 0.54.0. `sudo twcore upgrade --version 0.53.0 --restart` switches a server back to 0.53.0. +- The format of the request history changed (request store schema 22, from 21). On its first start, 0.54.0 replaces the request history and the stored request and response bodies of an earlier version with an empty store; the configuration is kept. Switching back to an earlier version empties it again. +- Changed in the protocol: the new event `RequestFirstToken { id, ttft_ms }`, `RequestFinished.tokens_per_sec`, `HistoryRow.ttft_ms` and `HistoryRow.tokens_per_sec`, and the new endpoints `GET /token-rate` and `GET /token-rate/provider`, which return `TokenRateView { model, p50, samples }`. `GET /latency` and `GET /latency/provider` now report the time to the first token. No message code changed. + +**First token.** The headers of a streamed response usually come back as soon as the upstream receives the request. The upstream then queues the request and reads the prompt before it produces anything, and the time a user waits is the time to the first token, not to the headers. The gateway now reads each successful streamed response in the upstream's format and reports the moment the first text, reasoning or tool call arrives; opening frames such as `message_start` and `response.created` do not count. A response that is not streamed arrives whole and has no first token. `GET /latency` and `GET /latency/provider` now give percentiles of this time, so responses that are not streamed are left out of them. `url-test` groups still pick the upstream with the fastest response headers. + +**Generation speed.** Each finished streamed request has a generation speed: the output produced after the first token, divided by the time from the first token to the end. +- When the model reasoned before the first token without streaming its reasoning, those reasoning tokens were generated outside that time. They are subtracted when the upstream reports how many there were, as OpenAI and Gemini do. When it does not, as with Anthropic, the request has no speed rather than one several times too high. +- Reasoning that is streamed as it happens is counted. +- Responses that are not streamed, cancelled and failed requests, and generations shorter than half a second have no speed. + +`GET /token-rate` and `GET /token-rate/provider` give the median speed by model and by upstream, with the number of samples. + +**The live rate.** `GET /live` used to divide each request's output by the time after its response headers. A response that is not streamed gets its headers only when generation is done, so that time was a few milliseconds, and one such request could push the rate to tens of thousands of tokens per second. The rate now combines the speeds of the requests that have one, weighted by their generation time.