[BUG] Python edit_file rewrites every CRLF line ending in the file it edits; the Go tool keeps them

Đang mở
#3,743 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@BahaaMattar đang làm issue này rồi.

Từ ngày 19/11/2026.

  • #3744 của @BahaaMattar — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
go, python
Lĩnh vực
tooling

Hướng nghiên cứu

Read python/packages/kagent-tools/src/kagent/tools/shell.py and inspect edit_file_content's file read and write behavior. Add or locate a regression test using CRLF bytes, then verify a one-line edit preserves the other line endings; the issue's linked pull request #3744 shows work is already underway.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Bug Description

edit_file_content (python/packages/kagent-tools/src/kagent/tools/shell.py, used by the ADK and OpenAI Agents runtimes) reads the file with universal newlines and writes it back with write_text, so a one-line edit turns every \r\n in the file into \n. The Go runtime's edit_file replaces bytes and leaves the rest of the file alone.

Steps To Reproduce

(default branch d5c04c17, no cluster needed)

f.write_bytes(b"$a = 1\r\n$b = 2\r\n$c = 3\r\n")
edit_file_content(f, "$b = 2", "$b = 20")
f.read_bytes()
Expected Behavior

b'$a = 1\r\n$b = 20\r\n$c = 3\r\n' (what the Go tool produces for the same edit).

Actual Behavior

b'$a = 1\n$b = 20\n$c = 3\n' for a one-line edit. All three line endings changed. Through the real EditFileTool the output is the same.

Impact/Severity

Minor inconvenience (silent change of every line in the file: noisy diffs, breaks files that must stay CRLF such as .bat or .ps1).

Ngôn ngữ chính
Go
Star
4.5k
Fork
937
Merge trung bình
1 ngày 10 giờ
Pull request đã merge (30 ngày)
150

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của kagent-dev/kagent

Tất cả issue của kagent-dev/kagent

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.