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

Abierto
#3,743 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@BahaaMattar ya está trabajando en esto.

Desde el 19/11/2026.

  • #3744 de @BahaaMattar — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
go, python
Área
tooling

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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).

Lenguaje dominante
Go
Estrellas
4.5k
Forks
937
Merge medio
1 d 10 h
PR fusionados (30 d)
150

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de kagent-dev/kagent

Todos los issues de kagent-dev/kagent

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.