Skip to content

fix: prevent edit application in ask mode (issue #5374)#5381

Open
chrislazar25 wants to merge 1 commit into
Aider-AI:mainfrom
chrislazar25:fix/issue-5374
Open

fix: prevent edit application in ask mode (issue #5374)#5381
chrislazar25 wants to merge 1 commit into
Aider-AI:mainfrom
chrislazar25:fix/issue-5374

Conversation

@chrislazar25

Copy link
Copy Markdown

Summary

Prevent file modifications in ask mode, which documents that aider "will discuss your code and answer questions about it, but never make changes."

Technical Details

Root Cause: Coder.apply_updates() in base_coder.py processes and applies LLM edit blocks regardless of edit_format. When the LLM hallucinates edit blocks in ask mode, the edits are applied to files, violating the documented behavior.

Mechanism: The call chain run_one()send_message()apply_updates()get_edits()prepare_to_edit()apply_edits() has no guard for ask mode. The fix adds an early return at the entry of apply_updates() when edit_format == "ask", short-circuiting the entire edit pipeline.

Verification

  • Confirmed adherence to CONTRIBUTING.md
  • Ran python3 -m pytest tests/basic/test_coder.py tests/basic/test_commands.py tests/basic/test_editblock.py tests/basic/test_udiff.py tests/basic/test_repo.py tests/basic/test_io.py tests/basic/test_main.py tests/basic/test_exceptions.py — 268 passed, 0 failed
  • Pre-commit hooks passed (isort, black, flake8, codespell)

Blast Radius

  • Impact: Low — ask mode only. No behavioral change for code, architect, or other edit formats.
  • Trade-offs: None. AskCoder is subclassed from Coder and inherits apply_updates(); the guard is intentionally at the shared method entry point since only AskCoder should skip edits.

Closes #5374

In ask mode, the documentation promises aider will 'never make changes.'
However, the LLM may still output edit blocks that get applied to files.
Add a guard in apply_updates() to immediately return an empty set when
edit_format is 'ask', preventing any file modifications.
@chrislazar25 chrislazar25 marked this pull request as ready for review July 1, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aider makes changes in ask mode

1 participant