Skip to content

Commit 7e9e3bb

Browse files
RoyLinRoyLin
authored andcommitted
fix(code): correct skill loading parameter from agent_dirs to skill_dirs
- Update README to use skill_dirs parameter instead of agent_dirs - Modify ahp_server_agent.py to load AHP skills using skill_dirs - Auto-detect ahp_skills directory and load if exists - Add logging for skill loading status The correct API is: session = agent.session(workspace, skill_dirs=['./path/to/skills']) Not: agent = Agent.create(config, agent_dirs=['./path/to/skills']) agent_dirs is for loading custom agent definitions (for task delegation), while skill_dirs is for loading custom skills (.md files).
1 parent b4e39eb commit 7e9e3bb

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

examples/ahp_server_agent.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,26 @@ async def initialize(self):
195195
import tempfile
196196
workspace = tempfile.mkdtemp(prefix="ahp_server_")
197197
198+
# 获取 AHP skills 目录路径
199+
ahp_skills_dir = Path(__file__).parent / "ahp_skills"
200+
198201
# 创建会话(用于安全分析)
199-
self.session = self.agent.session(
200-
workspace,
201-
permissive=True,
202-
builtin_skills=False,
203-
)
202+
# 如果 AHP skills 目录存在,则加载它们
203+
if ahp_skills_dir.exists():
204+
self.session = self.agent.session(
205+
workspace,
206+
permissive=True,
207+
builtin_skills=False,
208+
skill_dirs=[str(ahp_skills_dir)], # 加载 AHP safety skills
209+
)
210+
self.log(f"✓ 已加载 AHP safety skills: {ahp_skills_dir}")
211+
else:
212+
self.session = self.agent.session(
213+
workspace,
214+
permissive=True,
215+
builtin_skills=False,
216+
)
217+
self.log(f"⚠ AHP skills 目录不存在: {ahp_skills_dir}")
204218
205219
self.log(f"✓ 智能体已初始化")
206220
self.log(f" 工作空间: {workspace}")

examples/ahp_skills/README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,15 @@
5252
```python
5353
from a3s_code import Agent
5454

55-
# 创建智能体时指定 skills 目录
56-
agent = Agent.create(
57-
config_path,
58-
agent_dirs=["./examples/ahp_skills"] # 加载 AHP skills
59-
)
55+
# 创建智能体(不需要在这里指定 skills)
56+
agent = Agent.create(config_path)
6057

61-
# 创建会话时启用 skills
58+
# 创建会话时指定 skills 目录
6259
session = agent.session(
6360
workspace,
6461
permissive=True,
6562
builtin_skills=True, # 启用内置 skills
63+
skill_dirs=["./examples/ahp_skills"] # 加载自定义 AHP skills
6664
)
6765
```
6866

0 commit comments

Comments
 (0)