Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(agent): retain skipped inline reasoning separators
Xubin Rend0a1423ccf43
diff --git a/nanobot/utils/helpers.py b/nanobot/utils/helpers.pyindex 08e8d8d51..1573f7d6a 100644--- a/nanobot/utils/helpers.py+++ b/nanobot/utils/helpers.py@@ -289,9 +289,9 @@ class IncrementalThinkExtractor:if not thinking or thinking == self._emitted:return Falsenew = thinking[len(self._emitted) :]- self._emitted = thinkingif not new.strip():return False+ self._emitted = thinkingawait emit(new)return Truediff --git a/tests/agent/test_progress_inline_reasoning.py b/tests/agent/test_progress_inline_reasoning.pyindex a0417e37c..7a0706ad0 100644--- a/tests/agent/test_progress_inline_reasoning.py+++ b/tests/agent/test_progress_inline_reasoning.py@@ -8,11 +8,17 @@ from nanobot.bus.outbound_events import ProgressEventfrom nanobot.events import AgentEvent, EventSink[email protected]("chunks", [- ["<think>first paragraph</think><thought>second paragraph</thought>"],- ["<think>first paragraph</think>", "<thought>second paragraph</thought>"],[email protected]("chunks, expected", [+ (["<think>first paragraph</think><thought>second paragraph</thought>"],+ "first paragraph\n\nsecond paragraph"),+ (["<think>first paragraph</think>", "<thought>second paragraph</thought>"],+ "first paragraph\n\nsecond paragraph"),+ (["<think>first paragraph</think><think></think><thought>second paragraph</thought>"],+ "first paragraph\n\n\n\nsecond paragraph"),+ (["<think>first paragraph</think>", "<think></think>", "<thought>second paragraph</thought>"],+ "first paragraph\n\n\n\nsecond paragraph"),])-async def test_inline_reasoning_preserves_paragraph_separators(chunks: list[str]) -> None:+async def test_inline_reasoning_preserves_paragraph_separators(chunks: list[str], expected: str) -> None:events: list[AgentEvent] = []async def publish(event: AgentEvent) -> None:@@ -28,5 +34,5 @@ async def test_inline_reasoning_preserves_paragraph_separators(chunks: list[str]event.content for event in eventsif isinstance(event, ProgressEvent) and event.reasoning_delta)- assert reasoning == "first paragraph\n\nsecond paragraph"+ assert reasoning == expectedassert context.streamed_reasoning is True