odysseus/tests/test_streamed_tool_markup.py
2026-09-11 06:04:19 +00:00

29 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from src.agent_loop import (
_streamed_tool_markup_complete,
_streamed_tool_markup_starts,
_strip_incomplete_tool_markup_tail,
)
from src.tool_parsing import strip_tool_blocks
def test_dsml_tool_markup_is_complete_only_after_closing_tag():
start = "<||DSML||tool_calls><||DSML||invoke name=\"host_shell\">"
assert not _streamed_tool_markup_complete(start)
assert _streamed_tool_markup_complete(start + "</||DSML||invoke>")
def test_dsml_tool_markup_strips_to_empty_visible_text():
markup = (
"<||DSML||tool_calls>"
"<||DSML||invoke name=\"host_shell\">"
"<||DSML||parameter name=\"command\" string=\"true\">pwd"
"</||DSML||parameter>"
"</||DSML||invoke>"
"</||DSML||tool_calls>"
)
assert strip_tool_blocks(markup, skip_fenced=True) == ""
def test_chunk_split_tool_call_prefix_is_buffered_and_not_persisted():
assert _streamed_tool_markup_starts('I will search<tool_cal')
assert _strip_incomplete_tool_markup_tail('I will search<tool_cal') == 'I will search'