|
7 | 7 |
|
8 | 8 | Skills directory convention: |
9 | 9 | skills/ |
10 | | - ontology-design/ |
| 10 | + skill-name/ |
11 | 11 | SKILL.md # required: YAML frontmatter + markdown body |
12 | 12 | references/ # optional: bundled reference documents |
13 | | - owl_spec.md |
14 | 13 | scripts/ # optional: bundled template scripts |
15 | | - template.py |
16 | 14 |
|
17 | | -Single agent: full skill body is always injected. |
18 | | -Multiple skills: catalog mode (metadata only) shown initially; |
19 | | -the retrieve node selects relevant skills per task and injects their full bodies. |
| 15 | +Single skill: full body always injected into the system prompt. |
| 16 | +Multiple skills: catalog mode (name + description only) shown initially; |
| 17 | + the retrieve node selects relevant skills per task and injects full bodies. |
20 | 18 | """ |
21 | 19 |
|
22 | | -from BaseAgent import BaseAgent |
| 20 | +from BaseAgent import BaseAgent, Skill |
23 | 21 | from BaseAgent.agent_spec import AgentSpec |
24 | 22 |
|
25 | 23 | SKILLS_DIR = "examples/skills" |
26 | 24 |
|
27 | 25 | # -------------------------- |
28 | | -# Single agent, all skills (legacy glob mode — no AgentSpec) |
| 26 | +# Single agent, single skill |
29 | 27 | # -------------------------- |
30 | | -agent = BaseAgent(skills_directory=SKILLS_DIR) |
31 | | -# All SKILL.md files under SKILLS_DIR are loaded. |
32 | | -# With multiple skills, the system prompt shows a catalog; the retrieve node |
33 | | -# selects relevant skill bodies on each run. |
| 28 | +# With one skill, the full body is always injected — no catalog mode. |
| 29 | +agent = BaseAgent() |
| 30 | +agent.add_skill(f"{SKILLS_DIR}/data-analyst/SKILL.md") |
34 | 31 |
|
35 | 32 | # -------------------------- |
36 | | -# Single agent, ad-hoc skill from object |
| 33 | +# Ad-hoc skill from object |
37 | 34 | # -------------------------- |
38 | | -from BaseAgent.resources import Skill |
39 | | - |
| 35 | +# Build a Skill inline without a SKILL.md file. |
40 | 36 | agent2 = BaseAgent() |
41 | 37 | agent2.add_skill(Skill( |
42 | | - name="cypher-export", |
43 | | - description="Best practices for exporting data to Memgraph via Cypher", |
44 | | - tools=["run_python_repl"], |
45 | | - instructions="## Cypher Export\n1. Batch nodes in chunks of 1000\n2. Use MERGE to avoid duplicates", |
| 38 | + name="citation-formatter", |
| 39 | + description="Formats literature references in APA or Vancouver style", |
| 40 | + tools=[], |
| 41 | + instructions="## Citation rules\n1. Vancouver: number citations in order of appearance.\n2. APA: Author, Year, Title, Journal, DOI.", |
46 | 42 | )) |
47 | 43 |
|
48 | 44 | # -------------------------- |
49 | | -# Multi-agent setup (spec-driven targeted loading) |
| 45 | +# Multi-agent, glob mode (all skills) |
| 46 | +# -------------------------- |
| 47 | +# load_skills() globs all SKILL.md files under SKILLS_DIR. |
| 48 | +# With 3 skills progressive disclosure applies: the system prompt initially |
| 49 | +# shows a catalog (name + description only); the retrieve node injects full |
| 50 | +# skill bodies relevant to each task. |
| 51 | +agent3 = BaseAgent(skills_directory=SKILLS_DIR) |
| 52 | + |
| 53 | +# -------------------------- |
| 54 | +# Multi-agent, targeted loading |
50 | 55 | # -------------------------- |
51 | 56 | # Each agent loads ONLY the skills it needs: |
52 | | -# spec.skill_names → loads {skills_directory}/{name}/SKILL.md directly (no glob) |
| 57 | +# spec.skill_names → resolves {skills_directory}/{name}/SKILL.md directly. |
| 58 | +# Skill names must exactly match the subdirectory name under SKILLS_DIR. |
53 | 59 |
|
54 | | -oncology_agent = BaseAgent( |
| 60 | +analyst_agent = BaseAgent( |
55 | 61 | skills_directory=SKILLS_DIR, |
56 | 62 | spec=AgentSpec( |
57 | | - name="oncology_agent", |
58 | | - role="A disease domain expert that defines disease ontology schemas", |
59 | | - skill_names=["oncology_agent_protocol"], |
| 63 | + name="analyst-agent", |
| 64 | + role="A data analyst that profiles and summarises tabular biomedical datasets", |
| 65 | + skill_names=["data-analyst"], |
60 | 66 | ), |
61 | 67 | ) |
62 | 68 |
|
63 | | -mapping_agent = BaseAgent( |
| 69 | +mapper_agent = BaseAgent( |
64 | 70 | skills_directory=SKILLS_DIR, |
65 | 71 | spec=AgentSpec( |
66 | | - name="mapping_agent", |
67 | | - role="An ontology alignment agent that maps extracted data to OWL terms", |
68 | | - skill_names=["mapping_agent_protocol"], |
| 72 | + name="mapper-agent", |
| 73 | + role="An ontology alignment agent that maps tabular columns to OWL terms", |
| 74 | + skill_names=["ontology-mapper"], |
69 | 75 | ), |
70 | 76 | ) |
| 77 | + |
| 78 | +# -------------------------- |
| 79 | +# Bundled resources |
| 80 | +# -------------------------- |
| 81 | +# The ontology-mapper skill has a references/ subdirectory. |
| 82 | +# When any loaded skill has bundled resources, BaseAgent injects |
| 83 | +# read_skill_resource(skill_name, path) into the REPL namespace so the |
| 84 | +# agent can read those files at runtime: |
| 85 | +# |
| 86 | +# content = read_skill_resource("ontology-mapper", "references/owl_primer.md") |
| 87 | +# |
| 88 | +# Path traversal outside the skill directory is blocked. |
0 commit comments