fix(telegram): eliminate BOT_COMMANDS_TOO_MUCH double-log, cap commands at 99, add network retry - #10
Draft
Secret297-CODER-SOURCE with Copilot wants to merge 12 commits into
Draft
Secret297-CODER-SOURCE with Copilot wants to merge 12 commits into
Secret297-CODER-SOURCE with Copilot wants to merge 12 commits into
Conversation
Introduce scoped WorkspaceTools for Telegram agents (createWorkspaceTools) with explicit readable/writable file lists and Anthropic tool definitions. Add an Anthropic tool-calling loop (runAnthropicWithTools) to AiReplyEngine and accept an optional workspaceTools parameter in aiReply; when ANTHROPIC_API_KEY is present, use the tool-calling path (up to 5 iterations) and otherwise fall back to the existing adapter. Update BotAgent and UserBotAgent to create and pass per-agent workspace tools into aiReply so agents can safely read/write their own workspace files. Also adjust the UI file loader to always reload Telegram agent file contents to avoid showing stale/shared cache entries.
Remove the TG_ID pattern from PII_PATTERNS to avoid treating short numeric Telegram IDs as PII. Improve Telegram agent files loading UX: set agentFilesLoading=true when initiating file load to prevent a flash of the "click to load" callout, auto-load files when returning to an already-active Files panel, and import loadTelegramAgentFiles where needed. Update the Files panel UI to show a "Loading files…" state and replace the static callout with a clickable callout button that invokes the provided onLoadFiles handler.
Import loadTelegramAgentFileContent and, when returning to the Telegram Files panel, clear the shared agentFileContents cache and reload the agent's file list. If an active file is selected, also fetch its content so the Files panel doesn't show stale data left over from the main Agents tab. Adds a clarifying comment about the shared cache behavior.
… agent management
…dex.ts - UserBotAgent: add `EntityLike` type import from telegram/define and cast the BigInt peer to silence TS2345; gramjs handles native bigint at runtime - Delete extensions/telegram-manager/src/index.ts — orphaned dead-code file that was never imported, had broken module paths, and contained the Cyrillic identifier character that caused the historical ReferenceError at load time Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
After a network outage, syncTelegramMenuCommands fires during reconnect but the network may still be recovering. Previously this caused alarming error-level log messages for deleteMyCommands and setMyCommands failures. - Add retry loop (up to 5 attempts, exponential backoff) in syncTelegramMenuCommands for recoverable network errors - Suppress error-level logging for intermediate retry attempts; only log on final failure or non-network errors - Suppress deleteMyCommands network error logging (errors were already swallowed but still emitted at error level) - Add optional abortSignal parameter to stop retrying on shutdown - Add 4 new tests covering retry, exhausted retries, deleteMyCommands suppression, and abortSignal handling Co-authored-by: Secret297-CODER-SOURCE <73541046+Secret297-CODER-SOURCE@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Manage webchat connection states in gateway
fix(telegram): retry command sync on recoverable network errors
Mar 13, 2026
…, no retry, no double-log - Add isTelegramBotCommandsTooMuch() helper detecting the 400 GrammyError - Change setMyCommands shouldLog to only log on final attempt for recoverable network errors, preventing double-logging for non-recoverable errors like BOT_COMMANDS_TOO_MUCH - Handle BOT_COMMANDS_TOO_MUCH specifically: emit ONE actionable error message with guidance (channels.telegram.commands.native: false) and return cleanly - Add 2 new tests: single-message handling and no-double-log assertion - Refactor duplicate test error construction into makeBotCommandsTooMuchError() Co-authored-by: Secret297-CODER-SOURCE <73541046+Secret297-CODER-SOURCE@users.noreply.github.com>
Copilot
AI
changed the title
fix(telegram): retry command sync on recoverable network errors
fix(telegram): handle BOT_COMMANDS_TOO_MUCH with single actionable message, suppress retry and double-log
Mar 13, 2026
Copilot
AI
changed the title
fix(telegram): handle BOT_COMMANDS_TOO_MUCH with single actionable message, suppress retry and double-log
fix(telegram): eliminate BOT_COMMANDS_TOO_MUCH double-log, emit single actionable error
Mar 13, 2026
…review Co-authored-by: Secret297-CODER-SOURCE <73541046+Secret297-CODER-SOURCE@users.noreply.github.com>
Copilot
AI
changed the title
fix(telegram): eliminate BOT_COMMANDS_TOO_MUCH double-log, emit single actionable error
fix(telegram): eliminate BOT_COMMANDS_TOO_MUCH double-log, cap commands at 99, add network retry
Mar 13, 2026
Secret297-CODER-SOURCE
force-pushed
the
main
branch
from
April 11, 2026 11:11
7985cb9 to
c652340
Compare
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.
On every gateway start,
setMyCommandscould produce two redundant error lines for the same failure, with no actionable guidance and no retry distinction.Summary
BOT_COMMANDS_TOO_MUCH(GrammyError 400) double-logged on every startup — once fromwithTelegramApiErrorLogging(shouldLog fired for all non-network errors) and again from the outervoid sync().catch(...). No command count cap existed, so any configuration with ≥100 commands hit this on every run.setMyCommands; suppresswithTelegramApiErrorLoggingfor non-recoverable API errors; detectBOT_COMMANDS_TOO_MUCHexplicitly and emit one actionable message then return (no retry, no rethrow). Added exponential-backoff retry for genuine network errors only.deleteMyCommandsbehavior, retry policy shape.Before:
After:
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
BOT_COMMANDS_TOO_MUCHnow surfaces as a single error withchannels.telegram.commands.native: falseguidance instead of two raw GrammyError dumps.setMyCommandsnow retry up to 5× with exponential backoff (3s→60s) before failing; previously they surfaced immediately.Security Impact (required)
Repro + Verification
Environment
channels.telegramconfig with enough native/plugin/custom commands to reach the capSteps
openclaw gateway runExpected
Actual (before fix)
Evidence
10 unit tests in
bot-native-command-menu.test.tscovering: cap enforcement, single-log path, no-retry forBOT_COMMANDS_TOO_MUCH, abort signal, exhausted network retries,deleteMyCommandssuppression.Human Verification (required)
BOT_COMMANDS_TOO_MUCHsingle-log; cap at 99 with overflow warning; no retry on API errors; retry + backoff on network errors; abort signal exits cleanlyBOT_COMMANDS_TOO_MUCHnon-network errors still propagate to outer catch;commandsToRegister.length === 0returns early without callingsetMyCommandsCompatibility / Migration
Failure Recovery (if this breaks)
src/telegram/bot-native-command-menu.tsandsrc/telegram/bot-native-commands.tsBOT_COMMANDS_TOO_MUCHsilently swallowed with no log — confirm the single actionable line still appears on overflowRisks and Mitigations
isTelegramBotCommandsTooMuchstring-matches.description/.message— future grammY error shape changes could miss detection.catch()remains as fallback so undetected shapes still produce"Telegram command sync failed: …"📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.