Choose loop wakeup interval

From pjt222/agent-almanac · View interactive version

Choose loop wakeup interval is an AI agent skill from the GitHub repository pjt222/agent-almanac. Select a `delaySeconds` value when scheduling a loop wakeup via the `ScheduleWakeup` tool or the `/loop` slash command. Covers the three-tier cache-aware decision (cache-warm under 5 minutes, cache-miss 5 minutes to 1 hour, idle default 20 to 30 minutes), the 300-second anti-pattern, the [60, 3600]

How to use this skill

Skill file

Choose Loop Wakeup Interval

Pick delaySeconds for ScheduleWakeup → respects prompt cache 5-min TTL + scheduler whole-min granularity + [60, 3600] clamp. Non-trivial: "wait ~5 min" → worst-of-both zone → pay cache miss without amortizing wait.

Reasoning travels w/ ScheduleWakeup tool desc at call time → but loop already scheduled. This skill hoists reasoning → planning time.

Use When

In

Do

Step 1: Classify the Wait

Tier decision:

→ Classification: active-watch, cache-miss, or idle.

If err: Can't classify → no honest answer to "what waiting for?" → loop shouldn't exist → skip to Step 5.

Step 2: Apply Three-Tier Decision

Pick delaySeconds:

| Tier | Range | Cache | Use when |

|---|---|---|---|

| Cache-warm | 60 – 270 s | Warm (<5-min TTL) | Active watch — fast cheap re-entry |

| Cache-miss | 1200 – 3600 s | Cold; miss buys long wait | Idle, or event can't happen sooner |

| Idle default | 1200 – 1800 s (20–30 min) | Cold | No specific signal; periodic |

Do not pick 300 s. Worst-of-both: cache misses, wait too short to amortize. Reaching for "~5 min" → drop to 270 s (warm) or 1200 s+ (amortize).

→ Specific delaySeconds from one of three tiers, not round-minute habit.

If err: Keep landing on 300 s → real question is "should loop exist at this cadence?" → re-examine Step 1.

Step 3: Size for Minute Boundary

Scheduler fires on whole-min boundaries. delaySeconds = N → actual N to N + 60 s, depending on call second.

Example:

ScheduleWakeup({delaySeconds: 90}) at HH:MM:40 → target HH:(MM+2):00 → actual 140 s, not 90 s.

Sub-minute intent meaningless. Value = floor, not precise. Min of skew matters → cadence too tight for this mech.

→ Accepted actual wait up to 60 s longer than requested. Cache-warm: 270 s → ~330 s → tips into cache-miss.

If err: Near-ceiling values common (265 s for cache-warm) → pad down → 240 s preserves warmth under worst-case skew.

Step 4: Respect the Clamp

Runtime clamps delaySeconds → [60, 3600]. Out-of-range → silently adjusted. Telemetry: chosen_delay_seconds vs. clamped_delay_seconds + was_clamped: true.

Plan vs. clamped, not requested:

→ Value in [60, 3600] or clamp accepted.

If err: Genuinely multi-hour ("wake in 4 h") → chain wakeups (3600 s tick reschedules) or cron loop (CronCreate w/ kind: "loop").

Step 5: Write Specific `reason`

reason = telemetry + user status + cache-warmth reasoning. 200-char limit. Specific.

Reader = user glancing at status → write for them.

→ Concrete one-phrase reason sensible to glancing user.

If err: No specific reason → revisit loop existence (Step 1, Step 6).

Step 6: Recognize Don't-Loop Case

Not every "come back later" = scheduled wakeup. Do NOT schedule when:

→ Conscious choice: schedule wakeup vs. no loop. "Because I could" ≠ reason.

If err: User keeps interrupting wakeups → pattern wrong, not interval.

Check

Traps

Examples

Example 1 — Cache-warm active watch

bun build kicked off → agent checks quick → cache warm at results.

Example 2 — Idle heartbeat

Autonomous agent watches low-volume feed 1×/h.

Example 3 — Anti-pattern

Agent wants "wait 5 min" → remote API retries → 300 s req.

→

<!-- Keep under 500 lines. Current: ~200 lines. -->

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.