agentscope-ai / agentscope-ai/agentscope

[Bug]:skills不生效

未關閉
#1,383 2 則留言 0 個 reaction 已指派 1 人 已被 @qbc2016 認領 在 GitHub 檢視
stale-issue
主要語言
Python
星號
31.6k
分支
3.5k
平均合併
1 天 16 小時
30 天內合併 PR
103

描述

**AgentScope is an open-source project. To involve a broader community, we recommend asking your questions in English.**

**Describe the bug**
为什么我使用 https://github.com/joansongjr/cn-web-search 这个skills,通过tk.register_agent_skill(skill_dir)这个方法注册了skills,但是就是没发用呢?

**To Reproduce**
Steps to reproduce the behavior:

def enable_skills_for_agent(
self,
agent: AgentBase,
skill_names: List[str],
toolkit: Optional[Toolkit] = None
) -> bool:
"""为指定智能体启用特定技能

Args:
agent: 智能体实例
skill_names: 要启用的技能名称列表
toolkit: 可选的 Toolkit 实例,默认使用 agent.toolkit

Returns:
是否成功
"""
tk = toolkit or getattr(agent, 'toolkit', None)
if not tk:
logger.error(f"[SkillManager] 智能体 {agent.name} 没有 toolkit")
return False

enabled = []
for skill_name in skill_names:
if skill_name not in self._skills:
logger.warning(f"[SkillManager] 技能不存在: {skill_name}")
continue

skill_dir = self._skills[skill_name].directory

try:
# 使用官方方法注册技能
tk.register_agent_skill(skill_dir)
enabled.append(skill_name)
logger.info(f"[SkillManager] 为 {agent.name} 注册技能: {skill_name}")
except Exception as e:
logger.error(f"[SkillManager] 注册技能失败 {skill_name}: {e}")

# 记录该智能体已启用的技能
if agent.name not in self._agent_skills:
self._agent_skills[agent.name] = set()
self._agent_skills[agent.name].update(enabled) # 注意:ReActAgent 会自动将技能提示词附加到系统提示词中

return len(enabled) > 0

**Expected behavior**
A clear and concise description of what you expected to happen.

**Error messages**
Detailed error messages.

**Environment (please complete the following information):**

- AgentScope Version: [e.g. 1.0.0 via `print(agentscope.__version__)`]
- Python Version: [e.g. 3.10]
- OS: [e.g. macos, windows]

**Additional context**
Add any other context about the problem here.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。