From 7091c70a1e200e5093a726bc573f23cd7d2a2fce Mon Sep 17 00:00:00 2001 From: ZhangJun Date: Tue, 9 Sep 2025 04:01:55 +0800 Subject: [PATCH] open_ai: Trim newline before "data:" prefix and account for the possibility of no space after ":" (#37644) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I'am using an openai compatible model, but got nothing in agent thread panel, and Zed log has "Model generated an empty summary" line. I add one log to open_ai.rs: 图片 and got: 图片 It appear that `let line = line.strip_prefix("data: ")?;` can not handle correctly. Release Notes: - N/A --------- Co-authored-by: Ben Brandt --- crates/open_ai/src/open_ai.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/open_ai/src/open_ai.rs b/crates/open_ai/src/open_ai.rs index 279245c0b7d5a545a5d5c7725347f0b5153a4deb..fda0544be1748f3bf958cd159bc55edccdbb5c14 100644 --- a/crates/open_ai/src/open_ai.rs +++ b/crates/open_ai/src/open_ai.rs @@ -473,7 +473,7 @@ pub async fn stream_completion( .filter_map(|line| async move { match line { Ok(line) => { - let line = line.strip_prefix("data: ")?; + let line = line.strip_prefix("data: ").or_else(|| line.strip_prefix("data:"))?; if line == "[DONE]" { None } else {