feat: stream partial responses via Telegram sendMessageDraft API#123
feat: stream partial responses via Telegram sendMessageDraft API#123nimdraugsael wants to merge 2 commits intoRichardAtCT:mainfrom
Conversation
Stream Claude's tool activity and response text to the user in real-time using Telegram's sendMessageDraft, giving a smooth typing-preview experience in private chats. DraftStreamer accumulates two sections — a tool header (showing tool calls and reasoning snippets as they arrive) and a response body (streamed token-by-token) — and sends throttled drafts that self-disable on API errors for graceful fallback. SDK changes: - Enable --include-partial-messages for token-level StreamEvent deltas (content_block_delta / text_delta) - Handle StreamEvent to emit stream_delta type updates Orchestrator changes: - Feed tool calls and reasoning via append_tool(), response text via append_text() (stream_delta only, to avoid duplication) - Skip progress_msg.edit_text when draft streaming is active New settings: ENABLE_STREAM_DRAFTS, STREAM_DRAFT_INTERVAL 27 tests covering accumulation, throttle, composition, truncation, tool lines, and self-disable behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
PR Review Summary
What looks good
Issues / questions
Suggested tests (if needed)
Verdict — Friday, AI assistant to @RichardAtCT |
Replace hash()-based draft ID with secrets.randbits(30) for cleaner randomness, always populate tool_log as fallback when streamer disables mid-run, add debug logging for flush failures, raise overflow notice threshold to >= 3 lines, and restore missing blank line in settings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
PR Review (incremental — new commit since last review) Summary
What looks good
Issues / questions
Verdict — Friday, AI assistant to @RichardAtCT |
RichardAtCT
left a comment
There was a problem hiding this comment.
LGTM — streaming draft responses via sendMessageDraft is a nice UX improvement. Clean implementation.
|
Merged manually after rebasing to resolve conflicts with voice transcription PR. Included in main. |
Recently Telegram API released support of response streaming for Telegram bots. Attached feature preview from Durov's telegram channel
IMG_2258.MP4
DraftStreamer accumulates two sections — a tool header (showing tool calls and reasoning snippets as they arrive) and a response body (streamed token-by-token) — and sends throttled drafts that self-disable on API errors for graceful fallback.
SDK changes:
Orchestrator changes:
New settings: ENABLE_STREAM_DRAFTS, STREAM_DRAFT_INTERVAL
27 tests covering accumulation, throttle, composition, truncation, tool lines, and self-disable behavior.