Repository navigation
fix(telegram): retain superseded preview on generation mismatch race in sendMessageTransportPreview - #85808
Closed
samson1357924 wants to merge 10 commits into
Closed
fix(telegram): retain superseded preview on generation mismatch race in sendMessageTransportPreview#85808samson1357924 wants to merge 10 commits into
samson1357924 wants to merge 10 commits into
Conversation
…ected into config Two-part fix: A (onboarding-plugin-install.ts): add bundled root guard in addPluginLoadPath(). Before writing a plugin path to plugins.load.paths, check whether it resolves to OpenClaw's bundled plugin directory via resolvePackagedBundledLoadPathAlias. Bundled plugins are auto-discovered and do not need a config entry. B (repair-sequencing.ts): move maybeRepairBundledPluginLoadPaths to the end of the repair sequence so it runs after all plugin install/enable/auto-enable mutations are complete. Without this, plugin repair steps could re-add the bundled path after the mid-sequence cleanup, leaving a dirty config to be persisted. References: openclaw#85334
…ct flood Repeated callGateway calls each created a fresh GatewayClient then stopped it immediately. Each new client started WS exponential backoff from 1s, so background agents polling sessions.list (~2/sec) never let backoff converge to 30s, creating a sustained auth flood. Fix: pool GatewayClients by (method + token + password) key. acquirePooledClient() reuses a live client from the pool. releasePooledClient() keeps the client alive for 10s TTL then cleans up, letting WS backoff converge properly. Also adds GatewayClient.isShutdown public getter for pool liveness check without reaching into the private closed field. References: openclaw#85333
- Add CLIENT_POOL_MAX_SIZE=64 to prevent unbounded Map growth - Remove TTL-based cleanup (TTL race with in-flight requests) - Pool entries live until disconnected; stale entries evicted on acquire - Addresses PR openclaw#85462 review feedback from Argus
Add updateMode field to DoctorHealthContribution type. Contributions tagged with updateMode:skip are filtered out when OPENCLAW_UPDATE_IN_PROGRESS=1 is set (update-embedded doctor run). Tagged as skip: sandbox, skills, bootstrap-size, shell-completion, browser, hooks-model, systemd-linger, memory-search, device-pairing, workspace-suggestions. Critical checks (gateway-config, gateway-auth, auth-profiles, state-integrity, security, write-config, etc.) remain unaffected.
When sendMessageTransportPreview calls bot.api.sendMessage() and the API response arrives after forceNewMessage() has incremented generation, the generation mismatch check fires onSupersededPreview WITHOUT retain: true, causing the callback to deleteMessage() the just-delivered message. This is distinct from the issue openclaw#39795 fix (reducing unnecessary forceNewMessage calls in onAssistantMessageStart). Even when forceNewMessage is correctly needed, the in-flight API response can race with generation increment. The other superseded path (text exceeding maxChars) already passes retain: true. This patch adds retain: true to the generation-mismatch path so the delivered message is preserved.
Contributor
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(telegram): retain superseded preview on generation mismatch race in sendMessageTransportPreview This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
This was referenced May 23, 2026
Contributor
Author
This branch had an error being deployed
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
When Telegram preview streaming (
streaming.mode=partial/progress) delivers multiple response segments (e.g., tool progress + final answer text + follow-up), the first streamed message can be silently deleted, leaving the chat with only the second message visible.Symptoms
sendMessage+editMessageText)sendMessagereturned amessage_id), but the user never sees itEnvironment
mainat commit281878e910)partial(default)Root Cause
Race condition in
extensions/telegram/src/draft-stream.ts→sendMessageTransportPreview.Call chain:
sendMessageTransportPreviewis called →bot.api.sendMessage()is in-flight, waiting for Telegram API responseforceNewMessage()is called (fromrotateLaneForNewMessage,rotateAnswerLaneAfterToolProgress,onAssistantMessageStart, or text-splitting paths), which incrementsgenerationmessage_idsendGeneration !== generationevaluates totrueparams.onSupersededPreview?.(...)is called WITHOUTretain: trueonSupersededPreviewcallback (inbot-message-dispatch.ts) executesdeleteMessage(), permanently removing the just-delivered messageContrast with the other superseded path: The text-splitting path (when text exceeds
maxChars) correctly passesretain: trueat draft-stream.ts:220, but the generation-mismatch path at draft-stream.ts:174-179 does not.Related Issue #39795
Issue #39795 was about duplicate messages caused by
forceNewMessage()being called too aggressively inonAssistantMessageStart. That was fixed in v2026.4.22 by reducing unnecessaryforceNewMessage()calls and adding archived-preview finalization.This bug is different: Even when
forceNewMessage()is correctly needed (e.g., legitimate tool-progress → answer-text transition), the race condition between an in-flightsendMessageresponse andgenerationincrement causes the successfully sent message to be deleted. The #39795 fix reduced the frequency of the race but did not eliminate it.Proposed Fix
In
extensions/telegram/src/draft-stream.ts, addretain: trueto theonSupersededPreviewcall in the generation-mismatch block:if (sendGeneration !== generation) { params.onSupersededPreview?.({ messageId: normalizedMessageId, textSnapshot: renderedText, parseMode: renderedParseMode, visibleSinceMs, + retain: true, }); return true; }This prevents the callback from deleting the successfully sent message, matching the behavior already used by the text-splitting superseded path.