fix: trailing white spaces

This commit is contained in:
Timothy
2026-04-02 16:43:23 -07:00
parent 71a71beca7
commit e0cd16b92b
2 changed files with 14 additions and 0 deletions
+7
View File
@@ -59,6 +59,13 @@ class ActiveNodeClientIO(NodeClientIO):
self._input_result: str | None = None
async def emit_output(self, content: str, is_final: bool = False) -> None:
# Strip leading whitespace from first output chunk to avoid leading spaces
# (some LLMs like Kimi output leading whitespace before text)
if not self._output_snapshot and content:
content = content.lstrip()
if not content: # Content was all whitespace
return
self._output_snapshot += content
await self._output_queue.put(content)
+7
View File
@@ -3532,6 +3532,13 @@ class EventLoopNode(NodeProtocol):
iteration: int | None = None,
inner_turn: int = 0,
) -> None:
# Strip leading whitespace from first output chunk for client_facing nodes
# (some LLMs like Kimi output leading whitespace before text)
if ctx.node_spec.client_facing and not snapshot and content:
content = content.lstrip()
if not content: # Content was all whitespace
return
return await publish_text_delta(
event_bus=self._event_bus,
stream_id=stream_id,