Skip to content

Agent file diffs and edits mishandle Windows (CRLF) line endings since #4864 #4871

Open

Description

@github-actions

On any Windows-style (CRLF) file, the agent's file-diff preview now shows every line as deleted and re-added, so a one-line change looks like a full rewrite and the added/removed counts are wrong. Edits have a related gap: when the text to replace matches as-is, the replacement is spliced in with the model's LF endings, leaving a CRLF file with mixed line endings. This came in with #4864, which started reading files with their original endings but only converts the model's text on one edit path.

🔍 Evidence and locations

Severity: 🟠 medium Lens: correctness
Auto-fixable: yes — apply bug to let auto-fix open the PR

Where Evidence
src/gaia/agents/tools/file_io_tools.py · generate_diff Reads the original with open(..., newline="") (CRLF kept), then diffs original_content.splitlines(keepends=True) against the model's LF new_content. Every line differs. Before c5c9141 it read with universal newlines, so both sides were LF. A diff isn't a write round trip, so reading exactly gains nothing here.
src/gaia/agents/tools/file_edit.py · apply_unique_replacement new_content = _retarget_newlines(new_content, current_content) only runs inside the if not offsets: retry branch. When old_content matches directly (e.g. a single-line old_content), a multi-line LF new_content is inserted unchanged into a CRLF file.

Not acting on this? Close it with the audit-wontfix label and the audit will never re-file it. Applying bug instead hands it to the existing auto-fix job.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    weekly-auditProactive weekly Claude audit finding

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions