fix: prevent edit application in ask mode (issue #5374)#5381
Open
chrislazar25 wants to merge 1 commit into
Open
fix: prevent edit application in ask mode (issue #5374)#5381chrislazar25 wants to merge 1 commit into
chrislazar25 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prevent file modifications in
askmode, which documents that aider "will discuss your code and answer questions about it, but never make changes."Technical Details
Root Cause:
Coder.apply_updates()inbase_coder.pyprocesses and applies LLM edit blocks regardless ofedit_format. When the LLM hallucinates edit blocks inaskmode, 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 foraskmode. The fix adds an early return at the entry ofapply_updates()whenedit_format == "ask", short-circuiting the entire edit pipeline.Verification
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 failedBlast Radius
askmode only. No behavioral change forcode,architect, or other edit formats.apply_updates(); the guard is intentionally at the shared method entry point since only AskCoder should skip edits.Closes #5374