AstrBot icon indicating copy to clipboard operation
AstrBot copied to clipboard

[Bug] qq_official 平台下,未来任务到点后任务会执行并生成提醒文本,但不会主动发送到用户

Open DarkGhast opened this issue 8 months ago • 3 comments

What happened / 发生了什么

在 qq_official 平台下,我通过主动型能力创建未来任务,例如:

“10.40 提醒我检查token”

任务可以被正常创建,并且会出现在“未来任务管理”页面中。到达执行时间后,该任务会从任务列表中消失,说明调度器已经消费了该任务。

我开启 Debug 日志后观察到:

  1. 创建任务阶段正常
  • Agent 成功调用 create_future_task
  • run_at / note / run_once 等参数正确
  • WebUI 中可以看到任务已注册
  • AstrBot 也会正常回复“已为您设置一个在 10:40 提醒检查Token用量的任务”
  1. 到点执行阶段也正常运行了 Agent
  • 到点后日志中可以看到 AgentState.IDLE -> AgentState.RUNNING
  • LLM 成功生成提醒文本,例如: “您的Token用量检查提醒已经到达。如果您需要我帮您检查或提供相关的Token使用情况,请随时告诉我!”
  1. 但是执行完成后,没有进入发送阶段
  • 到点执行时日志中没有出现 respond.stage
  • 也没有出现 qqofficial_message_event 的发送日志
  • 不会出现类似 “Prepare to send” 或 “Message sent to C2C”
  • 最终用户侧没有收到任何提醒消息

Reproduce / 如何复现?

  1. 部署 AstrBot v4.20.0,平台适配器使用 qq_official(WebSockets),提供商使用 openai_chat_completion(SiliconFlow),模型为 Qwen/Qwen3-8B。

  2. 在配置中启用“主动型能力”。

  3. 通过 QQ 私聊机器人发送一条未来提醒,例如: “10.40 提醒我检查token”

  4. 观察到机器人会正常回复“已为您设置一个在 10:40 提醒检查Token用量的任务”,并且该任务会出现在 WebUI 的“未来任务管理”页面中。

  5. 等待到任务执行时间。

  6. 到点后,任务会从“未来任务管理”页面中消失,但用户不会收到任何主动提醒消息。

  7. 开启 Debug 日志后可以看到:

    • create_future_task 调用成功
    • 到点后 Agent 正常运行
    • LLM 成功生成提醒文本
    • 但没有进入 respond.stage,也没有出现 qqofficial_message_event 的发送日志,最终没有消息发送到用户

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

AstrBot v4.20.0

部署方式: 腾讯云 Linux 服务器,宝塔面板 Docker 应用商店部署(底层为 Docker Compose)

使用的提供商: openai_chat_completion(通过 SiliconFlow) 当前模型:Qwen/Qwen3-8B

使用的消息平台适配器: QQ 官方机器人(WebSockets)

OS

Linux

Logs / 报错日志

日志内容由AI脱敏,如果有关键信息遗漏,我可以在重启容器后触发以提供干净的日志

[2026-03-13 10:34:39.293] [Core] [INFO] [AstrBot.main:117]: ___ _... . ______ .___________. / \ / | || _ \ | _ \ / __ \ | | / ^ \ | (-------| |----| |) | | |) | | | | | ---| |---- / /\ \ \ \ | | | / | _ < | | | | | | / _____ \ .----) | | | | |\ ----.| |) | | --' | | | /__/ \__\ |_______/ |__| | _| .||/ ____/ ||

[2026-03-13 10:34:39.294] [Core] [DBUG] [core.core_lifecycle:80]: HTTP proxy cleared [2026-03-13 10:34:39.294] [Core] [INFO] [core.core_lifecycle:106]: AstrBot v4.20.0 [2026-03-13 10:34:39.373] [Core] [INFO] [core.persona_mgr:38]: 已加载 0 个人格。 [2026-03-13 10:34:39.380] [Core] [INFO] [star.star_manager:744]: 正在载入插件 astrbot ... [2026-03-13 10:34:39.383] [Core] [INFO] [star.star_manager:828]: Plugin astrbot (4.1.0) by Soulter: AstrBot 自带插件,包含人格注入、思考内容注入、群聊上下文感知等功能的实现,禁用后将无法使用这些功能。 [2026-03-13 10:34:39.383] [Core] [INFO] [star.star_manager:744]: 正在载入插件 builtin_commands ... [2026-03-13 10:34:39.391] [Core] [INFO] [star.star_manager:828]: Plugin builtin_commands (0.0.1) by Soulter: AstrBot 自带指令,提供常用的对话管理、工具使用、插件管理等功能。 [2026-03-13 10:34:39.391] [Core] [INFO] [star.star_manager:744]: 正在载入插件 session_controller ... [2026-03-13 10:34:39.395] [Core] [INFO] [star.star_manager:828]: Plugin session_controller (v1.0.1) by Cvandia & Soulter: 为插件支持会话控制 [2026-03-13 10:34:39.395] [Core] [INFO] [star.star_manager:744]: 正在载入插件 web_searcher ... [2026-03-13 10:34:39.496] [Core] [INFO] [provider.func_tool_manager:304]: 添加函数调用工具: web_search [2026-03-13 10:34:39.504] [Core] [INFO] [provider.func_tool_manager:304]: 添加函数调用工具: fetch_url [2026-03-13 10:34:39.515] [Core] [INFO] [provider.func_tool_manager:304]: 添加函数调用工具: web_search_tavily [2026-03-13 10:34:39.523] [Core] [INFO] [provider.func_tool_manager:304]: 添加函数调用工具: tavily_extract_web_page [2026-03-13 10:34:39.533] [Core] [INFO] [provider.func_tool_manager:304]: 添加函数调用工具: web_search_bocha [2026-03-13 10:34:39.535] [Core] [INFO] [star.star_manager:828]: Plugin astrbot-web-searcher (1.14.514) by Soulter: 让 LLM 具有网页检索能力 [2026-03-13 10:34:39.540] [Core] [INFO] [provider.manager:521]: Provider deepseek/deepseek-chat is disabled, skipping [2026-03-13 10:34:39.540] [Core] [INFO] [provider.manager:521]: Provider deepseek/deepseek-reasoner is disabled, skipping [2026-03-13 10:34:39.540] [Core] [INFO] [provider.manager:526]: 载入 openai_chat_completion(siliconflow/THUDM/GLM-4.1V-9B-Thinking) 服务提供商 ... [2026-03-13 10:34:39.559] [Core] [DBUG] [provider.register:50]: 服务提供商 Provider openai_chat_completion 已注册 [2026-03-13 10:34:39.783] [Core] [INFO] [provider.manager:526]: 载入 openai_chat_completion(siliconflow/Qwen/Qwen3-8B) 服务提供商 ... [2026-03-13 10:34:39.792] [Core] [INFO] [provider.manager:630]: 已选择 openai_chat_completion(siliconflow/Qwen/Qwen3-8B) 作为当前提供商适配器。 [2026-03-13 10:34:39.793] [Core] [INFO] [provider.manager:526]: 载入 openai_chat_completion(siliconflow/THUDM/GLM-4-9B-0414) 服务提供商 ... [2026-03-13 10:34:39.809] [Core] [INFO] [knowledge_base.kb_mgr:40]: 正在初始化知识库模块... [2026-03-13 10:34:39.824] [Core] [INFO] [knowledge_base.kb_mgr:66]: KnowledgeBase database initialized: /AstrBot/data/knowledge_base/kb.db [2026-03-13 10:34:39.996] [Core] [INFO] [platform.manager:125]: 载入 qq_official(default) 平台适配器 ... [2026-03-13 10:34:40.015] [Core] [DBUG] [platform.register:60]: 平台适配器 qq_official 已注册 [2026-03-13 10:34:40.102] [Core] [INFO] [dashboard.server:331]: 正在启动 WebUI, 监听地址: http://0.0.0.0:6185 [2026-03-13 10:34:40.103] [Core] [INFO] [dashboard.server:333]: 提示: WebUI 将监听所有网络接口,请注意安全。(可在 data/cmd_config.json 中配置 dashboard.host 以修改 host) [2026-03-13 10:34:40.103] [Core] [INFO] [dashboard.server:370]: ✨✨✨ AstrBot v4.20.0 WebUI 已启动,可访问

➜ 本地: http://localhost:6185 ➜ 网络: http://127.0.0.1:6185 ➜ 网络: http://<CONTAINER_IP>:6185 ➜ 默认用户名和密码: astrbot ✨✨✨ [2026-03-13 10:34:40.105] [Core] [INFO] [core.core_lifecycle:297]: AstrBot 启动完成。 [2026-03-13 10:34:40.113] [Core] [INFO] [utils.temp_dir_cleaner:127]: TempDirCleaner started. interval=600s cleanup_ratio=0.3 [2026-03-13 10:34:40.619] [Core] [INFO] [t2i.network_strategy:56]: Successfully got 2 official T2I endpoints. [2026-03-13 10:34:41.231] [Core] [INFO] [utils.llm_metadata:63]: Successfully fetched metadata for 2094 LLMs.

[2026-03-13 10:35:11.242] [Core] [INFO] [core.event_bus:66]: [<BOT_NAME>] [default(qq_official)] <USER_SESSION_ID>: [At:qq_official] 10.40 提醒我检查token [2026-03-13 10:35:11.243] [Core] [DBUG] [waking_check.stage:157]: enabled_plugins_name: ['*'] [2026-03-13 10:35:11.248] [Core] [DBUG] [method.star_request:44]: plugin -> session_controller - handle_session_control_agent [2026-03-13 10:35:11.249] [Core] [DBUG] [method.star_request:44]: plugin -> session_controller - handle_empty_mention [2026-03-13 10:35:11.249] [Core] [DBUG] [method.star_request:44]: plugin -> astrbot - on_message [2026-03-13 10:35:11.252] [Core] [DBUG] [agent_sub_stages.internal:166]: ready to request llm provider [2026-03-13 10:35:11.252] [Core] [DBUG] [agent_sub_stages.internal:185]: acquired session lock for llm request [2026-03-13 10:35:11.304] [Core] [DBUG] [core.astr_main_agent_resources:445]: [知识库] 使用全局配置,知识库数量: 0 [2026-03-13 10:35:11.304] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnLLMRequestEvent) -> astrbot - decorate_llm_req [2026-03-13 10:35:11.305] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnLLMRequestEvent) -> astrbot-web-searcher - edit_web_search_tools [2026-03-13 10:35:11.305] [Core] [DBUG] [runners.base:64]: Agent state transition: AgentState.IDLE -> AgentState.RUNNING [2026-03-13 10:35:11.305] [Core] [DBUG] [runners.tool_loop_agent_runner:297]: [BefCompact] RunCtx.messages -> [36] system,user,assistant,user,assistant,user,assistant,user,assistant,user,assistant,user,assistant,user,assistant,tool,assistant,user,assistant,tool,assistant,user,assistant,user,assistant,tool,assistant,user,assistant,user,assistant,tool,assistant,user,assistant,user [2026-03-13 10:35:11.306] [Core] [DBUG] [runners.tool_loop_agent_runner:297]: [AftCompact] RunCtx.messages -> [36] system,user,assistant,user,assistant,user,assistant,user,assistant,user,assistant,user,assistant,user,assistant,tool,assistant,user,assistant,tool,assistant,user,assistant,user,assistant,tool,assistant,user,assistant,user,assistant,tool,assistant,user,assistant,user [2026-03-13 10:35:16.959] [Core] [DBUG] [sources.openai_source:262]: completion: ChatCompletion(id='<CHAT_COMPLETION_ID_1>', choices=[Choice(finish_reason='tool_calls', index=0, logprobs=None, message=ChatCompletionMessage(content='', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=[ChatCompletionMessageFunctionToolCall(id='<TOOL_CALL_ID>', function=Function(arguments='{"run_at": "2026-03-13T10:40:00+08:00", "note": "提醒检查Token用量", "run_once": true, "name": "Check Token Usage at 10:40"}', name='create_future_task'), type='function')]))], created=1773369311, model='Qwen/Qwen3-8B', object='chat.completion', service_tier=None, system_fingerprint='', usage=CompletionUsage(completion_tokens=75, prompt_tokens=3580, total_tokens=3655, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=None, audio_tokens=None, reasoning_tokens=0, rejected_prediction_tokens=None), prompt_tokens_details=None)) [2026-03-13 10:35:16.963] [Core] [INFO] [respond.stage:184]: Prepare to send - /<USER_SESSION_ID>: [2026-03-13 10:35:16.963] [Core] [INFO] [respond.stage:215]: 消息为空,跳过发送阶段 [2026-03-13 10:35:16.963] [Core] [INFO] [runners.tool_loop_agent_runner:657]: Agent 使用工具: ['create_future_task'] [2026-03-13 10:35:16.963] [Core] [INFO] [runners.tool_loop_agent_runner:703]: 使用工具:create_future_task,参数:{'run_at': '2026-03-13T10:40:00+08:00', 'note': '提醒检查Token用量', 'run_once': True, 'name': 'Check Token Usage at 10:40'} [2026-03-13 10:35:16.974] [Core] [INFO] [runners.tool_loop_agent_runner:881]: Tool create_future_task Result: Scheduled future task <FUTURE_TASK_ID> (Check Token Usage at 10:40) one-time at 2026-03-13 10:40:00+08:00. [2026-03-13 10:35:16.977] [Core] [DBUG] [runners.tool_loop_agent_runner:297]: [BefCompact] RunCtx.messages -> [38] system,user,assistant,user,assistant,user,assistant,user,assistant,user,assistant,user,assistant,user,assistant,tool,assistant,user,assistant,tool,assistant,user,assistant,user,assistant,tool,assistant,user,assistant,user,assistant,tool,assistant,user,assistant,user,assistant,tool [2026-03-13 10:35:16.978] [Core] [DBUG] [runners.tool_loop_agent_runner:297]: [AftCompact] RunCtx.messages -> [38] system,user,assistant,user,assistant,user,assistant,user,assistant,user,assistant,user,assistant,user,assistant,tool,assistant,user,assistant,tool,assistant,user,assistant,user,assistant,tool,assistant,user,assistant,user,assistant,tool,assistant,user,assistant,user,assistant,tool [2026-03-13 10:35:19.910] [Core] [DBUG] [sources.openai_source:262]: completion: ChatCompletion(id='<CHAT_COMPLETION_ID_2>', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='已为您设置一个在10:40提醒检查Token用量的任务。请在该时间点准时查看提醒。如有任何问题,请随时告知!', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None))], created=1773369317, model='Qwen/Qwen3-8B', object='chat.completion', service_tier=None, system_fingerprint='', usage=CompletionUsage(completion_tokens=32, prompt_tokens=3744, total_tokens=3776, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=None, audio_tokens=None, reasoning_tokens=0, rejected_prediction_tokens=None), prompt_tokens_details=None)) [2026-03-13 10:35:19.910] [Core] [DBUG] [runners.base:64]: Agent state transition: AgentState.RUNNING -> AgentState.DONE [2026-03-13 10:35:19.910] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnLLMResponseEvent) -> astrbot - record_llm_resp_to_ltm [2026-03-13 10:35:19.913] [Core] [INFO] [respond.stage:184]: Prepare to send - /<USER_SESSION_ID>: 已为您设置一个在10:40提醒检查Token用量的任务。请在该时间点准时查看提醒。如有任何问题,请随时告知! [2026-03-13 10:35:20.241] [Core] [DBUG] [qqofficial.qqofficial_message_event:352]: Message sent to C2C: {'id': '<MESSAGE_ID>', 'timestamp': '2026-03-13T10:35:20+08:00', 'ext_info': {'ref_idx': '<REF_IDX>'}} [2026-03-13 10:35:20.241] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnAfterMessageSentEvent) -> astrbot - after_message_sent [2026-03-13 10:35:20.250] [Core] [DBUG] [pipeline.scheduler:93]: pipeline 执行完毕。

[2026-03-13 10:40:00.064] [Core] [DBUG] [core.astr_main_agent_resources:445]: [知识库] 使用全局配置,知识库数量: 0 [2026-03-13 10:40:00.064] [Core] [DBUG] [runners.base:64]: Agent state transition: AgentState.IDLE -> AgentState.RUNNING [2026-03-13 10:40:00.065] [Core] [DBUG] [runners.tool_loop_agent_runner:297]: [BefCompact] RunCtx.messages -> [2] system,user [2026-03-13 10:40:00.065] [Core] [DBUG] [runners.tool_loop_agent_runner:297]: [AftCompact] RunCtx.messages -> [2] system,user [2026-03-13 10:40:03.230] [Core] [DBUG] [sources.openai_source:262]: completion: ChatCompletion(id='<CHAT_COMPLETION_ID_3>', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='您的Token用量检查提醒已经到达。如果您需要我帮您检查或提供相关的Token使用情况,请随时告诉我!', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None))], created=1773369600, model='Qwen/Qwen3-8B', object='chat.completion', service_tier=None, system_fingerprint='', usage=CompletionUsage(completion_tokens=24, prompt_tokens=5021, total_tokens=5045, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=None, audio_tokens=None, reasoning_tokens=0, rejected_prediction_tokens=None), prompt_tokens_details=None)) [2026-03-13 10:40:03.230] [Core] [DBUG] [runners.base:64]: Agent state transition: AgentState.RUNNING -> AgentState.DONE [2026-03-13 10:40:03.231] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnLLMResponseEvent) -> astrbot - record_llm_resp_to_ltm

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • [ ] Yes!

Code of Conduct

DarkGhast avatar Mar 13 '26 03:03 DarkGhast

Hi @DarkGhast! I'm Dosu and I’m helping the AstrBot team.

这是一个 已知 Bug,已在 Issue #6103 中报告,症状与你的日志完全一致。

根本原因:定时任务唤醒时,Agent 的"主动型能力"状态管理存在问题。从你的日志可以看到,到点后 LLM 返回 finish_reason='stop' 且 tool_calls=None——这意味着 Agent 直接输出了文本回复,但没有调用 send_message_to_user 工具来发送消息。

正常流程应该是:Agent 被 CronJobManager 唤醒后,需要主动调用 send_message_to_user 工具向用户发送提醒,而不是像普通对话那样直接回复。

临时解决方案:

  1. 完全重启 AstrBot 容器/进程
  2. 确认"主动型能力"开关已启用
  3. 据 #6103 报告,重启后问题可能临时恢复

这个问题是 Agent 状态管理的 Bug,不是 qq_official 平台本身不支持定时任务。

To reply, just mention @dosu.


Share context across your team and agents. Try Dosu.

Leave Feedback Learn about AstrBot with Dosu Add Dosu to your team

dosubot[bot] avatar Mar 13 '26 03:03 dosubot[bot]

我这边在 v4.20.0 仍然可以复现。机器人提到的 #6103 看起来是 4.19 版本的问题,而 v4.20.0 的更新日志里也提到了“优化 QQ 官方 Bot 的流式消息投递可靠性与主动媒体发送能力”。但目前在 qq_official(WebSockets)+ 主动型能力 + FutureTask 场景下,到点后任务会执行并消失,用户仍然收不到主动提醒,说明新版本下这个问题似乎还没有完全修复

DarkGhast avatar Mar 13 '26 03:03 DarkGhast

https://github.com/AstrBotDevs/AstrBot/issues/6103 的问题在4.20仍可复现,与这个issue症状相同“finish_reason='stop'”。不同之处是https://github.com/AstrBotDevs/AstrBot/issues/6103 使用napcat平台。该问题应该与消息平台无关。

FFFold avatar Mar 13 '26 07:03 FFFold