Expand description
Learning loop — detect successful multi-step tool sequences from completed sessions and synthesize reusable skill documents.
§Architecture
When a session closes (TTL expiry or rotation), the governor calls
learn_on_close. This function:
- Loads all tool calls for the session via
get_tool_calls_for_session() - Flattens them chronologically and runs
detect_candidate_procedures - For each candidate, either reinforces an existing learned skill or synthesises a new SKILL.md and persists it
No LLM call is involved — learning is pure template synthesis from observed tool-call data, keeping the hot path fast and deterministic.
Structs§
- Candidate
Procedure - A candidate procedure detected from a session’s tool-call history.
- Procedure
Step - A single step within a candidate procedure.
Functions§
- detect_
candidate_ procedures - Flatten tool calls from all turns into chronological order, then detect
consecutive sequences of ≥
min_lengthtools where the success ratio meets the threshold. - learn_
on_ close - Main entry point: called by the governor when a session closes.
- synthesize_
skill_ md - Generate a SKILL.md document from a candidate procedure.
- write_
learned_ skill - Write a learned skill to disk under
{skills_dir}/learned/.