Repository navigation
Description
Summary
When channels.telegram.webhookUrl is configured, OpenClaw continues running its long-polling transport in the background. This polling transport periodically calls getUpdates, which causes Telegram to silently delete the registered webhook. The result is a continuous wipe cycle: webhook is set on startup → polling transport issues getUpdates ~30s later → Telegram interprets this as "switch to polling mode" and clears the webhook → inbound messages are lost until the webhook is manually re-registered.
Version
OpenClaw 2026.6.1 (confirmed via openclaw --version)
Steps to reproduce
- Configure
channels.telegram.webhookUrl+channels.telegram.webhookSecretinopenclaw.json - Start or restart the gateway
- Observe via
getWebhookInfo: webhook URL is set immediately after startup - Wait 20–35 seconds
- Observe via
getWebhookInfo: webhook URL is now empty — cleared by Telegram - Repeat step 4–5: it wipes every ~30 seconds continuously as long as the gateway runs
Root cause
The long-polling watchdog (pollingStallThresholdMs) runs even when webhookUrl is configured — OpenClaw has no pure-webhook mode. The polling transport calls getUpdates on its liveness cycle; per Telegram Bot API specification, calling getUpdates while a webhook is active automatically deletes the webhook (this is documented Telegram behaviour, not a Telegram bug).
From the OpenClaw docs (channels/telegram.md):
"Long polling is the default mode; webhook mode is optional."
"A still-active webhook surfaces as agetUpdatesconflict; OpenClaw then rebuilds the Telegram transport and retries webhook cleanup."
This confirms the polling path always runs. The pollingStallThresholdMs config key (range 30000–600000) only tunes the watchdog timing — it does not disable polling.
The complete channels.telegram schema was enumerated via openclaw config schema lookup channels.telegram. There is no disablePolling, mode: "webhook", webhookOnly, transport, or any flag to stop the poller when in webhook mode.
Impact
- Inbound Telegram DMs and group messages silently dropped for ~30s windows every minute
- Every gateway restart resets the webhook → DM blackout until manually re-registered
- Even with
webhookUrlconfigured, the bot receives no messages unless an external process continuously re-assertssetWebhook
Current workaround
A systemd timer fires every 15s, calls setWebhook via getWebhookInfo check (never getUpdates), and re-asserts the webhook before the next polling wipe. This works but is a band-aid.
# /etc/systemd/system/tg-webhook-guard.timer
[Timer]
OnBootSec=20s
OnUnitActiveSec=15s
AccuracySec=1sRequested fix
Add a disablePolling: true or transport: "webhook" config flag to channels.telegram that:
- Skips starting the long-polling transport entirely when
webhookUrlis set - Does NOT call
getUpdatesordeleteWebhookduring normal operation - Only uses the webhook listener path for inbound messages
Alternatively, make webhook mode the automatic behaviour when webhookUrl is configured (breaking change, but semantically correct).
Evidence
Gateway log shows liveness warning: eventLoopDelayP99Ms=4099 alongside continuous polling transport restarts. Empirical test: set webhook, poll getWebhookInfo every 10s with no guard running:
T+0s → set
T+10s → https://example.com/telegram-webhook ✅
T+20s → https://example.com/telegram-webhook ✅
T+30s → (empty) ❌ ← wiped by getUpdates
T+40s → (empty)
Reproduced across 3 independent gateway restarts on OpenClaw 2026.6.1.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 4, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 21, 2026, 7:34 AM ET / 11:34 UTC.
Summary
Keep open: current main and the latest release still call Telegram
deleteWebhookfrom the webhook abort path, while the focused repair is an open, unmerged PR that still needs review/proof before this issue can be closed.Reproducibility: yes. source-reproducible: current main still calls
deleteWebhookwhen the webhook abort signal fires, and the reporter supplied repeatedgetWebhookInfoclearing evidence. I did not run a live Telegram current-main reproduction.Root-cause cluster
Relationship:
canonicalCanonical: #90254
Summary: This issue is the canonical user report; the linked PR is the current open candidate fix and no merged fix exists on main yet.
Members:
fixed_by_candidate: fix(telegram): stop clearing registered webhook on channel restart #94506 - The PR uses closing syntax for this issue and removes the webhook shutdowndeleteWebhookcall identified in the issue discussion.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Next step
No new repair job: #94506 is open, uses closing syntax, and already owns the focused repair path.
Review details
Best possible solution:
Review and land #94506, or an equivalent focused lifecycle fix, so webhook registration persists across transient restarts while polling-mode cleanup remains intact.
Do we have a high-confidence way to reproduce the issue?
Yes, source-reproducible: current main still calls
deleteWebhookwhen the webhook abort signal fires, and the reporter supplied repeatedgetWebhookInfoclearing evidence. I did not run a live Telegram current-main reproduction.Is this the best way to solve the issue?
Yes for the linked lifecycle direction, not for the original new config flag proposal. Current main already selects webhook mode from
webhookUrl; the narrow maintainable fix is to stop transient webhook shutdown from deregistering Telegram while leaving polling-mode cleanup separate.AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against d1cbe29f3d52.
Label changes
Label changes:
issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.clawsweeper:needs-live-repro: Current issue advisory state no longer selects this label.issue-rating: 🐚 platinum hermit: Current issue advisory state no longer selects this label.Label justifications:
P2: This is a bounded Telegram channel reliability bug with concrete inbound message-loss impact but limited blast radius.impact:message-loss: Repeated webhook deregistration can prevent Telegram DMs and group messages from reaching OpenClaw.Evidence reviewed
What I checked:
getWebhookInfoobservations showing the webhook URL clearing on a regular cadence in OpenClaw 2026.6.1.startTelegramWebhookregisters a shutdown path that callsbot.api.deleteWebhook({ drop_pending_updates: false })when the abort signal fires. (extensions/telegram/src/webhook.ts:418, d1cbe29f3d52)useWebhook: Boolean(account.config.webhookUrl), so the remaining bug is the webhook lifecycle cleanup path rather than a missing transport-mode flag. (extensions/telegram/src/channel.ts:1083, d1cbe29f3d52)deleteWebhook, confirming main has not adopted the linked fix behavior. (extensions/telegram/src/webhook.test.ts:1046, d1cbe29f3d52)getUpdatesand webhooks are mutually exclusive, anddeleteWebhookremoves webhook integration when switching back togetUpdates.v2026.6.9is published, and the tag still contains the same webhook shutdowndeleteWebhookcall and test expectation. (extensions/telegram/src/webhook.ts:418, c645ec4555c0)Likely related people:
src/telegram/webhook.ts,extensions/telegram/src/channel.ts,extensions/telegram/src/webhook.ts)src/telegram/webhook.ts,src/telegram/webhook.test.ts)deleteWebhookpath. (role: recent polling and webhook-cleanup contributor; confidence: medium; commits: 5b94c4ce9396; files:extensions/telegram/src/monitor.ts,extensions/telegram/src/polling-session.ts,docs/channels/telegram.md)extensions/telegram/src/monitor.ts,extensions/telegram/src/polling-session.ts,extensions/telegram/src/telegram-ingress-worker.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.travellingsoldier85 commentedon Jun 4, 2026
Update — Root Fix Found via Schema Inspection
After diving deeper into the OpenClaw config schema via
openclaw config schema, the real fix was discovered:channels.telegram.actions.poll: falseThis is an undocumented schema key (not mentioned in the official docs at https://docs.openclaw.ai/channels/telegram) that disables the polling transport entirely, preventing
getUpdatescalls that were wiping the webhook.Config fix
{ "channels": { "telegram": { "webhookUrl": "https://your-domain.com/telegram-webhook", "webhookSecret": "<secret>", "actions": { "poll": false } } } }Test result (7/7 consecutive
getWebhookInfochecks over 70s, all stable):After setting
actions.poll: falseand restarting the gateway, the webhook stays registered permanently without any external guard process.Remaining issue
channels.telegram.actions.pollis not documented in the official Telegram channel docs. The docs only mentionwebhookUrl,webhookSecret,webhookPath,webhookHost,webhookPort, andwebhookCertPath— with no mention ofactions.pollas the required companion key to actually disable polling in webhook mode.Request: Please add
channels.telegram.actions.poll: falseto the webhook mode setup instructions in the docs. Without it, anywebhookUrldeployment silently continues polling and self-wipes the webhook every ~30 seconds.travellingsoldier85 commentedon Jun 4, 2026
Deeper Investigation — Real Root Cause
After further source code analysis of the compiled dist files, the true root cause is more nuanced:
What
channels.telegram.actions.poll: falseactually doesThis key controls whether the bot can send Telegram "poll" message types (quizzes/surveys) — not the long-polling transport. It does not disable polling. My earlier comment was incorrect.
Actual root cause — webhook runtime transport rebuild loop
From
monitor-webhook.runtime-BDuy-hXn.js:The webhook runtime calls
deleteWebhookwhenever itsabortSignalfires. This fires during:config change detected; evaluating reload (channels.telegram.actions))eventLoopDelayP99Ms=4099msobserved during heavy work)After
deleteWebhook, the runtime restarts and callssetWebhookagain — but under event loop pressure, thesetWebhookcall can fail silently, leaving the webhook empty until the next successful retry.The fix that actually works
A systemd timer firing every 15 seconds that re-asserts
setWebhookviagetWebhookInfocheck (nevergetUpdates):# /etc/systemd/system/tg-webhook-guard.timer [Timer] OnBootSec=20s OnUnitActiveSec=15s AccuracySec=1sThis beats both the ~30s transport rebuild cycle and any silent
setWebhookfailures.Requested fix (updated)
setWebhookwith exponential backoff after anydeleteWebhook→setWebhookcycle, and log when the re-registration failsabortSignalchain should not triggerdeleteWebhookduring transient liveness probe failures — only on true shutdowndeleteWebhookon rebuild, and recommend a guard mechanism for production deploymentstravellingsoldier85 commentedon Jun 4, 2026
Update: 6-hour diagnostic evidence — confirmed ~32s clear cadence
Environment: OpenClaw 2026.6.1, Ubuntu 24.04, webhook mode (
webhookUrlset,actions.poll: false)What we now know with certainty
After running a webhook guard script (which calls
getWebhookInfoevery 15s and re-asserts viasetWebhookwhen cleared, never callinggetUpdates), we have 6 hours of continuous data:[32, 32, 31, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 32, 31, 32, 32, 32, 32, 30]The cadence is extremely regular — almost exactly 32s, not random. This strongly suggests a fixed-interval timer inside the gateway transport layer, not a stochastic event.
What does NOT cause it
actions.poll: falseis set — does not stop the clearing (per L-TG-WEBHOOK-ACTIONS-POLL-1 — this controls poll message types only, not the transport)getUpdateswith the same token returnsok: truewith no 409 conflict; only one gateway PID existsgetUpdates— proof: when the guard runs and the webhook is set,getWebhookInfostill returns the URL correctly. The clear only happens on the ~32s boundary.Hypothesis on root cause
Based on code strings observed in the gateway binary:
"polling so getUpdates can confirm webhook state""polling mode: clearing webhook"monitor-webhook.runtimeliveness/stall watchdogThe
monitor-webhook.runtimetransport liveness timer appears to fire every ~32s and either callsgetUpdatesor triggersdeleteWebhookvia anabortSignalduring transport rebuild. Since Telegram auto-deletes any registered webhook the momentgetUpdatesis called, this completely neutralises the webhook.actions.poll: falseappears to only disable the poll message type delivery, not the transport liveness probe itself.Impact
Without the guard timer, all inbound Telegram DMs are lost within ~32 seconds of any gateway start or config reload. The only mitigation is the 15s guard re-assertion loop, which is a band-aid racing the transport defect.
Request
monitor-webhook.runtimeliveness probe (or sets its interval to 0) whenwebhookUrlis configured?getUpdates/deleteWebhookin the liveness cycle whenwebhookUrlis set?Happy to provide any additional diagnostics (gateway logs, binary strings, etc.).
fix(telegram): stop clearing registered webhook on channel restart