From 5312694f6df8a6c080d86dc3e5785ded7390f4ba Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 5 May 2026 15:07:55 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20bypass=20StreamConsumer=20=E2=80=94=20us?= =?UTF-8?q?e=20direct=20sendFormatted=20for=20reliable=20delivery?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bot/index.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/bot/index.js b/src/bot/index.js index b367ffe4..1547fb03 100644 --- a/src/bot/index.js +++ b/src/bot/index.js @@ -676,13 +676,9 @@ export async function initBot(config, api, tools, skills, agents) { await queueRequest(key, text, async () => { await ctx.api.sendChatAction(ctx.chat.id, 'typing'); - // Create stream consumer for real-time edit-in-place - const consumer = new StreamConsumer(ctx, { editInterval: 1000 }); - const runPromise = consumer.run(); - - // Wrap chatWithAI with self-correction + streaming + // Use self-correction + direct send (streaming disabled for reliability) const chatWithCorrection = withSelfCorrection(async (msgs) => { - return await chatWithAI(msgs, { onDelta: (token) => consumer.onDelta(token) }); + return await chatWithAI(msgs); }); const result = await chatWithCorrection([ @@ -690,13 +686,13 @@ export async function initBot(config, api, tools, skills, agents) { { role: 'user', content: text }, ]); - // Signal completion and wait for final edit - consumer.finish(); - await runPromise; - - // If streaming failed to deliver (no message sent), fallback to plain send - if (!consumer.alreadySent && result) { + // Send formatted response + if (result) { + logger.info(`📤 Sending response (${result.length} chars)`); await sendFormatted(ctx, result); + logger.info('✅ Response delivered'); + } else { + logger.warn('Empty response from AI — nothing to send'); } // ── Self-learning: extract patterns from this interaction ──