From d2b9997620ac23e83209a69ce6d0ff079a7ea92f Mon Sep 17 00:00:00 2001 From: advent259141 <2968474907@qq.com> Date: Wed, 4 Feb 2026 17:42:41 +0800 Subject: [PATCH 1/7] chore: bump version to 4.14.2 --- astrbot/cli/__init__.py | 2 +- astrbot/core/config/default.py | 2 +- changelogs/v4.14.2.md | 23 +++++++++++++++++++++++ pyproject.toml | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 changelogs/v4.14.2.md diff --git a/astrbot/cli/__init__.py b/astrbot/cli/__init__.py index 958d33c76..1a667d3f8 100644 --- a/astrbot/cli/__init__.py +++ b/astrbot/cli/__init__.py @@ -1 +1 @@ -__version__ = "4.14.1" +__version__ = "4.14.2" diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index 12056a04e..933edf2b3 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -5,7 +5,7 @@ from typing import Any, TypedDict from astrbot.core.utils.astrbot_path import get_astrbot_data_path -VERSION = "4.14.1" +VERSION = "4.14.2" DB_PATH = os.path.join(get_astrbot_data_path(), "data_v4.db") WEBHOOK_SUPPORTED_PLATFORMS = [ diff --git a/changelogs/v4.14.2.md b/changelogs/v4.14.2.md new file mode 100644 index 000000000..8438314e6 --- /dev/null +++ b/changelogs/v4.14.2.md @@ -0,0 +1,23 @@ +## What's Changed + +### 新增 +- 控制台页面新增调试提示和本地化文件 ([#4852](https://github.com/AstrBotDevs/AstrBot/pull/4852)) + +### 修复 +- 修复插件热重载时平台适配器未清理导致注册冲突的问题 ([#4859](https://github.com/AstrBotDevs/AstrBot/pull/4859)) + +### 其他 +- 更新 ruff 版本至 0.15.0 +- 新增 robots.txt ([#4847](https://github.com/AstrBotDevs/AstrBot/pull/4847)) + +## What's Changed (EN) + +### New Features +- Add debug hint to console page and localization files ([#4852](https://github.com/AstrBotDevs/AstrBot/pull/4852)) + +### Bug Fixes +- Fix platform adapter not being cleaned up during plugin hot reload, causing registration conflicts ([#4859](https://github.com/AstrBotDevs/AstrBot/pull/4859)) + +### Others +- Update ruff version to 0.15.0 +- Add robots.txt ([#4847](https://github.com/AstrBotDevs/AstrBot/pull/4847)) diff --git a/pyproject.toml b/pyproject.toml index 2ce53ad39..7920b3f2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "AstrBot" -version = "4.14.1" +version = "4.14.2" description = "Easy-to-use multi-platform LLM chatbot and development framework" readme = "README.md" requires-python = ">=3.10" From a954e755470dcb6a2ccb900e603cc4ca6faa7364 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Wed, 4 Feb 2026 20:25:28 +0800 Subject: [PATCH 2/7] fix: add apply_reset parameter to build_main_agent and handle coroutine reset in InternalAgentSubStage --- astrbot/core/astr_main_agent.py | 14 ++++++++++++-- .../method/agent_sub_stages/internal.py | 6 ++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/astrbot/core/astr_main_agent.py b/astrbot/core/astr_main_agent.py index 1ea36ff7a..dfffa9cf9 100644 --- a/astrbot/core/astr_main_agent.py +++ b/astrbot/core/astr_main_agent.py @@ -51,6 +51,7 @@ from astrbot.core.tools.cron_tools import ( ) from astrbot.core.utils.file_extract import extract_file_moonshotai from astrbot.core.utils.llm_metadata import LLM_METADATAS +from typing import Coroutine @dataclass(slots=True) @@ -114,6 +115,7 @@ class MainAgentBuildResult: agent_runner: AgentRunner provider_request: ProviderRequest provider: Provider + reset_coro: Coroutine | None = None def _select_provider( @@ -837,8 +839,12 @@ async def build_main_agent( config: MainAgentBuildConfig, provider: Provider | None = None, req: ProviderRequest | None = None, + apply_reset: bool = True, ) -> MainAgentBuildResult | None: - """构建主对话代理(Main Agent),并且自动 reset。""" + """构建主对话代理(Main Agent),并且自动 reset。 + + If apply_reset is False, will not call reset on the agent runner. + """ provider = provider or _select_provider(event, plugin_context) if provider is None: logger.info("未找到任何对话模型(提供商),跳过 LLM 请求处理。") @@ -955,7 +961,7 @@ async def build_main_agent( if action_type == "live": req.system_prompt += f"\n{LIVE_MODE_SYSTEM_PROMPT}\n" - await agent_runner.reset( + reset_coro = agent_runner.reset( provider=provider, request=req, run_context=AgentContextWrapper( @@ -973,8 +979,12 @@ async def build_main_agent( tool_schema_mode=config.tool_schema_mode, ) + if apply_reset: + await reset_coro + return MainAgentBuildResult( agent_runner=agent_runner, provider_request=req, provider=provider, + reset_coro=reset_coro if not apply_reset else None, ) diff --git a/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py b/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py index 8fa39f8e8..b598e3aa2 100644 --- a/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py +++ b/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py @@ -164,6 +164,7 @@ class InternalAgentSubStage(Stage): event=event, plugin_context=self.ctx.plugin_manager.context, config=build_cfg, + apply_reset=False, ) if build_result is None: @@ -172,6 +173,7 @@ class InternalAgentSubStage(Stage): agent_runner = build_result.agent_runner req = build_result.provider_request provider = build_result.provider + reset_coro = build_result.reset_coro api_base = provider.provider_config.get("api_base", "") for host in decoded_blocked: @@ -190,6 +192,10 @@ class InternalAgentSubStage(Stage): if await call_event_hook(event, EventType.OnLLMRequestEvent, req): return + # apply reset + if reset_coro: + await reset_coro + action_type = event.get_extra("action_type") event.trace.record( From 1f75255950098234cb9761280f4ea78f2f8a34fa Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Wed, 4 Feb 2026 20:31:19 +0800 Subject: [PATCH 3/7] chore: bump version to 4.14.3 --- astrbot/cli/__init__.py | 2 +- astrbot/core/astr_main_agent.py | 2 +- changelogs/v4.14.3.md | 4 ++++ pyproject.toml | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 changelogs/v4.14.3.md diff --git a/astrbot/cli/__init__.py b/astrbot/cli/__init__.py index 1a667d3f8..26066ebef 100644 --- a/astrbot/cli/__init__.py +++ b/astrbot/cli/__init__.py @@ -1 +1 @@ -__version__ = "4.14.2" +__version__ = "4.14.3" diff --git a/astrbot/core/astr_main_agent.py b/astrbot/core/astr_main_agent.py index dfffa9cf9..690a6404c 100644 --- a/astrbot/core/astr_main_agent.py +++ b/astrbot/core/astr_main_agent.py @@ -7,6 +7,7 @@ import datetime import json import os import zoneinfo +from collections.abc import Coroutine from dataclasses import dataclass, field from astrbot.api import sp @@ -51,7 +52,6 @@ from astrbot.core.tools.cron_tools import ( ) from astrbot.core.utils.file_extract import extract_file_moonshotai from astrbot.core.utils.llm_metadata import LLM_METADATAS -from typing import Coroutine @dataclass(slots=True) diff --git a/changelogs/v4.14.3.md b/changelogs/v4.14.3.md new file mode 100644 index 000000000..72d321d97 --- /dev/null +++ b/changelogs/v4.14.3.md @@ -0,0 +1,4 @@ +## What's Changed + +### 修复 +- 修复 `on_llm_request` 钩子可能无法应用效果的问题 diff --git a/pyproject.toml b/pyproject.toml index 7920b3f2e..e2d016d9a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "AstrBot" -version = "4.14.2" +version = "4.14.3" description = "Easy-to-use multi-platform LLM chatbot and development framework" readme = "README.md" requires-python = ">=3.10" From 6736fb85c234891a26ea2261c118a1b90b44cff4 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Wed, 4 Feb 2026 23:18:32 +0800 Subject: [PATCH 4/7] fix: conversation token usage calculate wrongly and fix tool call infinitely (#4869) --- astrbot/core/agent/runners/tool_loop_agent_runner.py | 2 ++ .../pipeline/process_stage/method/agent_sub_stages/internal.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/astrbot/core/agent/runners/tool_loop_agent_runner.py b/astrbot/core/agent/runners/tool_loop_agent_runner.py index 03d53427f..0e5b4353f 100644 --- a/astrbot/core/agent/runners/tool_loop_agent_runner.py +++ b/astrbot/core/agent/runners/tool_loop_agent_runner.py @@ -213,6 +213,8 @@ class ToolLoopAgentRunner(BaseAgentRunner[TContext]): if not llm_response.is_chunk and llm_response.usage: # only count the token usage of the final response for computation purpose self.stats.token_usage += llm_response.usage + if self.req.conversation: + self.req.conversation.token_usage = llm_response.usage.total break # got final response if not llm_resp_result: diff --git a/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py b/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py index b598e3aa2..87f0dd419 100644 --- a/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py +++ b/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py @@ -363,7 +363,8 @@ class InternalAgentSubStage(Stage): token_usage = None if runner_stats: - token_usage = runner_stats.token_usage.total + # token_usage = runner_stats.token_usage.total + token_usage = llm_response.usage.total if llm_response.usage else None await self.conv_manager.update_conversation( event.unified_msg_origin, From 464882f20627f3fe6346fff76c973e58127edb05 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Wed, 4 Feb 2026 23:21:08 +0800 Subject: [PATCH 5/7] chore: bump version to 4.14.4 --- astrbot/cli/__init__.py | 2 +- astrbot/core/config/default.py | 2 +- changelogs/v4.14.4.md | 4 ++++ pyproject.toml | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 changelogs/v4.14.4.md diff --git a/astrbot/cli/__init__.py b/astrbot/cli/__init__.py index 26066ebef..3914306d0 100644 --- a/astrbot/cli/__init__.py +++ b/astrbot/cli/__init__.py @@ -1 +1 @@ -__version__ = "4.14.3" +__version__ = "4.14.4" diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index 933edf2b3..10a6fc599 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -5,7 +5,7 @@ from typing import Any, TypedDict from astrbot.core.utils.astrbot_path import get_astrbot_data_path -VERSION = "4.14.2" +VERSION = "4.14.4" DB_PATH = os.path.join(get_astrbot_data_path(), "data_v4.db") WEBHOOK_SUPPORTED_PLATFORMS = [ diff --git a/changelogs/v4.14.4.md b/changelogs/v4.14.4.md new file mode 100644 index 000000000..3c881ae49 --- /dev/null +++ b/changelogs/v4.14.4.md @@ -0,0 +1,4 @@ +## What's Changed + +### 修复 +- 修复 token 统计错误的问题,修复在多轮 tool call 情况下或者其他极端情况下可能造成 tool 无限调用的问题。 diff --git a/pyproject.toml b/pyproject.toml index e2d016d9a..e98707944 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "AstrBot" -version = "4.14.3" +version = "4.14.4" description = "Easy-to-use multi-platform LLM chatbot and development framework" readme = "README.md" requires-python = ">=3.10" From 2876c4338708e2965a829054fb37838af3709043 Mon Sep 17 00:00:00 2001 From: Xican <107746729+luosheng520qaq@users.noreply.github.com> Date: Thu, 5 Feb 2026 10:14:31 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=89=B9=E5=AE=9A?= =?UTF-8?q?=E6=8F=90=E4=BE=9B=E5=95=86=E5=AF=BC=E8=87=B4=E7=9A=84=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=89=A7=E8=A1=8C=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20(#4872)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复特定提供商导致的定时任务执行失败的问题 * ruff format --------- Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com> --- astrbot/core/cron/manager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/astrbot/core/cron/manager.py b/astrbot/core/cron/manager.py index 85ca581bc..0572fa03a 100644 --- a/astrbot/core/cron/manager.py +++ b/astrbot/core/cron/manager.py @@ -310,6 +310,7 @@ class CronJobManager: config = MainAgentBuildConfig( tool_call_timeout=3600, llm_safety_mode=False, + streaming_response=False, ) req = ProviderRequest() conv = await _get_session_conv(event=cron_event, plugin_context=self.ctx) From 912e40e7f0f90f2562f47100ec4be3b2e751c5b3 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Thu, 5 Feb 2026 10:40:48 +0800 Subject: [PATCH 7/7] chore: delete unused file --- ASYNC_TASK_new.md | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 ASYNC_TASK_new.md diff --git a/ASYNC_TASK_new.md b/ASYNC_TASK_new.md deleted file mode 100644 index fc5d5deef..000000000 --- a/ASYNC_TASK_new.md +++ /dev/null @@ -1,18 +0,0 @@ -我需要让 Agent 能够在未来提醒自己去做某些事情,这样 Agent 能够主动地去完成一些任务,而不是等用户主动来下达命令。 - -你需要实现一个 CronJob 系统,允许 Agent 创建未来任务,并且在未来的某个时间点自动触发这些任务的执行. - -CronJob 系统分为 BasicCronJob 和 ActiveAgentCronJob 两种类型。前者只是简单的提供一个定时任务功能(给插件用),而后者则允许 Agent 主动地去完成一些任务。BasicCronJob 不必多说,就是定时执行某个函数。对于 ActiveAgentCronJob,Agent 应该可以主动管理(比如通过Tool来管理)这些 CronJobs,当添加的时候,Agent 可以给 CronJob 捎一段文字,以说明未来的自己需要做什么事情。比如说,Agent 在听到用户 “每天早上都给我整理一份今日早报” 之后,应该可以创建 Cron Job,并且自己写脚本来完成这个任务,并且注册 cron job。Agent 给未来的自己捎去的信息应该只是呈现为一段文字,这样可以保持设计简约。当触发后, CronJobManager 会调用 MainAgent 的一轮循环,MainAgent 通过上下文知道这是一个定时任务触发的循环,从而执行相应的操作。 - -此外,我还有一个需求,后台长任务。需要给当前的 FunctionTool 类增加一个属性,is_background_task: bool = False,插件可以通过这个属性来声明这是一个异步任务。这是为了解决一些 Tool 需要长时间运行的问题,比如 Deep Search tool 需要长时间搜索网页内容、Sub Agent 需要长时间运行来完成一个复杂任务。 - -基于上面的讨论,我觉得,应该: - -1. 需要给当前的 FunctionTool 类增加一个属性is_background_task: bool = False,tool runner 在执行这个 tool 的时候,如果发现是后台任务,就不等待结果返回,而是直接返回一个任务 ID (已经创建成功提示)的结果,tool runner 在后台继续执行这个任务。当任务完成之后,任务的结果回传给 MainAgent(其实就是再执行一次 main agent loop,但是上下文应该是最新的),并且 MainAgent 此时应该有 send_message_to_user 的工具,通过这个工具可以选择是否主动通知用户任务完成的结果。 -2. 增加一个 CronJobManager 类,负责管理所有的定时任务。Agent 可以通过调用这个类的方法来创建、删除、修改定时任务。通过 cron expression 来定义触发条件。 -3. CronJobManager 除了管理普通的定时任务(比如插件可能有一些自己的定时任务),还有一种特殊的任务类型,就是上面提到的主动型 Agent 任务。用户提需求,MainAgent 选择性地调用 CronJobManager 的方法来创建这些任务,并且在任务触发时,CronJobManager 的回调就是执行 MainAgent 的一轮循环(需要加 send_message_to_user tool),MainAgent 通过上下文知道这是一个定时任务触发的循环,从而执行相应的操作。 -4. WebUI 需要增加 Cron Job 管理界面,用户可以在界面上查看、创建、修改、删除定时任务。对于主动型 Agent 任务,用户可以看到任务的描述、触发条件等信息。 -5. 除此之外,现在的代码中已经有了 subagent 的管理。WebUI 可以创建 SubAgent,但是还没写完。除了结合上面我说的之外,你还需要将 SubAgent 与 Persona 结合起来——因为 Persona 是一个包含了 tool、skills、name、description 的完整体,所以 SubAgent 应该直接继承 Persona 的定义,而不是单独定义 SubAgent。SubAgent 本质上就是一个有特定角色和能力的 Persona!多么美妙的设计啊! -6. 为了实现大一统,is_background_task = True 的时候,后台任务也挂到 CronJobManager 上去管理,只不过这个是立即触发的任务,不需要等到未来某个时间点才触发罢了。 - -我希望设计尽可能简单,但是强大。