Skip to content

[BUG] Agent response is too large for Telegram #62

@auloin

Description

@auloin

What happened?

Reported by @soufianebouaddis: #38 (comment).

Telegram has a 4096 character limit per message. When the agent's answer is higher than the limit, the message is not sent.

Relevant logs

2026-04-22T19:01:36.487+01:00  INFO 80461 --- [JavaClaw] [pool-4-thread-1] a.j.channels.telegram.TelegramChannel    : Voice message received, downloading audio
2026-04-22T19:01:37.191+01:00  INFO 80461 --- [JavaClaw] [pool-4-thread-1] a.j.s.WhisperCppSpeechToTextService      : Transcribing audio via whisper-cpp (model: /Users/snof/whisper-models/ggml-small.bin)
2026-04-22T19:01:38.542+01:00  INFO 80461 --- [JavaClaw] [pool-4-thread-1] a.j.s.WhisperCppSpeechToTextService      : whisper-cpp transcription completed successfully
2026-04-22T19:01:38.543+01:00  INFO 80461 --- [JavaClaw] [pool-4-thread-1] a.j.channels.telegram.TelegramChannel    : Voice message transcribed successfully
2026-04-22T19:02:24.338+01:00  WARN 80461 --- [JavaClaw] [pool-4-thread-1] a.j.channels.telegram.TelegramChannel    : Failed to send HTML parsed message, falling back to raw text.

Exception in thread "pool-4-thread-1" java.lang.RuntimeException: Failed to send both HTML and fallback messages
	at ai.javaclaw.channels.telegram.TelegramChannel.sendMessage(TelegramChannel.java:136)
	at ai.javaclaw.channels.telegram.TelegramChannel.consume(TelegramChannel.java:100)
	at org.telegram.telegrambots.longpolling.util.LongPollingSingleThreadUpdateConsumer.lambda$consume$0(LongPollingSingleThreadUpdateConsumer.java:15)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1090)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:614)
	at java.base/java.lang.Thread.run(Thread.java:1474)
Caused by: Error executing org.telegram.telegrambots.meta.api.methods.send.SendMessage query: [400] Bad Request: message is too long
	at org.telegram.telegrambots.meta.api.methods.botapimethods.PartialBotApiMethod.deserializeResponseInternal(PartialBotApiMethod.java:63)
	at org.telegram.telegrambots.meta.api.methods.botapimethods.PartialBotApiMethod.deserializeResponse(PartialBotApiMethod.java:43)
	at org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodMessage.deserializeResponse(BotApiMethodMessage.java:24)
	at org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodMessage.deserializeResponse(BotApiMethodMessage.java:17)
	at org.telegram.telegrambots.client.okhttp.OkHttpFutureCallback.onResponse(OkHttpFutureCallback.java:35)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:531)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions