trading_agent.subagents.subagent_library
¶
The subagents every desk can delegate to.
Definitions are Markdown files in workspace/shared/agents/, which belongs to the user, and in the agents/ folder of each installed package. When two files define the same name, the user's own folder wins. The folders are read afresh every time, so a new definition is available on the desk's next turn.
Typical usage example:
library = SubagentLibrary(Path('workspace/shared/agents'), packages.agent_roots) definition = library.find('news_reader')
BrokenDefinition
dataclass
¶
A subagent file that could not be read, and why.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
Path
|
The file. |
error |
str
|
The reason. |
SubagentLibrary
¶
Finds subagent definitions.
Describes the folders without reading them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agents_directory
|
Path
|
workspace/shared/agents. |
required |
package_agent_roots
|
Callable[[], Sequence[Path]] | None
|
Returns the agents/ folders of installed packages, or None for no packages. |
None
|
Source code in src/trading_agent/subagents/subagent_library.py
definitions
¶
Every readable definition, the user's first, without repeated names.
Returns:
| Type | Description |
|---|---|
list[SubagentDefinition]
|
The subagents. |
Source code in src/trading_agent/subagents/subagent_library.py
broken
¶
The files that could not be read.
Returns:
| Type | Description |
|---|---|
list[BrokenDefinition]
|
Each broken file and why. |
find
¶
Finds one subagent by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name. |
required |
Returns:
| Type | Description |
|---|---|
SubagentDefinition | None
|
The subagent, or None when there is none of that name. |
Source code in src/trading_agent/subagents/subagent_library.py
index_text
¶
The section of the desk's prompt listing its subagents.
Returns:
| Type | Description |
|---|---|
str
|
The section, or an empty string when there are no subagents. |