Auto-label / auto-label (pull_request) Successful in 2s
CI Pipeline / lint (pull_request) Successful in 21s
CI Pipeline / unit-tests (pull_request) Successful in 51s
CI Pipeline / canary (pull_request) Successful in 4s
CI Pipeline / best-practices (pull_request) Successful in 2s
CI Pipeline / documentation (pull_request) Successful in 3s
CI Pipeline / required-checks (pull_request) Successful in 0s
Auto-version and Release / release (pull_request) Successful in 5s
30 lines
1010 B
Python
30 lines
1010 B
Python
"""Behavior contracts for chat and first-class tool objects."""
|
|
|
|
from rune.chat_bubble import ChatBubble
|
|
from rune.message_widgets import ToolCallWidget
|
|
|
|
|
|
def test_tool_object_keeps_protocol_data_out_of_chat_markup():
|
|
widget = ToolCallWidget(
|
|
{
|
|
"kind": "completed",
|
|
"request": {
|
|
"call_id": "call-1",
|
|
"name": "read_file",
|
|
"arguments": {"path": "[bold]/tmp/example[/bold]"},
|
|
},
|
|
"result": {"success": True, "result": "[red]literal[/red]"},
|
|
},
|
|
channel="chat",
|
|
)
|
|
|
|
assert widget.call_id == "call-1"
|
|
assert "✓ read_file" in widget._summary().plain
|
|
assert "[bold]/tmp/example[/bold]" in widget._details().plain
|
|
assert "[red]literal[/red]" in widget._details().plain
|
|
|
|
|
|
def test_chat_content_is_rendered_literally_between_tool_objects():
|
|
rendered = ChatBubble("assistant", "[bold]not markup[/bold]").render()
|
|
assert rendered.plain == "Rune\n[bold]not markup[/bold]"
|