[PR #5] Enhance channel_ai_bot with history context and auto-reconnect #5

Open
opened 2026-10-18 14:01:38 +00:00 by bsakaguchi · 0 comments
Owner

📋 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)

  • c8ae8ea Add Open WebUI channel AI bot example
  • e58bbd4 Enhance channel AI bot with history context and auto-reconnect
  • 311a7c1 Fix reconnect backoff reset and silent history fetch failure
  • 920b3f5 Remove 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.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/bot/pull/5 **Author:** [@shanw4](https://github.com/shanw4) **Created:** 3/12/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `channel-ai-example` --- ### 📝 Commits (4) - [`c8ae8ea`](https://github.com/open-webui/bot/commit/c8ae8eac08b7df38b2e2c96fca326174985cc152) Add Open WebUI channel AI bot example - [`e58bbd4`](https://github.com/open-webui/bot/commit/e58bbd454196261519cdff88b2bb2da9484790c5) Enhance channel AI bot with history context and auto-reconnect - [`311a7c1`](https://github.com/open-webui/bot/commit/311a7c1b61e9c8bd74dc44a3a23e1013ce5213de) Fix reconnect backoff reset and silent history fetch failure - [`920b3f5`](https://github.com/open-webui/bot/commit/920b3f5e16b6a01bae4758dda5a948f2286c5e4f) Remove CLAUDE.md from example (development-only file) ### 📊 Changes **1 file changed** (+233 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `examples/channel_ai_bot.py` (+233 -0) </details> ### 📄 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
open-webui/bot#5
No description provided.