Skip to content
Open
Show file tree
Hide file tree
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: 8 additions & 2 deletions backend/app/gateway/routers/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,15 @@ async def get_artifact(thread_id: str, path: str, request: Request, download: bo
return FileResponse(path=actual_path, filename=actual_path.name, media_type=mime_type, headers=_build_attachment_headers(actual_path.name))

if mime_type and mime_type.startswith("text/"):
return PlainTextResponse(content=actual_path.read_text(encoding="utf-8"), media_type=mime_type)
try:
return PlainTextResponse(content=actual_path.read_text(encoding="utf-8"), media_type=mime_type)
except UnicodeDecodeError:
Comment on lines 177 to +180
pass # Fall through to binary response

if is_text_file_by_content(actual_path):
return PlainTextResponse(content=actual_path.read_text(encoding="utf-8"), media_type=mime_type)
try:
return PlainTextResponse(content=actual_path.read_text(encoding="utf-8"), media_type=mime_type)
except UnicodeDecodeError:
pass # Fall through to binary response
Comment on lines +178 to +187
Comment on lines 177 to +187

return Response(content=actual_path.read_bytes(), media_type=mime_type, headers={"Content-Disposition": _build_content_disposition("inline", actual_path.name)})
3 changes: 3 additions & 0 deletions backend/packages/harness/deerflow/sandbox/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,9 @@ def str_replace_tool(
if replace_all:
content = content.replace(old_str, new_str)
else:
count = content.count(old_str)
if count > 1:
return f"Error: The string to replace appears {count} times in {requested_path}. Use replace_all=True to replace all occurrences, or provide a more specific string that appears exactly once."
Comment on lines +1572 to +1574
content = content.replace(old_str, new_str, 1)
Comment on lines 1571 to 1575
sandbox.write_file(path, content)
return "OK"
Expand Down
Loading