fix(agent): retain skipped inline reasoning separators
This commit is contained in:
1 parent
ed8143f7d0
commit
d0a1423ccf
2 files changed
+12
-6
No files matched your search
@@ -289,9 +289,9 @@ class IncrementalThinkExtractor:
|
|||||||
if not thinking or thinking == self._emitted:
|
if not thinking or thinking == self._emitted:
|
||||||
return False
|
return False
|
||||||
new = thinking[len(self._emitted) :]
|
new = thinking[len(self._emitted) :]
|
||||||
self._emitted = thinking
|
|
||||||
if not new.strip():
|
if not new.strip():
|
||||||
return False
|
return False
|
||||||
|
self._emitted = thinking
|
||||||
await emit(new)
|
await emit(new)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,17 @@ from nanobot.bus.outbound_events import ProgressEvent
|
|||||||
from nanobot.events import AgentEvent, EventSink
|
from nanobot.events import AgentEvent, EventSink
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("chunks", [
|
@pytest.mark.parametrize("chunks, expected", [
|
||||||
["<think>first paragraph</think><thought>second paragraph</thought>"],
|
(["<think>first paragraph</think><thought>second paragraph</thought>"],
|
||||||
["<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] = []
|
events: list[AgentEvent] = []
|
||||||
|
|
||||||
async def publish(event: AgentEvent) -> None:
|
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 events
|
event.content for event in events
|
||||||
if isinstance(event, ProgressEvent) and event.reasoning_delta
|
if isinstance(event, ProgressEvent) and event.reasoning_delta
|
||||||
)
|
)
|
||||||
assert reasoning == "first paragraph\n\nsecond paragraph"
|
assert reasoning == expected
|
||||||
assert context.streamed_reasoning is True
|
assert context.streamed_reasoning is True
|
||||||
Reference in new issue
Block a user