fix: do not append newlines for an empty system reminder - #5612
Open
BetterAndBetterII wants to merge 1 commit into
Open
fix: do not append newlines for an empty system reminder#5612BetterAndBetterII wants to merge 1 commit into
BetterAndBetterII wants to merge 1 commit into
Conversation
format_chat_chunks treated a missing max_input_tokens as always adding a user reminder. Combined with an empty help-coder reminder, that still concatenated trailing newlines onto the last user message.
Author
|
I have read the CLA Document and I hereby sign the CLA |
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
Coder.format_chat_chunkstreated a missingmax_input_tokensas “always add the reminder” becauseorbinds looser thanand. With the help coder’s emptysystem_reminderandreminder="user", that still concatenated"\n\n"onto the last user message even though there was no reminder text.Require a non-empty reminder before either placement branch. Keep adding a real reminder when the limit is missing or the prompt is under budget.
Closes #5611
Test plan
pytest tests/basic/test_coder.py::TestCoder::test_format_chat_chunks_empty_reminder_preserves_user_messagepytest tests/basic/test_coder.py::TestCoder::test_format_chat_chunks_reminder_max_input_tokens_combinationsmax_input_tokens→ user text unchangedmax_input_tokens→ user text unchangedmax_input_tokens→"\n\n" + remindermax_input_tokens→"\n\n" + reminder