trading_agent.skills.skill_library
¶
The skills one desk can use: the user's installed skills and the desk's own.
There are two homes, plus the skills of installed packages:
workspace/shared/skills/installed/
Only each skill's name and description go into the system prompt, as an index; load_skill reads a skill in full when the desk needs it. A skill whose required programs or environment variables are missing is hidden. When two skills share a name, the user's installed skill wins over a package's, and both win over the desk's own.
The library reads the folders afresh every time it is asked, so a newly imported or newly written skill shows up on the desk's next turn.
Typical usage example:
library = SkillLibrary(installed_directory, agent_directory) index = library.index_text() skill = library.find('opening-range-breakout')
HiddenSkill
dataclass
¶
A skill that cannot be used here, and why.
Attributes:
| Name | Type | Description |
|---|---|---|
skill |
Skill
|
The skill. |
missing |
tuple[str, ...]
|
The programs and environment variables it needs that are missing. |
SkillLibrary
¶
SkillLibrary(installed_directory, agent_directory, program_finder=which, environment=None, package_skill_roots=None)
Finds and checks one desk's skills.
Creates the library without reading anything.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
installed_directory
|
Path
|
The user's installed skills. |
required |
agent_directory
|
Path
|
The desk's own skills. |
required |
program_finder
|
Callable[[str], str | None]
|
Returns a program's path, or None when it is not installed; replaceable in tests. |
which
|
environment
|
Mapping[str, str] | None
|
The environment to check variables in; None uses os.environ. |
None
|
package_skill_roots
|
Callable[[], Sequence[Path]] | None
|
Returns the skills/ folders of installed packages, asked afresh each time, or None for no packages. |
None
|
Source code in src/trading_agent/skills/skill_library.py
available
¶
The skills the desk can use, installed ones first, each sorted by name.
Returns:
| Type | Description |
|---|---|
list[Skill]
|
The usable skills. |
Source code in src/trading_agent/skills/skill_library.py
hidden
¶
The skills hidden because something they need is missing.
Returns:
| Type | Description |
|---|---|
list[HiddenSkill]
|
The hidden skills and what each lacks. |
Source code in src/trading_agent/skills/skill_library.py
find
¶
Finds a usable skill by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The skill's name. |
required |
Returns:
| Type | Description |
|---|---|
Skill | None
|
The skill, or None when there is no usable skill of that name. |
Source code in src/trading_agent/skills/skill_library.py
find_agent_skill
¶
Finds one of the desk's own skills by name, usable or not.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The skill's name. |
required |
Returns:
| Type | Description |
|---|---|
Skill | None
|
The skill, or None when the desk wrote no skill of that name. |
Source code in src/trading_agent/skills/skill_library.py
is_installed_name
¶
Says whether one of the user's installed skills has a name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True when an installed skill has it. |
Source code in src/trading_agent/skills/skill_library.py
index_text
¶
The skills index for the system prompt.
Returns:
| Type | Description |
|---|---|
str
|
A titled section listing each usable skill's name and description, or saying there are none. |