trading_agent.skills.skill_usage
¶
Records each use of a skill, and whether the turn that used it went smoothly.
The tracker listens to the event bus, like the journal. A load_skill call opens a use; every failed tool call after it in the same turn counts against it; when the desk's turn finishes, the use is written as one JSON line to workspace/desks/<desk>/skills/usage.jsonl. A turn that ends in an error marks the use as failed.
"Went smoothly" is a rough signal, not a verdict: a tool can fail for reasons the skill did not cause. The curator reads these numbers as hints about which skills to review.
Typical usage example:
tracker = SkillUsageTracker(event_bus, layout) task = asyncio.create_task(tracker.run()) statistics = SkillUsageReader(usage_file).statistics()
SkillStatistics
dataclass
¶
How one skill has been used.
Attributes:
| Name | Type | Description |
|---|---|---|
uses |
int
|
How many turns loaded it. |
troubled_uses |
int
|
How many of those turns had failed tool calls after loading it, or ended in an error. |
last_used |
str
|
The ISO 8601 time of the last use. |
SkillUsageTracker
¶
Turns the event stream into skill-use records.
Subscribes to the bus at once, so no load_skill call is missed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_bus
|
EventBus
|
The bus to listen to. |
required |
layout
|
WorkspaceLayout
|
Where each desk's usage file goes. |
required |
Source code in src/trading_agent/skills/skill_usage.py
run
async
¶
Handles events until the task is cancelled.
handle
¶
Updates the open uses with one event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
published_event
|
Event
|
The event. |
required |
Source code in src/trading_agent/skills/skill_usage.py
SkillUsageReader
¶
Summarises one desk's usage file.
Creates the reader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
usage_file
|
Path
|
The desk's usage.jsonl. |
required |
Source code in src/trading_agent/skills/skill_usage.py
statistics
¶
Counts each skill's uses.
Returns:
| Type | Description |
|---|---|
dict[str, SkillStatistics]
|
The statistics, keyed by skill name; skills never used are absent. |