From d6f2c0f49efc566c410ef505cffd007690c710d8 Mon Sep 17 00:00:00 2001 From: Kayvan Zahiri Date: Thu, 13 Aug 2026 14:46:11 -0700 Subject: [PATCH] server : only enable token timestamps when the response needs them max_len defaults to 60 in the server, and that only takes effect on the token timestamps path. Until v1.8.3 token timestamps were limited to verbose_json, so the default never reached other formats. #3679 removed that condition, which left every response wrapped at 60 characters, on a token boundary rather than a word one. Resolve the default after the other parameters and enable it only for verbose_json, or when max_len or split_on_word was asked for. Clients passing max_len with any format still get wrapping. --- examples/server/server.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/server/server.cpp b/examples/server/server.cpp index b87ef2737..f6ab80aa9 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -554,8 +554,6 @@ void get_req_parameters(const Request & req, whisper_params & params) if (req.has_file("token_timestamps")) { params.token_timestamps = parse_str_to_bool(req.get_file_value("token_timestamps").content); - } else { - params.token_timestamps = !params.no_timestamps; } if (req.has_file("language")) { @@ -625,6 +623,17 @@ void get_req_parameters(const Request & req, whisper_params & params) { params.no_language_probabilities = parse_str_to_bool(req.get_file_value("no_language_probabilities").content); } + + // resolved last, since it depends on response_format / max_len / split_on_word above. + // token timestamps also drive the max_len segment wrapping in whisper_full(), so turning + // them on unconditionally makes the max_len fallback below wrap every response at 60 + // characters - on a token boundary, i.e. mid-word. Only default them on when the response + // actually carries per-token data (verbose_json) or wrapping was asked for. + if (!req.has_file("token_timestamps")) + { + params.token_timestamps = !params.no_timestamps && + (params.response_format == vjson_format || params.max_len > 0 || params.split_on_word); + } } } // namespace