Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/tau_coding/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ async def execute(

mime_type = _detect_supported_image_mime_type(path)
if mime_type is not None:
data = path.read_bytes()
data = await asyncio.to_thread(path.read_bytes)
return AgentToolResult(
tool_call_id="",
name="read",
Expand All @@ -168,7 +168,7 @@ async def execute(
},
)

text = path.read_text(encoding="utf-8")
text = await asyncio.to_thread(path.read_text, encoding="utf-8")
all_lines = text.split("\n")
start_line = 0 if offset is None or offset == 0 else offset - 1
if start_line >= len(all_lines):
Expand Down Expand Up @@ -282,7 +282,7 @@ async def execute(

async with _file_lock(path):
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(content, encoding="utf-8")
await asyncio.to_thread(path.write_text, content, encoding="utf-8")

return AgentToolResult(
tool_call_id="",
Expand Down Expand Up @@ -352,15 +352,15 @@ async def execute(
raise ToolInputError(f"Could not edit file: {path}. Path is a directory.")

async with _file_lock(path):
raw_content = path.read_text(encoding="utf-8")
raw_content = await asyncio.to_thread(path.read_text, encoding="utf-8")
bom, content = _strip_bom(raw_content)
original_ending = detect_line_ending(content)
normalized = normalize_to_lf(content)
base_content, new_content = apply_edits_to_normalized_content(
normalized, edits, str(path)
)
final_content = bom + restore_line_endings(new_content, original_ending)
path.write_text(final_content, encoding="utf-8")
await asyncio.to_thread(path.write_text, final_content, encoding="utf-8")

diff_text, first_changed_line = generate_diff_string(base_content, new_content)
patch = generate_unified_patch(str(path), base_content, new_content)
Expand Down