Skip to content

fix(bot): fix Telegram channel init crash and empty content for Claude#421

Open
ponsde wants to merge 2 commits intovolcengine:mainfrom
ponsde:fix/telegram-init-and-empty-content
Open

fix(bot): fix Telegram channel init crash and empty content for Claude#421
ponsde wants to merge 2 commits intovolcengine:mainfrom
ponsde:fix/telegram-init-and-empty-content

Conversation

@ponsde
Copy link
Contributor

@ponsde ponsde commented Mar 4, 2026

Summary

Fix two bugs that prevent Telegram channel and Claude models from working correctly in vikingbot:

  1. TelegramChannel.init NameError (channels/telegram.py): The super().__init__() call references **kwargs, but kwargs is not defined in the method signature. This causes an immediate NameError when the Telegram channel is instantiated, making it completely unusable. Also fixes the type hint from undefined TelegramConfig to the already-imported TelegramChannelConfig.

  2. Empty content block rejected by Claude (agent/context.py): When the LLM responds with only tool_calls and no text, content is None. The expression content or "" produces an empty string "", which Claude/Anthropic API rejects with 400 Bad Request ("text content blocks must be non-empty"). Fixed by only including the content field when it is non-empty.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Testing

  • Tested Telegram bot end-to-end with Claude (Opus 4-6) via custom API proxy
  • Verified Telegram channel starts without NameError
  • Verified multi-turn conversations with tool calls work on Claude models
  • Confirmed no regression on non-Telegram channels (Feishu pattern unchanged)

Checklist

  • Code follows the project's style guidelines (Ruff, 100 char line width)
  • Changes are minimal and focused on the bug fixes
  • No new dependencies added
  • Tested with real Telegram bot instance

ponsde added 2 commits March 4, 2026 13:03
TelegramChannel.__init__ references **kwargs in super().__init__() call,
but kwargs is not in the method signature. This causes a NameError when
the Telegram channel is instantiated, making it completely unusable.

Also fixes the type hint from undefined TelegramConfig to the correct
TelegramChannelConfig which is already imported.
…bility

When the LLM responds with only tool_calls and no text, content is None.
The expression `content or ""` produces an empty string, which Claude's
API rejects with 400 Bad Request ("text content blocks must be non-empty").

Only include the content field when it is non-empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant