You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Enhancement] Renew Telegram typing indicator during long agent.chat() calls
Labels:enhancement, gateway, telegram, ux
Overview
Telegram shows a "typing…" indicator when a bot calls send_action("typing"). That indicator expires after approximately 5 seconds. PraisonAI sends it once, immediately before calling agent.chat() — a blocking operation that routinely takes 20–30 seconds when the agent uses RAG search, tool calls, and LLM inference.
From the user's perspective, the bot goes completely silent for half a minute, then suddenly replies. Many operators assume the bot is broken and send duplicate messages or restart the gateway.
This was observed in a Hermes workforce deployment: @mervincfo_bot responded correctly but only after ~25 seconds with zero feedback after the initial typing bubble disappeared.
What the user sees
Telegram UX timeline (current behavior)
T+0s User sends: "What is our Q1 burn rate?"
T+0s Bot shows "typing…" (send_action once)
T+5s "typing…" disappears (Telegram timeout)
T+5–25s Nothing. User thinks bot is dead.
T+25s Full CFO answer arrives.
User messages (typical)
"Bot isn't working"
"I sent three messages, no reply"
"Is the gateway down? Health says healthy."
Health endpoint reports "running": true. The bot is working — it just looks broken.
Architecture — message handling timeline
sequenceDiagram
participant U as Telegram User
participant G as Gateway polling handler
participant A as Agent (RAG + tools + LLM)
participant T as Telegram API
U->>G: "What is our Q1 burn rate?"
G->>T: send_action("typing") ← only once
T-->>U: "typing…" visible
Note over G,A: agent.chat() — 20–30 seconds
G->>A: search_knowledge + LLM call
A-->>G: response text
Note over T,U: typing indicator expired at T+5s
G->>T: reply_text(response)
T-->>U: Full answer at T+25s
Loading
Both code paths share this pattern:
Gateway:_start_telegram_bot_polling() → handle_message() → one send_action → bot._session.chat()
Standalone:TelegramBot.handle_message() → one send_action → bot._session.chat()
There is no background task, no renewal loop, and no default acknowledgment emoji in gateway-generated configs.
Why agent.chat() takes so long (not a bug, but UX-critical)
In a typical workforce agent turn:
Step
Duration
Embedding + vector search (search_knowledge)
2–5s
LLM call with tool result context
5–15s
Optional second LLM pass (reflection, formatting)
5–10s
Network latency
1–3s
Total
15–30s common
This is expected for RAG-enabled agents. The UX gap is not slow inference — it is zero feedback after second 5.
Telegram platform constraints
send_action("typing") must be re-sent periodically to keep the indicator visible.
Telegram Bot API docs and community practice: renew every 4–5 seconds during long operations.
send_action("upload_photo") or other actions can substitute but typing is the standard chat UX.
Reaction emoji (ack_emoji: "⏳") can provide immediate visual ack independent of typing — PraisonAI supports this via bot._ack but it is not enabled by default in onboard configs.
[Enhancement] Renew Telegram typing indicator during long
agent.chat()callsLabels:
enhancement,gateway,telegram,uxOverview
Telegram shows a "typing…" indicator when a bot calls
send_action("typing"). That indicator expires after approximately 5 seconds. PraisonAI sends it once, immediately before callingagent.chat()— a blocking operation that routinely takes 20–30 seconds when the agent uses RAG search, tool calls, and LLM inference.From the user's perspective, the bot goes completely silent for half a minute, then suddenly replies. Many operators assume the bot is broken and send duplicate messages or restart the gateway.
This was observed in a Hermes workforce deployment:
@mervincfo_botresponded correctly but only after ~25 seconds with zero feedback after the initial typing bubble disappeared.What the user sees
Telegram UX timeline (current behavior)
User messages (typical)
Health endpoint reports
"running": true. The bot is working — it just looks broken.Architecture — message handling timeline
sequenceDiagram participant U as Telegram User participant G as Gateway polling handler participant A as Agent (RAG + tools + LLM) participant T as Telegram API U->>G: "What is our Q1 burn rate?" G->>T: send_action("typing") ← only once T-->>U: "typing…" visible Note over G,A: agent.chat() — 20–30 seconds G->>A: search_knowledge + LLM call A-->>G: response text Note over T,U: typing indicator expired at T+5s G->>T: reply_text(response) T-->>U: Full answer at T+25sBoth code paths share this pattern:
_start_telegram_bot_polling()→handle_message()→ onesend_action→bot._session.chat()TelegramBot.handle_message()→ onesend_action→bot._session.chat()There is no background task, no renewal loop, and no default acknowledgment emoji in gateway-generated configs.
Why agent.chat() takes so long (not a bug, but UX-critical)
In a typical workforce agent turn:
search_knowledge)This is expected for RAG-enabled agents. The UX gap is not slow inference — it is zero feedback after second 5.
Telegram platform constraints
send_action("typing")must be re-sent periodically to keep the indicator visible.send_action("upload_photo")or other actions can substitute but typing is the standard chat UX.ack_emoji: "⏳") can provide immediate visual ack independent of typing — PraisonAI supports this viabot._ackbut it is not enabled by default in onboard configs.Proposed fix
1. Typing renewal task
agent.chat().finallywhen response is sent or on error.TelegramBot.handle_message().2. Optional immediate ack
Enable
ack_emoji: "⏳"(or configurable) in onboard-generated gateway configs so users get instant feedback even before typing renewal kicks in.3. Shared helper
Single
TypingIndicatorutility inpraisonai.botsto avoid duplicating renewal logic across gateway and standalone paths.What this is NOT
Acceptance criteria