Skip to content

Agent Runtime: apply.patch diff information is incorrect — consider using git ghost commits #141

Description

@wangtsiao

Describe the bug

The diff information produced by apply_patch tool is incorrect. The patch diff shown to the user does not accurately reflect the changes being applied.

Current behavior

When apply_patch makes changes to files, the resulting diff displayed in the UI is wrong — it may show incorrect line numbers, wrong context, or missing changes.

Suggested approach

Instead of the current implementation, consider using git ghost commits to generate accurate diffs:

  1. Stage the current state
  2. Apply the patch
  3. Generate a diff between the committed state and the new state
  4. Optionally clean up the ghost commit

This guarantees the diff is always accurate since it uses git's built-in diff engine.

Where to look

  • crates/core/src/tools/apply_patch.rs — current apply_patch implementation
  • The diff output at crates/core/src/tools/apply_patch.rs:911 and the completion path at line 196

Related files

  • crates/core/src/tools/apply_patch.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions