Documentation

Scheduler & Self-Improvement

This page covers automated scheduling and the self-repair mechanism.

Scheduler skills (isolated namespace)

Scheduler-triggered skills live in a separate tree, not scanned by host.Scanner():

~/.config/agenvoy/skills/scheduler/<short>-<hash8>/SKILL.md
Aspect Regular skill Scheduler skill
Path ~/.config/agenvoy/skills/<name>/SKILL.md ~/.config/agenvoy/skills/scheduler/<short>-<hash8>/SKILL.md
Frontmatter name <name> <short>-<hash8> (no scheduler- prefix)
/<name> autocompletion yes no — surfaced as /sched-<name> (warn-purple) at the bottom of the picker
Trigger MatchSkillCall then run_skill (a) cron / one-shot fire from daemon runtime.SetRunner, (b) manual /sched-<name> from TUI

Creation flow

The scheduler-skill-creator skill is the canonical entry for new schedules. It:

  1. Pre-flight gate (Step 0): if the user message lacks a time token (+5m / HH:MM / etc.) or task token, it must call ask_user first — no defaulting to +10m, no inferring "probably 9am".
  2. Runs python3 scripts/init_scheduler_skill.py <short> to create the skill dir with hash suffix.
  3. Patches the SKILL.md body (description + task + output format).
  4. Calls add_schedule to bind the schedule.

Direct add_schedule calls are allowed only for rebinding existing schedules (changing the time of an already-created scheduler skill).

Manual execution (/sched-<name>)

The TUI command picker lists every directory under scheduler/ as /sched-<name>. Selecting one reads the body and dispatches it to the current agent with a preamble that blocks weaker models from misreading the SKILL.md-shaped body as a schedule-creation request and re-running the creator.

The preamble enforces:

Daemon fire

runtime.SetRunner registers runSkill(ctx, sessionID, skillName). When the scheduler fires (cron tick or one-shot deadline), the runner:

  1. Reads body via filesystem.ScheduleSkillBody(skillName).
  2. Ensures the session directory exists; writes a default bot.md.
  3. Calls exec.ExecWithSubagent(ctx, body, sessionID, "", "", nil) — an in-process subagent with always-allow context.

One-shot tasks are removed and the skill dir is trashed after a successful fire.

Self-improvement (auto-fix on failure)

When a skill execution encounters tool errors, Agenvoy automatically rewrites the skill definition to prevent the same failure next time. This is a closed-loop evolution cycle — no user intervention required.

How it works

  1. Trace collection — during Execute, every tool call result is recorded as an execStep{Tool, Error}. If the skill's session used run_skill to activate additional skills, those are tracked too.
  2. Trigger — at the end of Execute (in the defer), if the trace contains at least one error, postSkillImprove runs synchronously for each activated skill.
  3. Improvement agentpostSkillImprove loads the built-in improve-skill skill body, builds a stateless session with the execution trace, and runs a full Execute loop (2 min timeout, always-allow, no interactive tools).
  4. Auto-commit — on success, skill.AutoCommit(ctx, "improve", skillName) commits the rewritten files under ~/.config/agenvoy/skills/ to git, creating a versioned history of improvements.

What the improve-skill fixes

Issue detected Action
Wrong tool name in SKILL.md (e.g. Bash instead of run_command) Replace with correct registered tool name
Step caused repeated failures Add fallback strategy or remove the step
Unclear instruction caused LLM miscall Rewrite with more precise wording
Step ordering caused dependency failure Reorder steps
Typos or grammar issues Fix while preserving original language

Constraints

Rollback

All skill changes are auto-committed to git. Use git_log (tag=skills) to inspect history or git_rollback (tag=skills) to revert an unwanted auto-fix.


[!NOTE] This document was auto-generated by Claude after reading the full source code.