[spring-ai] Streaming responses ending with CJK punctuation (。!?) are misclassified as partial and never persisted to the session
維護者通常 1 天內回覆
評估
研究方向
從 contrib/spring-ai/src/main/java/com/google/adk/models/springai/MessageConverter.java 開始,方法 isPartialResponse 只檢查 ASCII . ! ? 和換行符。該 issue 的最小重現直接呼叫 MessageConverter#toLlmResponse,傳入以 。 結尾的 ChatResponse,因此將其轉換為 contrib/spring-ai/src/test 下的單元測試,並確認它目前回傳 partial=true。完成意味著以 。!? 結尾的回應會產生 partial=false,並且新測試和模組的現有測試都通過。
由索引模型根據 Issue 內容生成。
描述
Describe the Bug
In the Spring AI bridge (contrib/spring-ai), MessageConverter#isPartialResponse
decides whether a streaming chunk is partial by checking only ASCII sentence-ending
punctuation: ., !, ?, \n. CJK terminal punctuation (。, !, ?) is not
included.
As a result, when a model's final streaming response ends with a Chinese sentence
mark (which is the normal case for Chinese users), it is classified as partial=true
and therefore never persisted to the session — the reply silently disappears from
conversation history, breaking multi-turn context and session replay.
Steps to Reproduce
- Use the official
com.google.adk.models.springai.SpringAImodel bridge with any
OpenAI-compatible model, streaming mode (RunConfigSSE). - Send a question that produces a Chinese answer, e.g.
根因是库存扣减为 0 未拦截。 - Observe the final
LlmResponse:partialistrue, and the session event store
never receives this response.
A minimal unit-level repro (calling the converter directly) is provided below.
No exception/stacktrace is produced — the failure is silent, which is what makes it
hard to notice in production.
Expected Behavior
A response ending with 。 (or ! / ?) is a complete final response in Chinese
and should be partial=false, persisted to the session like its ASCII-. counterpart.
Observed Behavior
Verified against google-adk-spring-ai:1.9.0 on our classpath:
[PROBE] chinese-ending partial = true <-- bug: final reply treated as partial
[PROBE] ascii-ending partial = false
Downstream effect: Runner-driven sessions lose the assistant's final answer for
CJK conversations; Session.events() replay shows the question without the reply.
Live streaming looks fine (partials are forwarded to the client), so the loss only
shows up in history, multi-turn follow-ups and session replay.
Environment Details
- ADK Library Version: verified on 1.9.0, and confirmed still present in
1.11.0 (latest release) and on currentmain
(contrib/spring-ai/src/main/java/com/google/adk/models/springai/MessageConverter.java#isPartialResponse) - OS: macOS (behavior is OS-independent — pure string logic)
- TS Version: N/A (Java)
Model Information
Model-independent. Observed with GLM via an OpenAI-compatible gateway; the
classification happens in MessageConverter before any model-specific handling.
Regression
N/A — the heuristic has been present since we started using the bridge (1.9.0),
and is unchanged through 1.11.0.
Additional Context
Suggested fix, from minimal to better:
- Add CJK terminal punctuation to the check:
。!?(plus…,)). - Better: don't infer completeness from punctuation at all. Text legitimately ends
without sentence-ending characters (lists, code blocks, tables). Partial-ness
could be derived from chunk position / stream state instead of the last character.
This affects every CJK-language user of the official SpringAI bridge — and because
partials are still forwarded live, the missing persistence only surfaces later
(history / follow-up turns), which makes it easy to misdiagnose as a session-store
problem.
Minimal Reproduction Code
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.adk.models.springai.MessageConverter;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.ai.chat.model.Generation;
import java.util.List;
MessageConverter converter = new MessageConverter(new ObjectMapper());
ChatResponse chineseEnding = new ChatResponse(List.of(new Generation(
AssistantMessage.builder().content("根因是库存扣减为 0 未拦截。").build())));
ChatResponse asciiEnding = new ChatResponse(List.of(new Generation(
AssistantMessage.builder().content("Root cause: zero-stock deduction is not blocked.").build())));
boolean chinesePartial = converter.toLlmResponse(chineseEnding, true).partial().orElse(false); // true (bug)
boolean asciiPartial = converter.toLlmResponse(asciiEnding, true).partial().orElse(false); // false
How often has this issue occurred?
Always (100%) — every Chinese final response ending with 。, which is essentially
every conversation.
- 主要語言
- Java
- 星號
- 1.7k
- 分支
- 431
- 平均合併
- 3 天 2 小時
- 30 天內合併 PR
- 46
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
google/adk-java 的其他 Issue
-
GeminiUtil placeholder user turn ("Continue output. DO NOT look at this line ...") is flagged by prompt injection filters可能已有人在做 @innoprej 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
[spring-ai] ToolConverter silently drops enum and items from tool parameter schemas可能已有人在做 @hirematha 於 3 天前認領。 未關閉needs review
難度 2/5 1-3 小時 新手友好度 76/100
google/adk-java#1609 · 2 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
[core] Client disconnects don't cancel the model stream (per-step flow is cached) — and there is no public API to cancel an in-flight run可能已有人在做 @hemasekhar-p 於 2 天前認領。 未關閉needs review
google/adk-java#1618 · 6 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
[spring-ai] Bridge drops reasoning_content (thinking) — surface it as partial events and/or persist it可能已有人在做 @hemasekhar-p 於 2 天前認領。 未關閉needs review
google/adk-java#1616 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
[FEATURE] Port bypass_multi_tools_limit for built-in search tools from adk-python可能已有人在做 @hirematha 於 3 天前認領。 未關閉needs review
難度 5/5 一週以上 新手友好度 35/100
google/adk-java#1598 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
相似的 Issue
-
waiting-for-triage
難度 1/5 1 小時以內 新手友好度 72/100
spring-cloud/spring-cloud-openfeign#1443 ·
維護者通常 1 天內回覆
-
難度 1/5 1-3 小時 新手友好度 84/100
ADORSYS-GIS/keycloak-oid4vp-plugin#221 ·
維護者通常 2 天內回覆
-
status: team-only type: dependency-upgrade
難度 2/5 1-3 小時 新手友好度 65/100
spring-projects/spring-boot#52099 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 67/100
tchiotludo/akhq#3307 · 1 個 reaction ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
objectionary/jeo-maven-plugin#1885 ·
維護者通常 4 天內回覆