From b4f21ee9f45da54980dbfd3d50f392999e9946a1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 06:52:40 +0000 Subject: [PATCH 1/3] Initial plan From 71c90e06867d873efb5033d9211e08d88780c02e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 07:00:58 +0000 Subject: [PATCH 2/3] Add test case for unicode_escape handling in anthropic-text-editor output Co-authored-by: 0xba1a <2942888+0xba1a@users.noreply.github.com> --- test/bot/test_microbot.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/bot/test_microbot.py b/test/bot/test_microbot.py index 5cbfbb0..4ea9d3d 100644 --- a/test/bot/test_microbot.py +++ b/test/bot/test_microbot.py @@ -544,6 +544,43 @@ def test_pformat_produces_readable_output(self): raw_output = command assert r'\"' not in raw_output, "Raw command should not have escaped quotes" assert '"input"' in raw_output, "Raw command should preserve double quotes" + + def test_anthropic_text_editor_unicode_escape_decoding(self): + """Test that unicode-escaped output is properly decoded. + + This unit test verifies that the unicode_escape decoding logic introduced + for anthropic-text-editor output works correctly. When the tool returns + JSON with a "content" field containing unicode-escaped strings (e.g., \\n, \\t), + the content should be decoded to actual newlines and tabs. + """ + import json + + # Simulate anthropic-text-editor returning JSON with unicode-escaped content + escaped_output = '{"content": "Line 1\\nLine 2\\nLine 3\\tTabbed"}' + + # Parse the JSON (simulating json.loads in the actual code) + output_json = json.loads(escaped_output) + + # Apply the unicode_escape decoding (the line being tested) + decoded_output = output_json["content"].encode("utf-8").decode("unicode_escape") + + # Verify the decoded output has actual newlines and tabs + assert "Line 1\nLine 2\nLine 3\tTabbed" == decoded_output, \ + "Output should contain decoded newlines and tabs" + + # Verify the escaped versions are NOT in the decoded output + assert "\\n" not in decoded_output, \ + "Decoded output should not contain escaped newlines" + assert "\\t" not in decoded_output, \ + "Decoded output should not contain escaped tabs" + + # Verify line count - should be 3 lines (split by actual newlines) + lines = decoded_output.split("\n") + assert len(lines) == 3, "Should have 3 lines after decoding" + assert lines[0] == "Line 1" + assert lines[1] == "Line 2" + assert lines[2] == "Line 3\tTabbed" # This line contains an actual tab + def test_tool_usage_instructions_appended_to_system_prompt(self): """Test that tool usage instructions are appended to the system prompt when creating LLM.""" from microbots.tools.tool import Tool From 5bc1b0dd86e2fc3c78fb6768c49f93020456b434 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 07:03:18 +0000 Subject: [PATCH 3/3] Address code review feedback: move json import to top and improve assertion order Co-authored-by: 0xba1a <2942888+0xba1a@users.noreply.github.com> --- test/bot/test_microbot.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/bot/test_microbot.py b/test/bot/test_microbot.py index 4ea9d3d..403c52e 100644 --- a/test/bot/test_microbot.py +++ b/test/bot/test_microbot.py @@ -4,6 +4,7 @@ This test will create multiple custom bots - a reading bot, a writing bot using the base class. """ +import json import os from pathlib import Path import subprocess @@ -526,7 +527,6 @@ def test_pformat_produces_readable_output(self): command = """echo '{"input": {"command": "view", "path": "/tmp/test.txt"}}' | anthropic-text-editor""" # With json.dumps (old behavior) - escapes quotes making it harder to read - import json json_output = json.dumps(command) # With pformat (new behavior) - more readable @@ -553,8 +553,6 @@ def test_anthropic_text_editor_unicode_escape_decoding(self): JSON with a "content" field containing unicode-escaped strings (e.g., \\n, \\t), the content should be decoded to actual newlines and tabs. """ - import json - # Simulate anthropic-text-editor returning JSON with unicode-escaped content escaped_output = '{"content": "Line 1\\nLine 2\\nLine 3\\tTabbed"}' @@ -565,7 +563,8 @@ def test_anthropic_text_editor_unicode_escape_decoding(self): decoded_output = output_json["content"].encode("utf-8").decode("unicode_escape") # Verify the decoded output has actual newlines and tabs - assert "Line 1\nLine 2\nLine 3\tTabbed" == decoded_output, \ + expected_output = "Line 1\nLine 2\nLine 3\tTabbed" + assert decoded_output == expected_output, \ "Output should contain decoded newlines and tabs" # Verify the escaped versions are NOT in the decoded output