Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
44d2364
feat: enhanced subagent
elecvoid243 Mar 26, 2026
01b78d7
Merge branch 'master' of https://github.com/elecvoid243/AstrBot
elecvoid243 Mar 26, 2026
c70d0a5
no message
elecvoid243 Mar 26, 2026
f195754
no message
elecvoid243 Mar 27, 2026
3b005da
no message
elecvoid243 Mar 28, 2026
2b67fd3
no message
elecvoid243 Mar 28, 2026
9d38048
formatting
elecvoid243 Mar 28, 2026
378a6e6
no message
elecvoid243 Mar 28, 2026
2d33670
no message
elecvoid243 Mar 28, 2026
5e45821
test
elecvoid243 Mar 28, 2026
ad34dce
no message
elecvoid243 Mar 28, 2026
2389f27
Merge branch 'master' into master
elecvoid243 Mar 29, 2026
549ff85
no message
elecvoid243 Mar 29, 2026
38a6b2e
Merge branch 'master' of https://github.com/elecvoid243/AstrBot
elecvoid243 Mar 29, 2026
58d5141
Merge branch 'AstrBotDevs:master' into master
elecvoid243 Mar 29, 2026
a9cf8d3
添加Reset工具
elecvoid243 Mar 29, 2026
923a58e
Merge branch 'AstrBotDevs:master' into master
elecvoid243 Mar 29, 2026
bf88368
结构化的共享上下文;更新subagent后台任务逻辑
elecvoid243 Mar 30, 2026
97cfedf
Merge branch 'AstrBotDevs:master' into master
elecvoid243 Mar 30, 2026
9f7e208
主动等待机制;Prompt优化
elecvoid243 Apr 2, 2026
163ce55
Merge branch 'master' of https://github.com/elecvoid243/AstrBot
elecvoid243 Apr 2, 2026
ee0a85e
Merge branch 'AstrBotDevs:master' into master
elecvoid243 Apr 2, 2026
fb39593
Merge branch 'AstrBotDevs:master' into master
elecvoid243 Apr 5, 2026
06cb7ea
subagent运行状态监控
elecvoid243 Apr 6, 2026
a579ac3
Merge branch 'master' into master
elecvoid243 Apr 6, 2026
3f02d54
rollback local.py
elecvoid243 Apr 6, 2026
03deaac
Merge branch 'AstrBotDevs:master' into master
elecvoid243 Apr 7, 2026
d3cee00
merge
elecvoid243 Apr 7, 2026
47b61ec
Merge branch 'AstrBotDevs:master' into master
elecvoid243 Apr 8, 2026
7dbfb6e
后台subagent任务:若主agent已结束,回退到原始唤醒机制
elecvoid243 Apr 9, 2026
6a6d030
移除logger;prompt简化
elecvoid243 Apr 11, 2026
cea5611
subagent历史带工具调用信息
elecvoid243 Apr 11, 2026
a9dd635
Merge branch 'master' into master
elecvoid243 Apr 11, 2026
1222aae
formatting
elecvoid243 Apr 11, 2026
25200f2
no message
elecvoid243 Apr 11, 2026
603072c
no message
elecvoid243 Apr 11, 2026
2e2a60b
Merge branch 'AstrBotDevs:master' into master
elecvoid243 Apr 12, 2026
65bb50c
no message
elecvoid243 Apr 13, 2026
7d567b6
Merge branch 'AstrBotDevs:master' into master
elecvoid243 Apr 13, 2026
4366d37
Merge branch 'master' of https://github.com/elecvoid243/AstrBot
elecvoid243 Apr 13, 2026
7490ea3
添加subagent超时保护(总时长)
elecvoid243 Apr 14, 2026
cd912b3
Merge branch 'AstrBotDevs:master' into master
elecvoid243 Apr 14, 2026
f4fabc2
Merge branch 'master' of https://github.com/elecvoid243/AstrBot
elecvoid243 Apr 14, 2026
7ef86e4
formatting
elecvoid243 Apr 14, 2026
09da25c
Merge branch 'master' into master
elecvoid243 Apr 19, 2026
00465ee
更新dashborad
elecvoid243 Apr 19, 2026
ee3d6fe
fix dashboard
elecvoid243 Apr 20, 2026
0999ba1
formatting
elecvoid243 Apr 20, 2026
8705d81
bug fix
elecvoid243 Apr 21, 2026
17134ef
Merge branch 'AstrBotDevs:master' into master
elecvoid243 Apr 21, 2026
f26fbf4
Merge branch 'AstrBotDevs:master' into master
elecvoid243 Apr 23, 2026
a064451
bug fix
elecvoid243 Apr 23, 2026
e3ace42
resolve conficts
elecvoid243 Apr 27, 2026
ffa3cbc
Merge branch 'AstrBotDevs:master' into master
elecvoid243 Apr 27, 2026
095603c
合并subagent与enhanced subagent实现
elecvoid243 Apr 28, 2026
c098de9
Merge branch 'AstrBotDevs:master' into master
elecvoid243 Apr 29, 2026
0d6567a
format
elecvoid243 Apr 29, 2026
2f93e9e
format
elecvoid243 Apr 29, 2026
b70439b
Merge branch 'master' of https://github.com/elecvoid243/AstrBot
elecvoid243 Apr 29, 2026
ceba3ae
no message
elecvoid243 Apr 29, 2026
f0b3872
历史上下文功能变为可配置的
elecvoid243 Apr 30, 2026
49be025
Merge branch 'AstrBotDevs:master' into master
elecvoid243 Apr 30, 2026
885e1e0
bug fix
elecvoid243 May 3, 2026
40ce239
Merge branch 'AstrBotDevs:master' into master
elecvoid243 May 3, 2026
b7c3a88
Merge branch 'master' of https://github.com/elecvoid243/AstrBot
elecvoid243 May 3, 2026
b2a8593
为配置项更新dashboard
elecvoid243 May 4, 2026
c73a542
Merge branch 'AstrBotDevs:master' into master
elecvoid243 May 4, 2026
e0e8da9
Merge branch 'master' of https://github.com/elecvoid243/AstrBot
elecvoid243 May 4, 2026
116ec55
啥时候改的这个文件?还原
elecvoid243 May 4, 2026
820a9dd
no message
elecvoid243 May 4, 2026
1cd37f1
优化dashboard
elecvoid243 May 4, 2026
822de54
no message
elecvoid243 May 4, 2026
734e3a3
no message
elecvoid243 May 4, 2026
238ee93
no message
elecvoid243 May 4, 2026
12d761e
no message
elecvoid243 May 4, 2026
239d576
分离manager和tools
elecvoid243 May 4, 2026
5a11f81
ruff
elecvoid243 May 4, 2026
e2f8f5e
Merge branch 'AstrBotDevs:master' into master
elecvoid243 May 5, 2026
a0aa3d8
Merge branch 'AstrBotDevs:master' into master
elecvoid243 May 6, 2026
4f02492
优化router prompt; 更多dashboard配置
elecvoid243 May 6, 2026
d5fb9f9
共享上下文放到system_reminder防止缓存不命中
elecvoid243 May 7, 2026
56e0192
Merge branch 'AstrBotDevs:master' into master
elecvoid243 May 7, 2026
97d19cc
移除变化的router prompt
elecvoid243 May 7, 2026
675b5fa
Merge branch 'AstrBotDevs:master' into subagent
elecvoid243 May 10, 2026
ec56c6e
定期清理非活跃的subagent会话
elecvoid243 May 10, 2026
0f82b14
为/reset指令添加subagent清理;超时会话自动清理;管理工具简化
elecvoid243 May 10, 2026
08013bb
remove deprecated
elecvoid243 May 10, 2026
f3e238e
更新subagent默认工作路径为主agent默认路径/agent_name
elecvoid243 May 10, 2026
5a922f2
no message
elecvoid243 May 10, 2026
03fce2d
fix: ensure subagent workdir exists
elecvoid243 May 11, 2026
3fdba2c
Merge branch 'AstrBotDevs:master' into subagent
elecvoid243 May 11, 2026
f88eddf
Update astrbot/core/subagent_manager.py
elecvoid243 May 11, 2026
8d40859
Update astrbot/core/subagent_manager.py
elecvoid243 May 11, 2026
b3ab73d
Update astrbot/core/subagent_manager.py
elecvoid243 May 11, 2026
76399fb
Update astrbot/core/subagent_manager.py
elecvoid243 May 11, 2026
b28cefd
Update astrbot/core/astr_main_agent.py
elecvoid243 May 11, 2026
cf143f6
ruff
elecvoid243 May 11, 2026
81cf6b6
Merge branch 'AstrBotDevs:master' into subagent
elecvoid243 May 18, 2026
5236995
fix static subagent skill injection
elecvoid243 May 18, 2026
f42b212
ruff
elecvoid243 May 18, 2026
f0eb792
no message
elecvoid243 May 18, 2026
40b9936
no message
elecvoid243 May 18, 2026
e27ddec
fix: wait工具独立计时,不受工具调用超时参数影响
elecvoid243 May 21, 2026
f24682d
Merge branch 'AstrBotDevs:master' into subagent
elecvoid243 May 21, 2026
9434715
Merge branch 'subagent' of https://github.com/elecvoid243/AstrBot int…
elecvoid243 May 21, 2026
2a8ed83
Merge branch 'AstrBotDevs:master' into subagent
elecvoid243 May 23, 2026
5304c82
feat(subagent): 为subagent添加日志追踪
elecvoid243 May 24, 2026
d64d345
dag test
elecvoid243 May 26, 2026
99b5d63
dag dashboard
elecvoid243 May 26, 2026
4f3368f
feat: 添加有向无环图(DAG)编排器,自动处理数据依赖
elecvoid243 May 26, 2026
ab5e662
feat: 为动态子代理添加默认provider_id配置
elecvoid243 May 30, 2026
7c16350
Merge branch 'AstrBotDevs:master' into subagent
elecvoid243 May 30, 2026
1ad7b22
no message
elecvoid243 May 30, 2026
dc05126
Merge branch 'subagent' of https://github.com/elecvoid243/AstrBot int…
elecvoid243 May 30, 2026
c47cb7f
Merge branch 'master' into subagent
elecvoid243 May 30, 2026
9ccaa4d
no message
elecvoid243 May 30, 2026
bad33aa
fix: 统一subagent委派工具
elecvoid243 Jun 4, 2026
2cd0a71
fix: 保留静态handoff工具用于去重
elecvoid243 Jun 4, 2026
bae484e
Merge branch 'subagent' of https://github.com/elecvoid243/AstrBot int…
elecvoid243 Jun 4, 2026
109f7ae
Merge branch 'AstrBotDevs:master' into subagent
elecvoid243 Jun 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions astrbot/builtin_stars/builtin_commands/commands/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,18 @@ async def reset(self, message: AstrMessageEvent) -> None:

ret = "✅ Conversation reset successfully."

# 清理该会话下的所有 subagent
try:
from astrbot.core.subagent_manager import SubAgentManager

cleanup_result = await SubAgentManager.cleanup_session(umo)
if cleanup_result["status"] == "cleaned":
cleaned_count = len(cleanup_result["cleaned_agents"])
if cleaned_count > 0:
ret += f" 🧹 Also cleaned {cleaned_count} subagent(s): {', '.join(cleanup_result['cleaned_agents'])}."
except Exception as e:
logger.warning(f"[SubAgent] Failed to cleanup subagents on /reset: {e}")

message.set_extra("_clean_group_context_session", True)

message.set_result(MessageEventResult().message(ret))
Expand Down
32 changes: 32 additions & 0 deletions astrbot/core/agent/runners/tool_loop_agent_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,13 @@ def _append_tool_call_result(tool_call_id: str, content: str) -> None:
),
)

# 获取 trace span:优先使用 subagent trace_span,否则回退到 event.trace
_agent_ctx = getattr(self.run_context, "context", None)
_trace = getattr(_agent_ctx, "trace_span", None)
if _trace is None and _agent_ctx is not None:
_event = getattr(_agent_ctx, "event", None)
_trace = getattr(_event, "trace", None)

# 执行函数调用
for func_tool_name, func_tool_args, func_tool_id in zip(
llm_response.tools_call_name,
Expand All @@ -1014,10 +1021,23 @@ def _append_tool_call_result(tool_call_id: str, content: str) -> None:
],
)
)
# 记录工具调用追踪
if _trace:
_trace.record("agent_tool_call", tool_name=func_tool_name)
try:
if not req.func_tool:
return

# Resolve tool from regular tool sets
if (
self.tool_schema_mode == "skills_like"
and self._skill_like_raw_tool_set
):
# in 'skills_like' mode, raw.func_tool is light schema, does not have handler
# so we need to get the tool from the raw tool set
func_tool = self._skill_like_raw_tool_set.get_tool(func_tool_name)
else:
func_tool = req.func_tool.get_tool(func_tool_name)
if (
self.tool_schema_mode == "skills_like"
and self._skill_like_raw_tool_set
Expand Down Expand Up @@ -1231,6 +1251,15 @@ def _append_tool_call_result(tool_call_id: str, content: str) -> None:
)
)
logger.info(f"Tool `{func_tool_name}` Result: {tool_result_content}")
# 记录工具结果追踪
if _trace:
_trace.record(
"agent_tool_result",
tool_name=func_tool_name,
tool_result=tool_result_content[:500]
if tool_result_content
else None,
)

# 处理函数调用响应
if tool_call_result_blocks:
Expand Down Expand Up @@ -1359,13 +1388,16 @@ async def _finalize_aborted_step(
llm_resp: LLMResponse | None = None,
) -> AgentResponse:
logger.info("Agent execution was requested to stop by user.")

if llm_resp is None:
llm_resp = LLMResponse(role="assistant", completion_text="")

if llm_resp.role != "assistant":
llm_resp = LLMResponse(
role="assistant",
completion_text=self.USER_INTERRUPTION_MESSAGE,
)

self.final_llm_resp = llm_resp
self._aborted = True
self._transition_state(AgentState.DONE)
Expand Down
9 changes: 8 additions & 1 deletion astrbot/core/astr_agent_context.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Any

from pydantic import Field
from pydantic.dataclasses import dataclass

Expand All @@ -14,8 +16,13 @@ class AstrAgentContext:
"""The star context instance"""
event: AstrMessageEvent
"""The message event associated with the agent context."""
extra: dict[str, str] = Field(default_factory=dict)
extra: dict[str, Any] = Field(default_factory=dict)
"""Customized extra data."""
trace_span: Any = Field(default=None)
"""Optional custom TraceSpan for subagent tracing. When set, tool calls within
the agent loop will be recorded to this trace instead of event.trace.
This prevents concurrent subagent and main agent tool calls from mixing up
trace records."""


AgentContextWrapper = ContextWrapper[AstrAgentContext]
11 changes: 0 additions & 11 deletions astrbot/core/astr_agent_run_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,6 @@ async def run_agent(
if resp.type == "tool_call_result":
msg_chain = resp.data["chain"]

astr_event.trace.record(
"agent_tool_result",
tool_result=msg_chain.get_plain_text(
with_other_comps_mark=True
),
)

if msg_chain.type == "tool_direct_result":
# tool_direct_result 用于标记 llm tool 需要直接发送给用户的内容
await astr_event.send(msg_chain)
Expand All @@ -218,10 +211,6 @@ async def run_agent(
yield MessageChain(chain=[], type="break")

tool_info = _extract_chain_json_data(resp.data["chain"])
astr_event.trace.record(
"agent_tool_call",
tool_name=tool_info if tool_info else "unknown",
)
_record_tool_call_name(tool_info, tool_name_by_call_id)

if astr_event.get_platform_name() == "webchat":
Expand Down
Loading
Loading