[FIX] telegram: don't abort remaining chunks when one chunk fails; greppable send-status log lines#240
Open
MartinEbner wants to merge 1 commit into
Conversation
MartinEbner
force-pushed
the
feature/telegram-send-hardening
branch
2 times, most recently
from
July 10, 2026 22:59
ab0fc4a to
eb1825a
Compare
…ppable send-status log lines Previously a failed chunk in a multi-chunk message aborted all remaining chunks with a single log line, so the tail of long messages was silently dropped and delivery status was hard to diagnose from the log. Now (all through the structured logger, src.logger): - a failed chunk is logged ([SEND_FAIL] chunk=K/N err=..., with traceback via logger.exception) and the remaining chunks are still attempted — partial delivery with a diagnosable log beats silently dropping the rest - after a failed chunk, pause 1s before the remaining chunks (the most likely failure is a rate limit; do not hammer the API) - every send ends with a greppable summary line: [SEND_OK] chunks=N chars=M (info), [SEND_PARTIAL] ok=N fail=M chars=K (warning), or [SEND_FAIL] ok=0 fail=N chars=M (error) when every chunk failed - unbound/disconnected sends log [SEND_SKIP] connected=... bound=... (warning) instead of dropping the message with no trace Adds Autotests/unit/test_telegram_send_chunking.py — in-process unit tests in the mock_websocket/test_wschat_unit.py pattern (module loaded by file path, _api_call stubbed, caplog assertions; no container/network/token) — and wires it into Autotests/run_mandatory so CI executes it: pytest Autotests/unit/test_telegram_send_chunking.py
MartinEbner
force-pushed
the
feature/telegram-send-hardening
branch
from
July 10, 2026 23:13
eb1825a to
fb04aef
Compare
This was referenced Jul 11, 2026
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.
Two small robustness fixes to the Telegram send path, no behavior change on the happy path. Rebased onto current
main; the new log lines go through the structured logger (src.logger) introduced in #226.1. A failed chunk no longer aborts the remaining chunks.
send_messagesplitslong messages at 3900 chars, but any chunk failure
returned out of the loop, sothe tail of a long multi-chunk message was silently dropped. Now the failed chunk
is logged (
logger.exception, so the traceback is kept), the sender pauses 1s(the most likely chunk failure is a rate limit — don't hammer the API), and the
remaining chunks are still attempted — partial delivery with a diagnosable log
beats silently losing the rest. (Related community pain: the long-running
truncated/multi-send-failure reports in the ASI Alliance channel.)
2. Greppable delivery-status log lines. Every send now ends with a summary,
and skipped/failed sends leave a trace:
This makes "did my message actually go out?" answerable from the log — useful
both for operators and for the agent-side self-verification patterns the
community has been building (send-then-verify).
Tests:
Autotests/unit/test_telegram_send_chunking.py— in-process unittests following the
mock_websocket/test_wschat_unit.pypattern (module loadedby file path,
_api_callstubbed,caplogassertions; no container, network,or token needed), wired into
Autotests/run_mandatoryso CI executes them:[SEND_OK][SEND_FAIL]+[SEND_PARTIAL][SEND_FAIL] ok=0summary instead of claiming partial delivery[SEND_SKIP]Run:
pytest Autotests/unit/test_telegram_send_chunking.pyPossible follow-up (not in this PR to keep it minimal): a single retry per failed
chunk (honoring 429
retry_after) before counting it as failed — the send-pathanalogue of what #18 proposes for LLM-provider 429s.