Issue
Summary
In aider/repo.py, GitRepo.get_commit_message treats a whitespace-only model response as a successful commit message before normalizing it with strip().
When the first configured model returns only whitespace, the method stops trying fallback models and ultimately returns an empty string.
Steps to reproduce
-
Check out Aider main at commit 5dc9490bb35f9729ef2c95d00a19ccd30c26339c.
-
Add the following test inside TestRepo in tests/basic/test_repo.py:
@patch("aider.models.Model.simple_send_with_retries")
def test_get_commit_message_skips_whitespace_only_response(self, mock_send):
mock_send.side_effect = [" ", "fallback commit message"]
model1 = Model("gpt-3.5-turbo")
model2 = Model("gpt-4")
repo = GitRepo(InputOutput(), None, None, models=[model1, model2])
result = repo.get_commit_message("dummy diff", "dummy context")
self.assertEqual(
(result, mock_send.call_count),
("fallback commit message", 2),
)
- Run:
python -m pytest tests/basic/test_repo.py -q
- Observe that the newly added assertion fails while the 21 existing tests pass.
Expected behavior
The whitespace-only response should be treated as an empty response after normalization. get_commit_message should try the second configured model and return:
"fallback commit message"
The existing test_get_commit_message establishes this fallback behavior when the first model returns an empty string. A whitespace-only response also becomes empty when processed by the method's existing strip() operation.
Actual behavior
get_commit_message stops after the first model, returns an empty string, and never calls the fallback model:
(result, mock_send.call_count) == ("", 1)
The focused run reports:
...........F.......... [100%]
FAILED tests/basic/test_repo.py::TestRepo::test_get_commit_message_skips_whitespace_only_response
AssertionError: Tuples differ: ('', 1) != ('fallback commit message', 2)
First differing element 0:
''
'fallback commit message'
- ('', 1)
+ ('fallback commit message', 2)
1 failed, 21 passed in 21.58s
Impact
A whitespace-only response from an earlier commit-message model prevents later configured models from generating a usable message.
When this empty result is returned to GitRepo.commit, the commit path replaces it with the generic fallback text:
(no commit message provided)
The configured fallback model is therefore skipped even though it could provide a valid commit message.
Root cause
The model loop checks the unnormalized response for truthiness:
commit_message = model.simple_send_with_retries(messages)
if commit_message:
break
A string containing spaces is truthy, so the loop terminates. Whitespace is removed only after the fallback loop has finished:
commit_message = commit_message.strip()
The value consequently becomes empty after the opportunity to try another model has already passed.
Possible fix direction
Normalize each model response before deciding whether it is usable:
commit_message = model.simple_send_with_retries(messages)
if commit_message:
commit_message = commit_message.strip()
if commit_message:
break
Regression coverage should retain the existing empty-response fallback test and add whitespace-only responses, including spaces, tabs, and newlines.
Version and model info
Aider: 0.86.3.dev, main@5dc9490bb35f9729ef2c95d00a19ccd30c26339c
Python: 3.12.13
Operating system: macOS 15.7.3
Installation: source checkout; focused pytest reproduction
Models: local gpt-3.5-turbo and gpt-4 model metadata used to exercise fallback ordering; no provider request is made
Configuration: two-model commit-message fallback sequence
Issue
Summary
In
aider/repo.py,GitRepo.get_commit_messagetreats a whitespace-only model response as a successful commit message before normalizing it withstrip().When the first configured model returns only whitespace, the method stops trying fallback models and ultimately returns an empty string.
Steps to reproduce
Check out Aider
mainat commit5dc9490bb35f9729ef2c95d00a19ccd30c26339c.Add the following test inside
TestRepointests/basic/test_repo.py:Expected behavior
The whitespace-only response should be treated as an empty response after normalization.
get_commit_messageshould try the second configured model and return:"fallback commit message"The existing
test_get_commit_messageestablishes this fallback behavior when the first model returns an empty string. A whitespace-only response also becomes empty when processed by the method's existingstrip()operation.Actual behavior
get_commit_messagestops after the first model, returns an empty string, and never calls the fallback model:The focused run reports:
Impact
A whitespace-only response from an earlier commit-message model prevents later configured models from generating a usable message.
When this empty result is returned to
GitRepo.commit, the commit path replaces it with the generic fallback text:The configured fallback model is therefore skipped even though it could provide a valid commit message.
Root cause
The model loop checks the unnormalized response for truthiness:
A string containing spaces is truthy, so the loop terminates. Whitespace is removed only after the fallback loop has finished:
The value consequently becomes empty after the opportunity to try another model has already passed.
Possible fix direction
Normalize each model response before deciding whether it is usable:
Regression coverage should retain the existing empty-response fallback test and add whitespace-only responses, including spaces, tabs, and newlines.
Version and model info
Aider:
0.86.3.dev,main@5dc9490bb35f9729ef2c95d00a19ccd30c26339cPython:
3.12.13Operating system: macOS
15.7.3Installation: source checkout; focused pytest reproduction
Models: local
gpt-3.5-turboandgpt-4model metadata used to exercise fallback ordering; no provider request is madeConfiguration: two-model commit-message fallback sequence