Skip to content

fix(channels): deliver long Telegram and Discord replies - #117

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/high-severity-issues-09da
Closed

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/high-severity-issues-09da

Conversation

@cursor

@cursor cursor Bot commented Oct 13, 2026

Copy link
Copy Markdown

Bug and impact

Agent replies longer than the chat platform limit were not delivered.

  • Telegram sendMessage accepts at most 4096 characters. tg_send treated any completed curl transfer as success, including HTTP 400 message is too long and HTTP 200 bodies with "ok": false. handle_message then acked the cron job, so a one-shot job was deleted and a recurring job advanced even though the user never received the text.
  • Discord REST messages are limited to 2000 characters. discord_send returned an error before posting when the reply was longer. The cron job was not acked, so the agent ran the same job again on every poll and the Discord user still saw nothing.

A normal agent answer is allowed to be up to 32 KiB (RESPONSE_BUF_SIZE), so both paths are hit by ordinary long answers.

Root cause

Outbound send did not split text to the platform limit. Telegram also ignored the Bot API ok field and HTTP status.

Fix

  • Split outbound text on UTF-8 boundaries at 4096 bytes (Telegram) and 2000 bytes (Discord), then send each piece.
  • Treat a Telegram send as delivered only when the HTTP status is 2xx and the JSON body has "ok": true.

Validation

make test_channel test_telegram

18 channel tests and 41 telegram tests passed. src/channels/discord.c compiles with SHELLCLAW_GATEWAY.

Open in Web聽View Automation聽

Telegram treated a finished sendMessage as success, so an HTTP 400
for a reply over 4096 characters still acked cron and the user never
saw the text. Discord refused the whole reply above 2000 characters,
so the send failed and a due cron job re-ran the agent on every poll.

Co-authored-by: esadrianno <esadrianno@gmail.com>
@adriannoes

Copy link
Copy Markdown
Collaborator

Superseded by #123: consolidated into the operator-authored branch fix/channels-telegram-discord (same fixes, re-validated with make test_telegram, make test_channel, CI=true make test, make static). Closing in favor of the consolidation.

@adriannoes adriannoes closed this Oct 16, 2026
@adriannoes
adriannoes deleted the cursor/high-severity-issues-09da branch October 16, 2026 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants