mirror of
https://github.com/open-webui/bot.git
synced 2026-11-05 01:17:46 +00:00
[PR #5] Enhance channel_ai_bot with history context and auto-reconnect #5
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
open-webui/bot#5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/bot/pull/5
Author: @shanw4
Created: 3/12/2026
Status: 🔄 Open
Base:
main← Head:channel-ai-example📝 Commits (4)
c8ae8eaAdd Open WebUI channel AI bot examplee58bbd4Enhance channel AI bot with history context and auto-reconnect311a7c1Fix reconnect backoff reset and silent history fetch failure920b3f5Remove CLAUDE.md from example (development-only file)📊 Changes
1 file changed (+233 additions, -0 deletions)
View changed files
➕
examples/channel_ai_bot.py(+233 -0)📄 Description
This PR extends the channel_ai_bot example with two improvements:
Channel history context
The bot now fetches the last 50 messages from the channel before responding and includes them in the system prompt. This allows the AI to reference and cite prior discussion, making it significantly more useful in active team channels.
Auto-reconnect with exponential backoff
The original implementation had a silent reliability bug: after a socket disconnect, the bot would reconnect the socket but not re-send the user-join authentication event. The server would accept the connection but stop routing events:channel events to it, leaving the
bot silently deaf until a full process restart.
This PR replaces the single connect/wait cycle with a loop that re-authenticates on every reconnect, with exponential backoff (5s → 10s → ... → 5 min cap) to avoid hammering a temporarily unavailable server.
Tested against Open WebUI 0.5.10.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.