mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 03:30:48 +08:00
fix(chat): persist/split <thinking>/<thought> blocks like stream UI
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
7ea02e66ca
commit
46ebfeb54f
3 changed files with 36 additions and 3 deletions
28
tests/test_direct_loop_reasoning_split.py
Normal file
28
tests/test_direct_loop_reasoning_split.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from oclaw.runtime.direct_loop import _split_reasoning_and_body
|
||||
|
||||
|
||||
def test_split_reasoning_extracts_thinking_tags() -> None:
|
||||
chunks, body = _split_reasoning_and_body("<thinking>\ninner\n</thinking>\nvisible")
|
||||
assert chunks == ["inner"]
|
||||
assert body == "visible"
|
||||
|
||||
|
||||
def test_split_reasoning_extracts_thought_tags() -> None:
|
||||
chunks, body = _split_reasoning_and_body("<thought>x</thought>after")
|
||||
assert chunks == ["x"]
|
||||
assert body == "after"
|
||||
|
||||
|
||||
def test_split_reasoning_explicit_when_no_tags() -> None:
|
||||
chunks, body = _split_reasoning_and_body("body only", explicit_reasoning=" rc ")
|
||||
assert chunks == ["rc"]
|
||||
assert body == "body only"
|
||||
|
||||
|
||||
def test_split_reasoning_antml_optional_prefix() -> None:
|
||||
raw = "<antml:thinking>\nZ\n</antml:thinking>\nok"
|
||||
chunks, body = _split_reasoning_and_body(raw)
|
||||
assert chunks == ["Z"]
|
||||
assert body == "ok"
|
||||
Loading…
Add table
Add a link
Reference in a new issue