fix: 优化Agent消息排版

This commit is contained in:
jxxghp
2026-03-24 20:21:58 +08:00
parent 3c7fdfec3c
commit 17373bc0fe
2 changed files with 5 additions and 2 deletions

View File

@@ -61,6 +61,9 @@ class StreamingHandler:
接收 LLM 流式 token积累到缓冲区。
"""
with self._lock:
# 如果存量消息结束是两个换行,则去掉新消息前面的换行,避免过多空行
if self._buffer.endswith("\n\n") and token.startswith("\n"):
token = token.lstrip("\n")
self._buffer += token
async def take(self) -> str: