feat: concat chunked Telegram messages for multi-part pastes (#186)#187
Open
IliyaBrook wants to merge 2 commits intoRichardAtCT:mainfrom
Open
feat: concat chunked Telegram messages for multi-part pastes (#186)#187IliyaBrook wants to merge 2 commits intoRichardAtCT:mainfrom
IliyaBrook wants to merge 2 commits intoRichardAtCT:mainfrom
Conversation
|
Hey, thank you for the PR Or maybe at least add a note to the docs. |
Author
|
Good catch, thanks! You're right — I had the same thought after reading your example. I've lowered the default |
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
When a user pastes text longer than 4096 characters, the Telegram client silently splits it into multiple messages. Previously, each fragment triggered a separate Claude run — wasteful, slow, and producing poor results since Claude would see incomplete text fragments.
This PR adds a per-user debounce buffer that detects Telegram-split chunks (messages near the 4096-char limit), accumulates them, and submits the combined text as a single Claude request.
How it works
"".join()) since Telegram splits at character boundariesNew settings
CHUNK_BUFFER_TIMEOUT(default0.5) — seconds to wait for more chunksCHUNK_BUFFER_THRESHOLD(default4000) — min message length to trigger bufferingChanged files
src/bot/utils/message_buffer.py— newMessageBufferclasssrc/bot/orchestrator.py— extracted_process_agentic_text(), added buffer logic toagentic_text()src/config/settings.py— new settingssrc/utils/constants.py— new defaultstests/unit/test_bot/test_message_buffer.py— 20 unit teststests/unit/test_bot/test_middleware.py— fixture update for new settingsTest plan
Closes #186