Skip to content

feat(services): 新增 QQ OneBot 适配器 (services/qq-bot)#1668

Draft
PhoenixForrestLin wants to merge 31 commits intomoeru-ai:mainfrom
PhoenixForrestLin:feat/qq-bot
Draft

feat(services): 新增 QQ OneBot 适配器 (services/qq-bot)#1668
PhoenixForrestLin wants to merge 31 commits intomoeru-ai:mainfrom
PhoenixForrestLin:feat/qq-bot

Conversation

@PhoenixForrestLin
Copy link
Copy Markdown
Contributor

概述

为 AIRI 新增 QQ 平台支持,基于 OneBot V11 协议,通过 NapLink SDK 以正向 WebSocket 连接 NapCat,采用 7 阶段流水线架构处理消息。

动机

AIRI 目前已有 Telegram 和 Discord 适配器,但缺少 QQ 平台的接入。QQ 拥有大量中文用户群体,本 PR 补齐这一空缺。

架构设计


QQ 实现端 (NapCat) ←→ NapLink Client (正向 WS) → Event Normalizer → Pipeline (7 阶段) → Response Dispatcher

四大模块

  • NapLink Client — 协议连接层,内置心跳、指数退避重连、API 超时控制
  • Event Normalizer — NapLink 层级化事件 → 统一 QQMessageEvent
  • Pipeline — 可配置的 7 阶段链:Filter → Wake → RateLimit → Session → Process → Decorate → Respond
  • Response Dispatcher — 调用 NapLink API 发送响应(消息/合并转发/静默)

流水线阶段

阶段 职责
① Filter 过滤系统号、黑名单、白名单模式、空消息/纯表情
② Wake 唤醒判定:私聊 > @bot > 回复 > 关键词 > 随机
③ RateLimit 三维度滑动窗口限流(session/user/global)+ 冷却
④ Session per-session 环形缓冲区维护消息历史
⑤ Process 命令匹配 → 插件钩子 → LLM 调用(@xsai/generate-text
⑥ Decorate 长消息分割、Markdown → QQ 格式、内容过滤
⑦ Respond NapLink API 发送 + 模拟打字延迟 + 重试

设计原则

  • 规则前置,LLM 后置 — 唤醒判定、频率限制等用规则层前置过滤,节省 token
  • 配置驱动 — 所有行为参数通过 YAML 配置管理,支持 env fallback(YAML > 环境变量 > 默认值)
  • 适配器只做协议转换 — 业务逻辑全部在流水线中处理
  • QQ 一等公民 — 群聊、私聊、戳一戳、@提及、引用回复等 QQ 特有概念原生支持

类型架构亮点

  • MessageSegment — 9 种消息段的 discriminated union,switch(seg.type) 自动窄化
  • Input/Output 分离InputMessageSegment(含 ReplySegment)用于输入侧,OutputMessageSegment(不含)用于输出侧;ReplySegment 仅由 Dispatcher 根据 replyTo 声明式注入
  • ResponsePayloadkind 判别字段强制 message/forward/silent 三分支互斥,工厂函数 fail-fast 校验
  • 循环依赖消除PipelineContextWakeReasonStageResult 抽离到 types/context.ts,打破 event ↔ stage 环路
  • Config via Valibot — 一套 schema 同时产出 TS 类型 + 运行时验证 + 默认值填充
  • 两阶段 LoggercreateLogger() import 时安全调用,initLoggers(config) 后统一刷新级别,支持热重载

群聊上下文持久化

在设计文档的内存环形缓冲区基础上,额外实现了:

  • src/db/ — 基于 sql.js / libsql 的 SQLite 持久化层
    • message-history-repo.ts — 群聊消息历史持久存储
    • conversation-repo.ts — 会话元数据管理
  • src/context/ — 语义检索与上下文压缩
    • embedding-provider.ts — Embedding 生成
    • semantic-retriever.ts — 基于 sqlite-vec 的向量语义检索
    • compressor.ts — 上下文窗口压缩(token 预算内最大化相关信息)
  • src/pipeline/passive-record.ts — 被动记录阶段,所有经过 Filter 的消息均入库
  • src/pipeline/conversation.ts — 会话管理阶段,融合内存缓冲 + DB 持久化 + 语义检索

新增文件

services/qq-bot/
├── src/
│   ├── index.ts                       # 入口
│   ├── config.ts                      # Valibot schema + YAML 加载
│   ├── client.ts                      # NapLink 实例生命周期
│   ├── airi-client.ts                 # AIRI 服务 SDK 客户端
│   ├── agent/
│   │   └── loop.ts                    # Agent 循环
│   ├── types/
│   │   ├── index.ts                   # Barrel export
│   │   ├── context.ts                 # PipelineContext, StageResult, WakeReason
│   │   ├── event.ts                   # QQMessageEvent, EventSource, buildSessionId
│   │   ├── message.ts                 # MessageSegment union + 工具函数
│   │   └── response.ts               # ResponsePayload + 工厂函数
│   ├── normalizer/
│   │   └── index.ts                   # NapLink 事件 → QQMessageEvent
│   ├── dispatcher/
│   │   └── index.ts                   # NapLink API 发送
│   ├── pipeline/
│   │   ├── stage.ts                   # 抽象基类(计时 + 日志)
│   │   ├── extensions.ts              # PipelineExtensions
│   │   ├── runner.ts                  # 流水线执行引擎
│   │   ├── filter.ts                  # ① FilterStage
│   │   ├── wake.ts                    # ② WakeStage
│   │   ├── rate-limit.ts             # ③ RateLimitStage
│   │   ├── session.ts                 # ④ SessionStage
│   │   ├── process.ts                 # ⑤ ProcessStage
│   │   ├── decorate.ts               # ⑥ DecorateStage
│   │   ├── respond.ts                # ⑦ RespondStage
│   │   ├── passive-record.ts         # 被动消息记录
│   │   ├── conversation.ts           # 会话管理(持久化 + 语义检索)
│   │   └── plugins.ts                # 插件钩子
│   ├── commands/
│   │   ├── index.ts, types.ts        # 命令注册表
│   │   ├── help.ts, status.ts, clear.ts
│   ├── db/
│   │   ├── index.ts                   # SQLite 初始化
│   │   ├── message-history-repo.ts   # 消息历史持久化
│   │   └── conversation-repo.ts      # 会话元数据
│   ├── context/
│   │   ├── embedding-provider.ts     # Embedding 生成
│   │   ├── semantic-retriever.ts     # sqlite-vec 语义检索
│   │   └── compressor.ts            # 上下文压缩
│   └── utils/
│       ├── logger.ts                  # 统一日志(两阶段初始化 + 注册表 + 彩色)
│       ├── naplink-logger-adapter.ts  # NapLink Logger 适配
│       ├── message-buffer.ts         # 泛型环形缓冲区
│       ├── rate-limiter.ts           # 滑动窗口 + 冷却追踪器
│       ├── chain-serializer.ts       # 消息链序列化
│       └── token-estimator.ts        # Token 估算
├── config.example.yaml
├── docker-compose.yaml
├── Dockerfile
├── package.json
└── tsconfig.json

依赖

  • @naplink/naplink — NapCat SDK(正向 WS、类型安全、内置重连)
  • @xsai/generate-text + @xsai/shared-chat — OpenAI 兼容 LLM 调用
  • @proj-airi/server-sdk + @proj-airi/server-shared — AIRI 内部 SDK
  • valibot — 配置 schema 验证
  • yaml — YAML 配置解析
  • sql.js + @libsql/client + sqlite-vec — 本地持久化 + 向量检索
  • gpt-tokenizer — Token 计数
  • es-toolkit — 工具函数

致谢

7 阶段流水线架构深受 AstrBot 启发,本适配器是其架构在 QQ OneBot 场景下的精简版。感谢 AstrBot 团队的开源工作 🙏

Copilot AI review requested due to automatic review settings April 15, 2026 13:34
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 15, 2026

⏳ Approval required for deploying to Cloudflare Workers (Preview) for stage-web.

Name Link
🔭 Waiting for approval For maintainers, approve here

Hey, maintainers, kindly take some time to review and approve this deployment when you are available. Thank you! 🙏

@PhoenixForrestLin
Copy link
Copy Markdown
Contributor Author

只有一个commit是我的失误😂,我之前忘记配gitignore了,不小心把API KEY和涉及我隐私的AI聊天记录传进去了,所以后面直接重新fork重新上传了,我发现似乎还有一些环境配置没搞好,我现在解决

@PhoenixForrestLin PhoenixForrestLin marked this pull request as draft April 15, 2026 13:38
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the services/qq-bot service, a QQ OneBot adapter built for Project AIRI. The implementation includes a 7-stage message pipeline, SQLite-based persistence, and integration with the AIRI server. My review identified several areas for improvement: the Dockerfile requires a multi-stage build for production readiness, dependencies should be pinned to avoid breaking changes, and internal library access should be avoided in favor of public APIs. Additionally, I recommended improving type safety by replacing any types with explicit interfaces and correcting language identifiers in documentation.

Comment thread services/qq-bot/Dockerfile Outdated
Comment thread services/qq-bot/README.md Outdated
Comment thread services/qq-bot/README.md Outdated
Comment thread services/qq-bot/package.json Outdated
Comment thread services/qq-bot/src/agent/loop.ts Outdated
Comment thread services/qq-bot/src/airi-client.ts Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new services/qq-bot service to add QQ platform support for AIRI via the OneBot V11 protocol (NapCat + NapLink), implementing a staged pipeline to normalize events, apply rules (wake/rate-limit/context), call AIRI server for LLM replies, and dispatch responses.

Changes:

  • Added a full QQ OneBot adapter service with config loading (Valibot + YAML), logging, NapLink client wiring, and a multi-stage message pipeline.
  • Implemented persistence and context features (SQLite message history, conversation tracking, semantic retrieval + optional compression).
  • Added deployment scaffolding and docs (Dockerfile, docker-compose, example config, README, Copilot instructions).

Reviewed changes

Copilot reviewed 51 out of 52 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
services/qq-bot/tsconfig.json TypeScript compiler configuration for the service.
services/qq-bot/package.json Service package manifest and dependencies (NapLink, libsql, tokenizer, valibot, etc.).
services/qq-bot/Dockerfile Container build for running the service.
services/qq-bot/docker-compose.yaml Compose setup for running the service container.
services/qq-bot/config.example.yaml Example YAML configuration for users.
services/qq-bot/README.md Service documentation and setup guide.
services/qq-bot/.gitignore Ignores local config and data artifacts.
services/qq-bot/.env Local env file placeholder.
services/qq-bot/.github/copilot-instructions.md Service-specific contributor/Copilot guidance.
services/qq-bot/airi-client.ts Root barrel export for src/airi-client.
services/qq-bot/src/index.ts Runtime entrypoint wiring config/logging/db/client/pipeline and graceful shutdown.
services/qq-bot/src/config.ts Valibot schemas + YAML loading + runtime validation/defaults.
services/qq-bot/src/client.ts NapLink client factory and a createBot composition-root style API.
services/qq-bot/src/airi-client.ts AIRI server SDK channel wrapper and event logging hooks.
services/qq-bot/src/normalizer/index.ts NapLink event → internal QQMessageEvent normalization.
services/qq-bot/src/dispatcher/index.ts Converts internal ResponsePayload into NapLink API calls with retry/delay.
services/qq-bot/src/types/index.ts Barrel exports for internal types.
services/qq-bot/src/types/context.ts Pipeline blackboard types (PipelineContext, StageResult, OpenAIMessage, etc.).
services/qq-bot/src/types/event.ts Unified event model QQMessageEvent and sessionId helper.
services/qq-bot/src/types/message.ts Strongly-typed OneBot message segment unions + chain utilities.
services/qq-bot/src/types/response.ts Response payload union + factory helpers + text merging utility.
services/qq-bot/src/pipeline/stage.ts Base stage abstraction (timing/logging/error wrapper).
services/qq-bot/src/pipeline/extensions.ts Typed cross-stage extensions contract and rules.
services/qq-bot/src/pipeline/filter.ts Stage ①: basic filtering (system/bw-list/empty message).
services/qq-bot/src/pipeline/wake.ts Stage ②: wakeup decision (private/@/reply/keyword/random).
services/qq-bot/src/pipeline/rate-limit.ts Stage ③: sliding-window rate limits + cooldown.
services/qq-bot/src/pipeline/session.ts Context injection stage (recent history + semantic retrieval).
services/qq-bot/src/pipeline/conversation.ts Conversation persistence + optional compression + token usage tracking.
services/qq-bot/src/pipeline/process.ts Core stage: commands + send to AIRI server + wait for reply.
services/qq-bot/src/pipeline/decorate.ts Post-processing stage: filtering/replacement/splitting/reply behavior.
services/qq-bot/src/pipeline/respond.ts Final stage that triggers dispatch of context.response.
services/qq-bot/src/pipeline/passive-record.ts Passive capture of message history into memory + DB + embeddings.
services/qq-bot/src/pipeline/plugins.ts Plugin registration/listing for processing hooks.
services/qq-bot/src/pipeline/runner.ts Orchestrates the pipeline stages and dispatch flow.
services/qq-bot/src/db/index.ts SQLite/libsql initialization + schema (history, conversations, embeddings).
services/qq-bot/src/db/message-history-repo.ts Message history repository APIs (insert/query/prune/list).
services/qq-bot/src/db/conversation-repo.ts Conversation repository APIs (create/switch/update/delete/list).
services/qq-bot/src/context/embedding-provider.ts Embedding provider interface + Bailian implementation.
services/qq-bot/src/context/semantic-retriever.ts sqlite-vec retrieval with fallback to brute-force scan.
services/qq-bot/src/context/compressor.ts Context compression (truncate or LLM summary via AIRI channel).
services/qq-bot/src/agent/loop.ts Optional proactive AgentLoop using unread DB history + AIRI decision.
services/qq-bot/src/commands/types.ts Command handler typing.
services/qq-bot/src/commands/index.ts Command registry creation from config enabled list.
services/qq-bot/src/commands/help.ts Built-in help command.
services/qq-bot/src/commands/status.ts Built-in status command.
services/qq-bot/src/commands/clear.ts Built-in clear command (delegates actual clearing to runner flag).
services/qq-bot/src/utils/logger.ts Two-phase logger with registry + optional ANSI colors.
services/qq-bot/src/utils/naplink-logger-adapter.ts Adapts internal logger to NapLink logger interface.
services/qq-bot/src/utils/rate-limiter.ts Sliding window limiter + cooldown tracker utility.
services/qq-bot/src/utils/message-buffer.ts Ring buffer for per-session message history.
services/qq-bot/src/utils/chain-serializer.ts Serializes message segments into single-line context text.
services/qq-bot/src/utils/token-estimator.ts Local token estimation using gpt-tokenizer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/qq-bot/src/pipeline/decorate.ts Outdated
Comment thread services/qq-bot/src/pipeline/rate-limit.ts Outdated
Comment thread services/qq-bot/src/airi-client.ts Outdated
Comment thread services/qq-bot/src/airi-client.ts Outdated
Comment thread services/qq-bot/Dockerfile Outdated
Comment thread services/qq-bot/src/pipeline/filter.ts
Comment thread services/qq-bot/src/pipeline/process.ts Outdated
Comment thread services/qq-bot/src/pipeline/runner.ts Outdated
Comment thread services/qq-bot/README.md
Comment thread services/qq-bot/docker-compose.yaml
@PhoenixForrestLin PhoenixForrestLin marked this pull request as ready for review April 15, 2026 14:02
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9efb7e54a0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread services/qq-bot/src/pipeline/process.ts Outdated
Comment thread services/qq-bot/Dockerfile Outdated
Comment thread services/qq-bot/src/index.ts
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 20bc27d6ea

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread services/qq-bot/src/pipeline/process.ts Outdated
Comment thread services/qq-bot/src/pipeline/wake.ts
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 896352b22d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread services/qq-bot/src/pipeline/wake.ts Outdated
Comment thread services/qq-bot/src/pipeline/process.ts Outdated
Comment thread services/qq-bot/src/context/compressor.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 23348d0a4d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread services/qq-bot/src/pipeline/conversation.ts Outdated
Comment thread services/qq-bot/src/agent/loop.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a7d7999a5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread services/qq-bot/src/pipeline/runner.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 60e53a22e8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread services/qq-bot/tsconfig.json Outdated
Comment thread services/qq-bot/src/db/message-history-repo.ts Outdated
Comment thread services/qq-bot/src/index.ts
@PhoenixForrestLin
Copy link
Copy Markdown
Contributor Author

PhoenixForrestLin commented Apr 16, 2026

我发现给AIRI提供历史聊天数据的时候似乎忘记给他提供时间戳了,导致他只能看到消息的先后顺序没法看到时间
我等PR被merge了以后就开始着手加这个功能,另外还会加一些类似消息引用的优化(自动把被引用的消息填入上下文中,现在我是直接传输NapCat提供的id,需要AIRI自己匹配)

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5038ccf0e0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread services/qq-bot/src/db/message-history-repo.ts Outdated
Comment thread services/qq-bot/src/db/message-history-repo.ts Outdated
@nekomeowww nekomeowww added scope/extension Scope related to extension api, or internally known as tentacle api, mod api, plugin api pr-review/hold/unsure Pull Request that unsure about purpose, not sure if needed priority/nice-to-have Issue, or Pull Request that nice to have but can be handled later labels Apr 16, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5559a805c0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread services/qq-bot/src/pipeline/runner.ts
Comment thread services/qq-bot/Dockerfile Outdated
@PhoenixForrestLin
Copy link
Copy Markdown
Contributor Author

我着手修改一下文档,主要是增加example.config.yaml的内容,对齐config.ts

@PhoenixForrestLin
Copy link
Copy Markdown
Contributor Author

额,搞错了,这个 commit 其实是根据config.ts完善example.config.yaml

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f814f54a73

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +166 to +167
if (event.context.rateLimitPassed)
this.rateLimitStage.startCooldown(event.source.sessionId)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip cooldown when response is silent

ProcessStage explicitly emits createSilentResponse() when AIRI send/reply fails, but PipelineRunner starts the per-session cooldown for every respond action regardless of payload kind. In those failure paths, dispatcher.send() is a no-op, so users receive no message yet their next retry in the same session can be dropped by cooldown, which makes transient AIRI outages look like persistent bot silence. Gate cooldown on non-silent payloads (or successful dispatch of an actual message).

Useful? React with 👍 / 👎.

@PhoenixForrestLin
Copy link
Copy Markdown
Contributor Author

我在想,我的 QQbot 的群聊部分是不是比重太大了
单独看群聊部分的话,AIRI 只提供了一个 LLM 服务,表现远不如 AstrBot 和 MaiBot ,也许我后面的功能中心应该放到私聊上,定位是你不在电脑前面的时候 AIRI 也可以和你对话

@PhoenixForrestLin
Copy link
Copy Markdown
Contributor Author

我觉得我可以砍掉一部分群聊功能,专注做私聊部分

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 32628ff417

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +215 to +216
const decisionSessionId = `${sessionId}${AGENT_SESSION_SUFFIX}`
const prompt = this.buildDecisionPrompt(unread)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use unique correlation IDs for agent-loop decisions

The proactive loop reuses a constant decisionSessionId per session (${sessionId}:agent-loop) and keys pendingReplies by that value, so a delayed response from an earlier timed-out decision can incorrectly resolve a later decision request for the same group. This can make the bot act on stale context (e.g., send or suppress proactive replies based on an old batch) whenever AIRI responses arrive late or out of order. Use a per-request correlation key (and echo it in overrides) instead of a stable per-session key.

Useful? React with 👍 / 👎.

return null

const { prefix, enabled } = commandConfig
const text = event.text.trim()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse commands from chain after removing @bot mentions

WakeStage removes @bot segments from event.chain, but command parsing still uses event.text from raw input. For mention-prefixed commands in groups (for example, users sending @bot /help), text.startsWith(prefix) fails and the command falls through to LLM processing instead of the built-in handler. Command parsing should derive text from the normalized chain (or keep event.text synchronized) so mention cleanup actually affects command detection.

Useful? React with 👍 / 👎.

@PhoenixForrestLin PhoenixForrestLin marked this pull request as draft April 17, 2026 02:46
@PhoenixForrestLin
Copy link
Copy Markdown
Contributor Author

我需要重构一部分代码,对私聊功能做一等公民支持,同时优化聊天记录存储,对话流

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-review/hold/unsure Pull Request that unsure about purpose, not sure if needed priority/nice-to-have Issue, or Pull Request that nice to have but can be handled later scope/extension Scope related to extension api, or internally known as tentacle api, mod api, plugin api

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants