Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ai
/
ai-workflow
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 846ee6ff
authored
May 23, 2026
by
sunqi02
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新增 per-agent toolkit 构建逻辑
将工具注册到所有拥有指定 skill 的 agent
1 parent
98e8391f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
8 deletions
workspace/agent-admin/backend/app/main.py
workspace/agent-admin/backend/app/service/agent_hub.py
workspace/agent-admin/backend/app/main.py
View file @
846ee6f
...
...
@@ -50,11 +50,7 @@ async def lifespan(app: FastAPI):
)
from
skills.meeting_minutes.scripts.pipeline
import
run_pipeline
agent_hub_instance
.
toolkit
.
register_tool_function
(
run_pipeline
,
func_name
=
"run_pipeline"
,
group_name
=
"basic"
,
)
agent_hub_instance
.
register_skill_tool
(
"meeting_minutes"
,
run_pipeline
,
"run_pipeline"
)
yield
...
...
workspace/agent-admin/backend/app/service/agent_hub.py
View file @
846ee6f
...
...
@@ -99,6 +99,28 @@ class AgentHub:
group_name
=
"basic"
,
)
# 构建每个 agent 的专属 toolkit(按 skills 字段过滤)
self
.
agent_toolkits
:
Dict
[
str
,
Toolkit
]
=
{}
for
agent_code
,
agent_config
in
self
.
agents
.
items
():
agent_tk
=
Toolkit
()
# 复制 basic 组工具(所有 agent 共用)
for
name
,
tool
in
self
.
toolkit
.
tools
.
items
():
if
tool
.
group
==
"basic"
:
agent_tk
.
register_tool_function
(
tool
.
original_func
,
group_name
=
tool
.
group
,
func_name
=
tool
.
name
,
preset_kwargs
=
tool
.
preset_kwargs
,
)
# 只复制该 agent 配置的 skills
for
skill_name
in
agent_config
.
skills
:
if
skill_name
in
self
.
toolkit
.
skills
:
skill_info
=
self
.
toolkit
.
skills
[
skill_name
]
skill_dir
=
skill_info
.
get
(
"dir"
,
""
)
if
skill_dir
:
agent_tk
.
register_agent_skill
(
skill_dir
)
self
.
agent_toolkits
[
agent_code
]
=
agent_tk
def
_build_main_prompt
(
self
,
context
:
Dict
[
str
,
Any
],
...
...
@@ -253,13 +275,13 @@ class AgentHub:
if
history_msgs
:
await
agent_memory
.
add
(
history_msgs
)
# Create per-request ReActAgent with
shared singletons
# Create per-request ReActAgent with
per-agent toolkit
agent
=
ReActAgent
(
name
=
target_agent
,
sys_prompt
=
system_prompt
,
model
=
self
.
model
,
formatter
=
self
.
formatter
,
toolkit
=
self
.
toolkit
,
toolkit
=
self
.
agent_toolkits
.
get
(
target_agent
,
self
.
toolkit
)
,
memory
=
agent_memory
,
max_iters
=
10
,
)
...
...
@@ -310,7 +332,7 @@ class AgentHub:
sys_prompt
=
sub_prompt
,
model
=
self
.
model
,
formatter
=
self
.
formatter
,
toolkit
=
self
.
toolkit
,
toolkit
=
self
.
agent_toolkits
.
get
(
agent_code
,
self
.
toolkit
)
,
memory
=
sub_memory
,
max_iters
=
10
,
)
...
...
@@ -336,6 +358,16 @@ class AgentHub:
return
call_sub_agent
def
register_skill_tool
(
self
,
skill_name
:
str
,
tool_func
,
func_name
:
str
):
"""将工具注册到所有拥有该 skill 的 agent toolkit"""
for
agent_code
,
agent_config
in
self
.
agents
.
items
():
if
skill_name
in
agent_config
.
skills
:
self
.
agent_toolkits
[
agent_code
]
.
register_tool_function
(
tool_func
,
func_name
=
func_name
,
group_name
=
"basic"
,
)
async
def
close
(
self
):
"""Clean up resources (no-op with AgentScope)."""
pass
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment