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

Aperta
#3,743 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@BahaaMattar ci sta già lavorando.

Dal 19/11/2026.

  • #3744 di @BahaaMattar — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
go, python
Ambito
tooling

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Go
Stelle
4.5k
Fork
937
Merge medio
1g 10h
PR unite (30g)
150

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di kagent-dev/kagent

Tutte le issue di kagent-dev/kagent

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.