whatevertogo 3fd6c4c8a6 fix: 修复 asyncio 事件循环相关问题 (#5774)
* fix: 修复 asyncio 事件循环相关的问题

1. components.py: 修复异常处理结构错误
   - 将 except Exception 移到正确的内部 try 块
   - 确保 _download_file() 异常能被正确捕获和记录

2. session_lock.py: 修复跨事件循环 Lock 绑定问题
   - 添加 _access_lock_loop_id 追踪事件循环
   - 当事件循环变化时重新创建 Lock

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: 根据代码审查反馈修复问题

1. components.py: 移除 asyncio.set_event_loop() 调用
   - 创建临时 event loop 时不再设置为全局
   - 避免干扰其他 asyncio 使用

2. session_lock.py: 简化延迟初始化逻辑
   - 移除 loop-ID 追踪和 _get_lock 方法
   - 使用 setdefault 简化 session lock 创建
   - 保留延迟初始化行为

3. wecomai_queue_mgr.py: 使用 time.monotonic() 替代 loop.time()
   - 同步方法不再依赖活动的 event loop
   - 避免在非异步上下文中抛出 RuntimeError

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: 优化 asyncio 事件循环管理,使用安全的方式创建和关闭事件循环

* fix: 根据代码审查反馈改进异常处理和事件循环使用

- main.py: 显式处理 check_dashboard_files() 返回 None 的情况
- components.py: 使用 logger.exception 保留异常堆栈信息
- star_manager.py: 添加 Future 异常回调处理 __del__ 执行异常
- bay_manager.py: 缓存事件循环引用避免重复调用

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor: 简化 SessionLockManager 使用 defaultdict 和 setdefault

- 使用 defaultdict(asyncio.Lock) 简化锁的懒创建
- 使用 setdefault 简化 _get_loop_state 逻辑
- 减少 get + if 分支,提升可读性

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: 降低 webui_dir 检查失败时的日志级别为 warning

改为警告而非退出,允许程序在无 WebUI 的情况下继续运行

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor: 重构事件循环锁管理,简化锁状态管理逻辑

* 新增对 SessionLockManager 的多事件循环隔离测试

* fix: 修复测试中的变量声明和断言,确保事件循环管理器的正确性

* fix: 修复插件删除时异常处理逻辑,确保正确记录错误信息

* fix: 新增针对多个事件循环的 OneBot 实例的测试,确保锁对象在不同事件循环间不共享

---------

Co-authored-by: whatevertogo <whatevertogo@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 01:00:13 +09:00
2026-03-05 16:10:09 +08:00
2023-04-15 15:33:00 +08:00
2026-01-13 12:19:05 +08:00
2025-02-24 00:31:57 +08:00
2026-02-21 17:20:26 +08:00
2026-03-05 16:10:09 +08:00

AstrBot-Logo-Simplified

AstrBot is an open-source all-in-one Agent chatbot platform that integrates with mainstream instant messaging apps. It provides reliable and scalable conversational AI infrastructure for individuals, developers, and teams. Whether you're building a personal AI companion, intelligent customer service, automation assistant, or enterprise knowledge base, AstrBot enables you to quickly build production-ready AI applications within your IM platform workflows.

screenshot_1 5x_postspark_2026-02-27_22-37-45

Key Features

  1. 💯 Free & Open Source.
  2. AI LLM Conversations, Multimodal, Agent, MCP, Skills, Knowledge Base, Persona Settings, Auto Context Compression.
  3. 🤖 Supports integration with Dify, Alibaba Cloud Bailian, Coze, and other agent platforms.
  4. 🌐 Multi-Platform: QQ, WeChat Work, Feishu, DingTalk, WeChat Official Accounts, Telegram, Slack, and more.
  5. 📦 Plugin Extensions with 1000+ plugins available for one-click installation.
  6. 🛡️ Agent Sandbox for isolated, safe execution of code, shell calls, and session-level resource reuse.
  7. 💻 WebUI Support.
  8. 🌈 Web ChatUI Support with built-in agent sandbox and web search.
  9. 🌐 Internationalization (i18n) Support.

💙 Role-playing & Emotional Companionship Proactive Agent 🚀 General Agentic Capabilities 🧩 1000+ Community Plugins

99b587c5d35eea09d84f33e6cf6cfd4f

c449acd838c41d0915cc08a3824025b1

image

image

Quick Start

One-Click Deployment

For users who want to quickly experience AstrBot, are familiar with command-line usage, and can install a uv environment on their own, we recommend the uv one-click deployment method :

uv tool install astrbot
astrbot init # Only execute this command for the first time to initialize the environment
astrbot

Requires uv to be installed.

Note

For macOS user: due to macOS security checks, the first run of the astrbot command may take longer (about 10-20s).

Update astrbot:

uv tool upgrade astrbot

Docker Deployment

For users familiar with containers and looking for a more stable, production-ready deployment method, we recommend deploying AstrBot with Docker / Docker Compose.

Please refer to the official documentation: Deploy AstrBot with Docker.

Deploy on RainYun

For users who want one-click deployment and do not want to manage servers themselves, we recommend RainYun's one-click cloud deployment service ☁️:

Deploy on RainYun

Desktop Application Deployment

For users who want to use AstrBot on desktop and mainly use ChatUI, we recommend AstrBot App.

Visit AstrBot-desktop to download and install; this method is designed for desktop usage and is not recommended for server scenarios.

Launcher Deployment

For desktop users who also want fast deployment and isolated multi-instance usage, we recommend AstrBot Launcher.

Visit AstrBot Launcher to download and install.

Deploy on Replit

Replit deployment is maintained by the community and is suitable for online demos and lightweight trials.

Run on Repl.it

AUR

AUR deployment targets Arch Linux users who prefer installing AstrBot through the system package workflow.

Run the command below to install astrbot-git, then start AstrBot in your local environment.

yay -S astrbot-git

More deployment methods

If you need panel-based management or deeper customization, see BT-Panel Deployment for BT Panel app-store setup, 1Panel Deployment for 1Panel app-market deployment, CasaOS Deployment for NAS/home-server visual deployment, and Manual Deployment for fully custom source-based installation with uv.

Supported Messaging Platforms

Connect AstrBot to your favorite chat platform.

Platform Maintainer
QQ Official
OneBot v11 protocol implementation Official
Telegram Official
Wecom & Wecom AI Bot Official
WeChat Official Accounts Official
Feishu (Lark) Official
DingTalk Official
Slack Official
Discord Official
LINE Official
Satori Official
Misskey Official
WhatsApp (Coming Soon) Official
Matrix Community
KOOK Community
VoceChat Community

Supported Model Services

Service Type
OpenAI and Compatible Services LLM Services
Anthropic LLM Services
Google Gemini LLM Services
Moonshot AI LLM Services
Zhipu AI LLM Services
DeepSeek LLM Services
Ollama (Self-hosted) LLM Services
LM Studio (Self-hosted) LLM Services
AIHubMix LLM Services (API Gateway, supports all models)
CompShare LLM Services
302.AI LLM Services
TokenPony LLM Services
SiliconFlow LLM Services
PPIO Cloud LLM Services
ModelScope LLM Services
OneAPI LLM Services
Dify LLMOps Platforms
Alibaba Cloud Bailian Applications LLMOps Platforms
Coze LLMOps Platforms
OpenAI Whisper Speech-to-Text Services
SenseVoice Speech-to-Text Services
OpenAI TTS Text-to-Speech Services
Gemini TTS Text-to-Speech Services
GPT-Sovits-Inference Text-to-Speech Services
GPT-Sovits Text-to-Speech Services
FishAudio Text-to-Speech Services
Edge TTS Text-to-Speech Services
Alibaba Cloud Bailian TTS Text-to-Speech Services
Azure TTS Text-to-Speech Services
Minimax TTS Text-to-Speech Services
Volcano Engine TTS Text-to-Speech Services

❤️ Sponsors

sponsors

❤️ Contributing

Issues and Pull Requests are always welcome! Feel free to submit your changes to this project :)

How to Contribute

You can contribute by reviewing issues or helping with pull request reviews. Any issues or PRs are welcome to encourage community participation. Of course, these are just suggestions—you can contribute in any way you like. For adding new features, please discuss through an Issue first.

Development Environment

AstrBot uses ruff for code formatting and linting.

git clone https://github.com/AstrBotDevs/AstrBot
pip install pre-commit
pre-commit install

🌍 Community

QQ Groups

  • Group 9: 1076659624 (New)

  • Group 10: 1078079676 (New)

  • Group 1: 322154837

  • Group 3: 630166526

  • Group 5: 822130018

  • Group 6: 753075035

  • Group 7: 743746109

  • Group 8: 1030353265

  • Developer Group: 975206796

Discord Server

Discord_community

❤️ Special Thanks

Special thanks to all Contributors and plugin developers for their contributions to AstrBot ❤️

Additionally, the birth of this project would not have been possible without the help of the following open-source projects:

Star History

Tip

If this project has helped you in your life or work, or if you're interested in its future development, please give the project a Star. It's the driving force behind maintaining this open-source project <3

Star History Chart

Companionship and capability should never be at odds. What we aim to create is a robot that can understand emotions, provide genuine companionship, and reliably accomplish tasks.

私は、高性能ですから!

S
Description
No description provided
Readme AGPL-3.0 65 MiB
Languages
Python 69.1%
Vue 25.4%
TypeScript 3.4%
JavaScript 1.4%
Shell 0.3%
Other 0.4%