-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
feat: major improvements to native Telegram integration UX and streaming #1676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
3clyp50
merged 10 commits into
agent0ai:ready
from
hash-anmol:telegram-native-integration-production
Jun 11, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1bbbfa4
Improve Telegram integration command and streaming UX
hash-anmol 8bc81c7
Send Telegram intermediate responses separately
hash-anmol a17cef5
Group Telegram tool streams by response
hash-anmol 97ef479
Send Telegram media attachments natively
hash-anmol 92b728c
Show friendly Telegram errors
hash-anmol 99207d6
Add Telegram long-run status updates
hash-anmol 1ff45e7
Add Telegram session picker
hash-anmol 709b865
Add Telegram speech mode
hash-anmol 013a374
Revert "Add Telegram speech mode"
hash-anmol abf0cef
Scope Telegram integration commands
hash-anmol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
43 changes: 43 additions & 0 deletions
43
...ation/extensions/python/_functions/agent/Agent/handle_exception/end/_85_telegram_error.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| from helpers.errors import HandledException | ||
| from helpers.extension import Extension | ||
| from helpers.print_style import PrintStyle | ||
| from plugins._telegram_integration.helpers.constants import ( | ||
| CTX_TG_BOT, | ||
| CTX_TG_ERROR_SENT, | ||
| CTX_TG_REPLY_TO, | ||
| CTX_TG_TYPING_STOP, | ||
| ) | ||
|
|
||
|
|
||
| class TelegramFriendlyError(Extension): | ||
| async def execute(self, data: dict = {}, **kwargs): | ||
| if not self.agent or self.agent.number != 0: | ||
| return | ||
|
|
||
| context = self.agent.context | ||
| if not context.data.get(CTX_TG_BOT): | ||
| return | ||
|
|
||
| exception = data.get("exception") | ||
| if not exception or isinstance(exception, HandledException): | ||
| return | ||
|
|
||
| if context.data.get(CTX_TG_ERROR_SENT): | ||
| return | ||
|
|
||
| context.data[CTX_TG_ERROR_SENT] = True | ||
|
|
||
| from plugins._telegram_integration.helpers import draft_stream, error_ui, heartbeat | ||
| from plugins._telegram_integration.helpers.handler import send_telegram_reply | ||
|
|
||
| text = error_ui.friendly_error_message(exception) | ||
| error = await send_telegram_reply(context, text) | ||
| if error: | ||
| PrintStyle.debug(f"Telegram error reply failed: {error}") | ||
|
|
||
| typing_stop = context.data.pop(CTX_TG_TYPING_STOP, None) | ||
| if typing_stop: | ||
| typing_stop.set() | ||
| await heartbeat.stop(context) | ||
| draft_stream.clear(context) | ||
| context.data.pop(CTX_TG_REPLY_TO, None) | ||
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
18 changes: 18 additions & 0 deletions
18
...ns/_telegram_integration/extensions/python/message_loop_start/_45_telegram_draft_start.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| from agent import LoopData | ||
| from helpers.extension import Extension | ||
| from plugins._telegram_integration.helpers.constants import CTX_TG_BOT | ||
|
|
||
|
|
||
| class TelegramDraftStart(Extension): | ||
|
|
||
| async def execute(self, loop_data: LoopData = LoopData(), **kwargs): | ||
|
3clyp50 marked this conversation as resolved.
|
||
| if not self.agent or self.agent.number != 0: | ||
| return | ||
| context = self.agent.context | ||
| if not context.data.get(CTX_TG_BOT): | ||
| return | ||
|
|
||
| from plugins._telegram_integration.helpers import draft_stream, heartbeat | ||
|
|
||
| await draft_stream.start(context) | ||
| await heartbeat.start(context) | ||
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
30 changes: 30 additions & 0 deletions
30
...ns/_telegram_integration/extensions/python/response_stream/_45_telegram_draft_response.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| from agent import LoopData | ||
| from helpers.extension import Extension | ||
| from plugins._telegram_integration.helpers.constants import CTX_TG_BOT | ||
|
|
||
|
|
||
| class TelegramDraftResponse(Extension): | ||
|
|
||
| async def execute( | ||
| self, | ||
| loop_data: LoopData = LoopData(), | ||
|
3clyp50 marked this conversation as resolved.
|
||
| parsed: dict | None = None, | ||
| **kwargs, | ||
| ): | ||
| if not self.agent or self.agent.number != 0: | ||
| return | ||
| context = self.agent.context | ||
| if not context.data.get(CTX_TG_BOT): | ||
| return | ||
|
|
||
| parsed = parsed or {} | ||
| if parsed.get("tool_name") != "response": | ||
| return | ||
| tool_args = parsed.get("tool_args") or {} | ||
| text = tool_args.get("text") or tool_args.get("message") or "" | ||
| if not text: | ||
| return | ||
|
|
||
| from plugins._telegram_integration.helpers import draft_stream | ||
|
|
||
| await draft_stream.update_response(context, str(text)) | ||
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
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
18 changes: 18 additions & 0 deletions
18
...ns/_telegram_integration/extensions/python/tool_execute_before/_45_telegram_draft_tool.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| from helpers.extension import Extension | ||
| from plugins._telegram_integration.helpers.constants import CTX_TG_BOT | ||
|
|
||
|
|
||
| class TelegramDraftToolStart(Extension): | ||
|
|
||
| async def execute(self, tool_name: str = "", tool_args: dict | None = None, **kwargs): | ||
| if not self.agent or self.agent.number != 0: | ||
| return | ||
| if (tool_name or "").strip().lower() == "response": | ||
| return | ||
| context = self.agent.context | ||
| if not context.data.get(CTX_TG_BOT): | ||
| return | ||
|
|
||
| from plugins._telegram_integration.helpers import draft_stream | ||
|
|
||
| await draft_stream.add_tool_start(context, tool_name, tool_args or {}) |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.