Skip to content

Agent Zero AI framework

Ignore non-Telegram tool streaming contexts

Alessandro8e270c5ab766
diff --git a/plugins/_telegram_integration/extensions/python/tool_execute_after/_50_telegram_response.py b/plugins/_telegram_integration/extensions/python/tool_execute_after/_50_telegram_response.py
index c959eaf52..b911219ba 100644
--- a/plugins/_telegram_integration/extensions/python/tool_execute_after/_50_telegram_response.py
+++ b/plugins/_telegram_integration/extensions/python/tool_execute_after/_50_telegram_response.py
@@ -16,7 +16,13 @@ class TelegramResponseIntercept(Extension):
if not self.agent:
return
context = self.agent.context
- if not context.data.get(CTX_TG_BOT):
+ context_data = getattr(context, "data", None)
+ telegram_bot = (
+ context_data.get(CTX_TG_BOT)
+ if isinstance(context_data, dict)
+ else context.get_data(CTX_TG_BOT)
+ )
+ if not telegram_bot:
return
from plugins._telegram_integration.helpers import draft_stream
diff --git a/plugins/_telegram_integration/extensions/python/tool_execute_before/_45_telegram_draft_tool.py b/plugins/_telegram_integration/extensions/python/tool_execute_before/_45_telegram_draft_tool.py
index 4496cd422..0a32839a6 100644
--- a/plugins/_telegram_integration/extensions/python/tool_execute_before/_45_telegram_draft_tool.py
+++ b/plugins/_telegram_integration/extensions/python/tool_execute_before/_45_telegram_draft_tool.py
@@ -10,7 +10,13 @@ class TelegramDraftToolStart(Extension):
if (tool_name or "").strip().lower() == "response":
return
context = self.agent.context
- if not context.data.get(CTX_TG_BOT):
+ context_data = getattr(context, "data", None)
+ telegram_bot = (
+ context_data.get(CTX_TG_BOT)
+ if isinstance(context_data, dict)
+ else context.get_data(CTX_TG_BOT)
+ )
+ if not telegram_bot:
return
from plugins._telegram_integration.helpers import draft_stream