Skip to main content

Module learning

Module learning 

Source
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:

  1. Loads all tool calls for the session via get_tool_calls_for_session()
  2. Flattens them chronologically and runs detect_candidate_procedures
  3. 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§

CandidateProcedure
A candidate procedure detected from a session’s tool-call history.
ProcedureStep
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_length tools 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/.