feat: add conversation history for Telegram chat sessions#536
Open
buger wants to merge 1 commit intoprobelabs:mainfrom
Open
feat: add conversation history for Telegram chat sessions#536buger wants to merge 1 commit intoprobelabs:mainfrom
buger wants to merge 1 commit intoprobelabs:mainfrom
Conversation
The Telegram adapter's buildConversationContext() only included the current message in the messages array, causing every message to be processed in isolation without any conversation context. This meant the LLM couldn't reference previous messages in the chat. Changes: - Add in-memory chat history cache to TelegramAdapter (per thread ID) with LRU eviction (max 500 chats), TTL (2 hours), and per-chat message limit (50 messages) - buildConversationContext() now returns the full conversation history in the messages array, matching the Slack adapter pattern - Polling runner captures bot responses from engine results and adds them to the history, so the LLM sees both user and bot messages - Inject conversation context into execution context so the engine can use it for the git-check bypass (PR probelabs#535) This brings Telegram conversation handling in line with the Slack adapter, which already maintains thread history via ThreadCache. Co-Authored-By: Claude Opus 4.6 <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.
Problem
The Telegram adapter's
buildConversationContext()only includes the current message:This means every Telegram message is processed in isolation — the LLM has no context from previous messages in the conversation. The bot can't follow multi-turn conversations, reference earlier questions, or maintain context.
Compare with the Slack adapter, which maintains a
ThreadCacheand passes full thread history:Fix
1.
TelegramAdapter— in-memory chat history cacheaddToHistory(threadId, message)— public method for the runner to add bot responsesbuildConversationContext()now returns full history inmessagesarray2.
TelegramPollingRunner— captures bot responsesconversationinto execution context (works with the git-check bypass from PR fix: skip git requirement for conversation/chat workflows #535)Test plan
🤖 Generated with Claude Code