fix: refresh commit-message models after /model or /weak-model switch - #5685
Open
Shxiao101 wants to merge 1 commit into
Open
fix: refresh commit-message models after /model or /weak-model switch#5685Shxiao101 wants to merge 1 commit into
Shxiao101 wants to merge 1 commit into
Conversation
GitRepo only received commit_message_models() when it was first constructed. /model and /weak-model rebuild the Coder but reuse the existing repo object, so commit messages kept using the previous weak model until aider was restarted (issue Aider-AI#5213). Re-derive the model list from the current main model whenever an already-constructed repo is attached.
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.
Fixes #5213
Problem
GitRepoonly receivescommit_message_models()when it is first constructed./modeland/weak-modelraiseSwitchCoder, andmain.pyrebuilds the coder viaCoder.create(..., from_coder=old_coder)— but the new coder inherits the originalrepoobject fromfrom_coder.original_kwargs, soCoder.__init__skips theGitRepoconstruction branch (self.repois notNone) andrepo.modelskeeps pointing at the old[weak_model, main_model]pair. Commit messages — both manual/commitand the automatic post-edit ones — keep using the previous weak model until aider is restarted.Change
While attaching an already-constructed repo in
Coder.__init__, refreshrepo.modelsfrom the currentmain_model:repo.modelsis only consumed byGitRepo.get_commit_message(), andcommit_message_models()is a pure accessor returning[self.weak_model, self], so the refresh is an idempotent no-op on first construction and cannot bypass any normalization (GitRepo.__init__storesmodelsas-is).Testing
GitRepoand twoCoder.create()calls using different weak models: onmain,repo.modelsstayed['gpt-4o-mini', 'gpt-4o-mini']after the switch; with this change it becomes['gpt-3.5-turbo', 'gpt-4o-mini'].pytest tests/basic/test_repo.py tests/basic/test_coder.py: 58 passed, 5 skipped, 29 subtests passed — identical before and after the change.