Skip to main content

Module skill_review

Module skill_review 

Source
Expand description

Helpers for the autonomous skill-review pipeline.

Skill review takes the conversation trace from a completed turn and decides whether the agent’s approach is worth saving as a reusable skill. The first step is converting the raw Vec<Message> into a structured tool-trajectory the review LLM can reason about — without drowning in tool I/O bytes.

The shape is deliberately small (one builder, one truncation knob) so that future steps in the pipeline (success heuristics, evolution decisions) can compose on top without entangling.

Module entry points:

  • build_tool_trajectory — render a Vec<Message> to a step list
  • assess_success — cheap heuristic that flags failed/aborted turns so the review LLM doesn’t waste budget packaging them as skills

Structs§

AppliedAction
Outcome of applying a review action; logged by the caller.
SkillReviewJob
Asynchronous queue for end-of-turn skill review requests. The agent loop enqueues a chat_id after a successful turn; a dedicated worker task drains the queue and invokes run_skill_review without blocking the request path.
SkillReviewQueue
SkillReviewWorker
Owning side of the skill-review queue. Created together with the SkillReviewQueue handle and consumed by spawn_skill_review_worker.

Enums§

LearnOutcome
Outcome of one review pass, rich enough for a user-facing reply (the /learn command) while the autonomous path just logs it.
ReviewAction
Decoded review verdict. Accepts both the new {"action": "create"|"edit"|"patch"|"none", ...} shape and the legacy {"create": true|false, ...} shape so older self-hosted prompts and fine-tuned models keep working through the upgrade.
SuccessSignal
Cheap, no-LLM verdict on whether a completed turn is “successful enough” to mine for a reusable skill. We bias toward false positives (review more) over false negatives (miss a good skill) — only the clear failure shapes are flagged as Unlikely.
TrajectoryStep
One step in the rendered trajectory.

Constants§

DEFAULT_TEXT_PREVIEW_CHARS
Cap per assistant/user text block. Long-form messages (essays, pasted-in code) get summarized; concise reasoning narrations pass through unchanged.
DEFAULT_TOOL_INPUT_PREVIEW_CHARS
Cap per-tool-input JSON in the rendered trajectory. Generous enough to preserve typical commands/queries, tight enough that one giant bash payload doesn’t blow up the review prompt.
DEFAULT_TOOL_RESULT_PREVIEW_CHARS
Cap per-tool-result body in the rendered trajectory. Tool results are often the bulk of token cost; the head usually carries the headline, so head-only truncation is fine for review purposes.

Functions§

apply_review_action
Validate + apply a review action against the skills directory on disk. Returns Ok(Some(_)) when a file was written, Ok(None) for None / Malformed, or Err(_) when the action failed validation (already- existing name on create, missing target on edit/patch, immutable human-curated target, injection-scan failure, etc.).
archive_inactive_agent_skills
Move stale agent-created skills out of the active discovery path. Targets a skill iff should_archive_skill returns true for its (mtime, last activation) pair against threshold_days.
assess_success
Inspect the trailing assistant text + the tool-result mix to decide whether the task looks completed. Designed to be safe to call even on short or pathological message lists.
build_skill_review_channel
Build the (handle, worker) pair that goes into AppState and the scheduler boot, respectively.
build_tool_trajectory
Render the conversation as an ordered, structured tool trajectory suitable for feeding to a review LLM. Image blocks are dropped (no text signal) and oversized payloads are head-truncated using the DEFAULT_*_PREVIEW_CHARS caps. The output is human-readable Markdown — the leading numbers make it easy for the LLM to reference specific steps in its rationale.
parse_review_action
run_skill_review
Run the full review pipeline for one chat. Safe to call repeatedly for the same chat — the cap on agent-created skills and the duplicate-name check inside skill creation prevent runaway writes.
run_skill_review_core
Full review pipeline for one chat. forced is the /learn path: it bypasses the feature gate, the tool-call threshold, and the success heuristic — the user explicitly asked for distillation — but keeps the agent-created cap and every content-security check.
should_archive_skill
Pure decision rule for the auto-archive sweep — extracted so the policy can be unit-tested without touching the filesystem clock. Returns true iff the candidate skill should be archived.
spawn_skill_review_worker
Run the worker loop on the current task. Drains all immediately- available jobs into a dedup set before processing, so a flurry of enqueues for the same chat collapses to one review.