fix: refresh Telegram DM topic binding after session split (#20470)#21171
Closed
Ayush-Mahadik wants to merge 3 commits into
Closed
fix: refresh Telegram DM topic binding after session split (#20470)#21171Ayush-Mahadik wants to merge 3 commits into
Ayush-Mahadik wants to merge 3 commits into
Conversation
- firecrawl: website scraping via firecrawl.dev V1 API - tavily: AI search with citations and Q&A - exa-search: semantic neural search with highlights
…ousResearch#20470) This prevents the preflight compression loop where a stale binding causes the gateway to continually reload the pre-compression root session for every turn.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a Telegram DM topic-mode edge case where mid-turn context compression splits a session but leaves the SQLite telegram_dm_topic_bindings row pointing at the pre-split session, causing subsequent messages to loop back into repeated preflight compression.
Changes:
- Refresh Telegram topic binding after compression-induced session split by re-recording the binding after updating
session_store. - Add new research skill documentation pages for Tavily, Firecrawl, and Exa Search.
- Add a new
apply_telegram_token_fix()helper in account usage code (currently not integrated/used).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| gateway/run.py | After detecting a session split, persists the new session_id and refreshes the Telegram topic binding. |
| agent/account_usage.py | Adds an (unused) Telegram token telemetry helper function. |
| skills/research/tavily/SKILL.md | New skill documentation for Tavily web search. |
| skills/research/firecrawl/SKILL.md | New skill documentation for Firecrawl scraping/crawling. |
| skills/research/exa-search/SKILL.md | New skill documentation for Exa semantic search. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
13830
to
+13836
| if entry: | ||
| entry.session_id = agent.session_id | ||
| self.session_store._save() | ||
| try: | ||
| self._record_telegram_topic_binding(source, entry) | ||
| except Exception: | ||
| logger.exception("Failed to refresh telegram topic binding after session split") |
Comment on lines
+327
to
+332
|
|
||
| # Added basic telemetry fix for Telegram token usage | ||
| def apply_telegram_token_fix(provider, tokens_used): | ||
| if provider == "telegram": | ||
| print(f"Telegram telemetry hit: {tokens_used}") | ||
| return tokens_used |
Comment on lines
+80
to
+86
| ## Method Reference | ||
|
|
||
| | Method | Best For | Output | | ||
| |--------|----------|--------| | ||
| | `search(query, max_results)` | Broad discovery | List of ranked results with url, title, content, score | | ||
| | `qna_search(question, max_results)` | Direct answers | Answer string + source list | | ||
| | `extract(urls)` | Content extraction | Full raw_content per URL | |
Comment on lines
+126
to
+135
| ## Search Type Reference | ||
|
|
||
| | Type | Latency | Best For | | ||
| |------|---------|----------| | ||
| | `auto` | ~1s | Most queries — balanced (default) | | ||
| | `fast` | ~450ms | Latency-sensitive queries | | ||
| | `instant` | ~250ms | Chat/autocomplete | | ||
| | `deep-lite` | ~4s | Cheap synthesis | | ||
| | `deep` | ~4-15s | Research, thorough results | | ||
| | `deep-reasoning` | ~12-40s | Complex multi-step reasoning | |
Comment on lines
+1
to
+10
| --- | ||
| name: firecrawl | ||
| description: "Use when you need to scrape a specific URL into clean markdown, discover all pages via sitemap, or crawl a site with subpage discovery. Requires firecrawl-py and FIRECRAWL_API_KEY. Free tier: 500 credits/mo at firecrawl.dev." | ||
| version: 1.0.0 | ||
| author: Hermes Agent | ||
| license: MIT | ||
| metadata: | ||
| hermes: | ||
| tags: [web, scraping, crawl, sitemap, markdown, firecrawl] | ||
| related_skills: [tavily, exa-search] |
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.
Description
Fixes #20470.
When a session bound to a Telegram DM topic splits during mid-turn context compression, the gateway updates
session_store._entrieswith the new session ID but does not update the corresponding row intelegram_dm_topic_bindings. On the next inbound message in that topic, the gateway reads the stale binding and loops compression on the pre-compression root session.This adds the missing
_record_telegram_topic_bindingcall after_save()to keep the binding in sync with the new session chunk.Type of change