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:
- Pre-flight gate (Step 0): if the user message lacks a time token (
+5m/HH:MM/ etc.) or task token, it must callask_userfirst — no defaulting to+10m, no inferring "probably 9am". - Runs
python3 scripts/init_scheduler_skill.py <short>to create the skill dir with hash suffix. - Patches the SKILL.md body (description + task + output format).
- Calls
add_scheduleto 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:
- Execute the existing scheduler skill immediately and output results
- Do not activate
scheduler-skill-creator - Do not run
init_scheduler_skill.py - Do not call
add_schedule
Daemon fire
runtime.SetRunner registers runSkill(ctx, sessionID, skillName). When the scheduler fires (cron tick or one-shot deadline), the runner:
- Reads body via
filesystem.ScheduleSkillBody(skillName). - Ensures the session directory exists; writes a default
bot.md. - 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
- Trace collection — during
Execute, every tool call result is recorded as anexecStep{Tool, Error}. If the skill's session usedrun_skillto activate additional skills, those are tracked too. - Trigger — at the end of
Execute(in the defer), if the trace contains at least one error,postSkillImproveruns synchronously for each activated skill. - Improvement agent —
postSkillImproveloads the built-inimprove-skillskill body, builds a stateless session with the execution trace, and runs a fullExecuteloop (2 min timeout, always-allow, no interactive tools). - 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
- The improvement agent cannot use interactive tools (
ask_user), web tools (search_web,fetch_page), media tools (generate_image), or agent-orchestration tools - Only file read/write and command execution are available — the agent reads the current skill, analyzes the trace, and writes corrected files
- Improvements are scoped to the skill's own files; system prompts and runtime code are never modified
- Each improvement run is a stateless session with no conversation history
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.