Skip to content

Enhance channel_ai_bot with history context and auto-reconnect#5

Open
shanw4 wants to merge 4 commits into
open-webui:mainfrom
shanw4:channel-ai-example
Open

Enhance channel_ai_bot with history context and auto-reconnect#5
shanw4 wants to merge 4 commits into
open-webui:mainfrom
shanw4:channel-ai-example

Conversation

@shanw4
Copy link
Copy Markdown

@shanw4 shanw4 commented Mar 12, 2026

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.

Shannon Young and others added 4 commits March 12, 2026 22:29
- Fetch last 50 channel messages and include as context in the system
  prompt so the AI can reference and cite prior discussion
- Add auto-reconnect loop with exponential backoff so the bot recovers
  from disconnects without manual intervention
- Re-send user-join auth on every reconnect (fixes silent deaf-socket
  bug where the old version reconnected but stopped receiving events)
- Add CLAUDE.md with project overview and architecture notes
- Reset exponential backoff delay to 5s after a successful connection
  so long-running bots don't wait up to 5 minutes after a clean reconnect
- Log HTTP status when channel history fetch fails instead of silently
  returning an empty list
@shanw4 shanw4 changed the title Add Open WebUI channel AI bot example Enhance channel_ai_bot with history context and auto-reconnect Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant