fix(telegram+config): per-inbound typing keying, tighter context cache, higher max_tokens#997
Open
minhdang03 wants to merge 1 commit intonextlevelbuilder:devfrom
Open
Conversation
…he + raise max_tokens Three follow-ups to the earlier telegram-error / markdown-balance fix, all concentrating around "user sends two messages in rapid succession". **Typing controller: key by inbound message id, not localKey.** With scheduler maxConcurrent=1 for DM, msg2 queues behind an in-flight msg1. The old handler replaced typingCtrls[localKey] when msg2 arrived, and then Send() for msg1's reply yanked that shared controller — leaving msg2 to run silently with no typing indicator. Now each inbound owns its own typing controller under a composite key (localKey + msg id) and Send() stops only its own via the new `inbound_message_id` outbound metadata field (with a graceful fall-through to localKey for non-Telegram outbounds). **USER.md context-file cache TTL 5m → 1m.** The 5-minute cache made same-conversation writes invisible for a long window — a predefined agent could write USER.md, then re-read its stale cached copy on the next turn. Direct writes invalidate their own key, but indirect writes (admin UI, background workers) could linger up to 5 min. One minute is short enough to be safe for bursty conversational writes without re-reading the file every turn. **DefaultMaxTokens 8192 → 16384.** Modern agents doing step-by-step reasoning plus tool calls plus a final answer can hit the 8192 cap, producing finish_reason=length mid-bold and cut messages on Telegram. Providers bill actual completion tokens not the cap, so raising it has no cost impact on normal replies but removes a recurring truncation footgun for long answers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Three follow-ups to #996, all grouped around the "two inbounds for the same chat in quick succession" failure mode and the truncation-related UX bugs.
Files changed
Test plan
Relation to #996
These are strictly additive. #996 is already enough to stop the visible "**70" leak and the silent-error dead-end. This PR closes the remaining two footguns (typing yank + truncation pressure) and reduces the staleness window on USER.md.
🤖 Generated with Claude Code