Bot channel code is split into two layers:
BotsService owns product semantics: config, binding, authorization, workspace scope, command routing, task creation/resume, permission responses, elicitation responses, reply formatting, broadcasts, and persisted bot state.The split keeps provider-specific event loops out of botsService.ts while preserving the same BotInboundMessage callback pipeline.
telegramChannelRuntime.ts
getUpdates long polling.{ ok: false } result leaves the update retryable.weixinChannelRuntime.ts
getupdates long polling.get_updates_buf only after every message in the batch returns a successful business callback result. A rejected callback or { ok: false } result leaves the batch retryable.feishuChannelRuntime.ts
processProviderCallback(provider, payload) before business handling.bot-channel-continuous; this split must not opt bot channels into mobile replayable recovery semantics.BotsDialog can show the same provider status messages as before..pending staging entry are directories; when Windows reports EPERM (and POSIX reports EISDIR) for the staging-directory rename because the published directory already exists, acquisition must enter the same owner/lease conflict path as EEXIST/ENOTEMPTY rather than surface a permanent lock error. Stale directory cleanup and owner release use bounded retries for transient Windows EPERM/EBUSY/ENOTEMPTY errors.card.raw; the callback pipeline must not also write the same card through REST or message PATCH. A rejected callback or { ok: false } result must reject the handler so the provider can expose a retryable failure.createSession first, then capability-checked model/mode/thought configuration, then sendText. The v4 create command must carry the same resolved mcpServers used by the legacy session create path so desktop-continuous, Bot, and remote entry points start equivalent runtimes. It must not create the empty session through the legacy session operation, because the following v4 input ledger requires the v4 draft persistence state. Attachment delivery keeps the existing attachment-capable send fallback after the same v4 draft creation.sendText command ID. The ID comes from the provider message identity: Bot ID, provider, chat or user ID, and provider message ID. This is the same key as the inbound delivery dedupe. The in-memory dedupe lasts only two minutes, so it only stops short repeats. The CLI command ledger is the durable idempotency point. When the provider delivers the same message again, the CLI answers from that ledger and does not create a second queued input: duplicate for an input that is queued or executed, and failed for an input that was discarded or cancelled. This applies when the dedupe window is over, when a cursor or offset was not committed, and after a host restart. A message without a provider message ID keeps a random command ID. A message with attachments also keeps a random command ID: it still uses the legacy session/send path, which does not deduplicate by input ID, so a fixed ID there gives no protection and would let two turns share one input ID.resumed and prompt_sent. These states normally end with the turn's terminal event. A duplicate ACK starts no turn, so no terminal event follows. sendPrompt therefore returns the v4 ACK. On duplicate, the Bot reads the authoritative CLI task snapshot with the same idle rule as the task-switch check. When the task is idle (completed or error), the Bot clears the running mark and the IM trace, stops typing (including the Feishu typing reaction), and broadcasts completed. When the task is still running or has queued work, the Bot keeps these states, because the running turn's terminal event clears them. This uses no timeout and does not wait for the next message. A legacy or remote runtime that returns no ACK keeps the previous behavior.warn log. The log has the Bot ID, the count of consecutive failures, the next retry delay, and the error message. The retry delay starts at 5 seconds and doubles after each consecutive failure, up to 5 minutes. A fully committed batch resets the count. The runtime never skips the failed batch and never stops the Bot because of this backoff. HTTP status failures and invalid-response failures from Telegram getUpdates keep their existing fixed delays.2026-11-10 incident: a private Weixin message was executed again every two minutes for about 23 hours. The
get_updates_bufwas not committed, sogetupdatesdelivered the same message again. After the Bot's own turn had ended, the Bot no longer rejected new private messages as "task running". Each later delivery came after the two-minute in-memory dedupe had expired, and each one got a new randomsendTextcommand ID. Each delivery was therefore admitted as a new queued input. The failure that stopped the cursor commit was not logged.
resolveInteraction ACK as their business commit point. Persisted Bot state must remain retryable until that ACK succeeds; a transport callback or provider-card update is not a business acknowledgement./getupdates keeps a 90-second idle window and remains cancellable by runtime disposal/config refresh.