cron-agent-patterns
Layered timeout defense for cron-orchestrated agents calling external APIs (LLM CLI, HTTP, subprocess) — nested tiers, anti-patterns, headroom.
Skill by Arcanada-one
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/arcanada-one-cron-agent-patterns
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: ml, agent-building
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/cron-agent-patterns
What's inside
- Skill name
cron-agent-patterns- Description
- Layered timeout defense for cron-orchestrated agents calling external APIs (LLM CLI, HTTP, subprocess) — nested tiers, anti-patterns, headroom.
- License
- MIT
- Instructions
- 101 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Cron-Agent Patterns
> **TL;DR:** A cron-orchestrated agent that makes external API calls (LLM CLI,
> HTTP client, subprocess) can hang, drift past its window, or overlap the next
> cron tick. Defend with **nested timeouts** — each tier strictly smaller than
> the one enclosing it — plus symmetric deadline guards and explicit headroom
> for the next fallback tier.
## When To Apply
Load this skill when implementing or reviewing any agent that:
- runs on a schedule (cron, systemd timer, `sleep`-loop) **and**
- makes calls that can block indefinitely — LLM CLI subprocess, HTTP request,
shell-out, DB query, or a provider fallback chain.
The pattern is **stack-agnostic** — the tier names below map onto any runtime
(Python `signal`/`subprocess`, Node timers/`AbortController`, Go `context`,
shell `timeout`).
## The Layered Timeout Ladder
Order the timeouts so each inner budget is strictly smaller than the budget
enclosing it. Violating the strict-nesting invariant means an inner tier can
never fire before the outer one preempts it — the inner guard becomes dead code.
```
(a) per-call timeout < (b) per-cycle deadline budget
(wall-clock, time.monotonic)
(b) per-cycle deadline < (c) SIGALRM safety net
(catches C-level blocked syscalls the
library-level timeout cannot interrupt)
(c) SIGALRM safety net < (d) shell `timeout --kill-after` outermost guard
(cron-level watchdog; kills the whole
process tree if everything above wedges)
```
- **(a) Per-call timeout.** Bound every individual external call (HTTP read
timeout, subprocess timeout, LLM CLI `--timeout`). Must be short enough that
the whole cycle — including retries and fallbacks — still fits inside (b).
- **(b) Per-cycle deadline budget.** Compute a monotonic deadline once at
cycle start (`deadline = time.monotonic() + CYCLE_BUDGET_SEC`). Before every
external call, check `time.monotonic() < deadline`; skip the call if not.
- **(c) SIGALRM safety net.** A library-level timeout cannot interrupt a call
blocked in a C-level syscall. Arm `SIGALRM` (or the runtime's equivalent
hard alarm) so the process is forced back into your handler and raises a
`CycleTimeout`.
- **(d) Shell outermost guard.** Wrap the whole invocation in
`timeout --kill-after=<grace> <hard-limit> <cmd>`. This is the last line of
defense when everything in-process has wedged. Set it above (c) so the
in-process net gets first chance to exit cleanly.
## Anti-Patterns (each caused a real incident)
- **Per-call timeout == cycle budget.** If the per-call limit equals the whole
cycle budget, the math forbids the call from ever fitting alongside retries
or the next-tier fallback. A single slow call consumes the entire window.
- **`max(N, deadline - now)` floor.** Flooring a per-call timeout at a constant
`N` re-inflates a doomed call after the deadline has already passed:
once `deadline - now` goes negative, `max(1.0, deadline - now)` stages a
fresh 1-second call *past* the deadline. Never floor the remaining budget —
if `deadline - now <= 0`, skip the call, do not clamp it back up.
- **`except Exception: pass` swallowing the alarm.** A bare
`except Exception:` around the call body silently eats the exception raised
by the SIGALRM handler, so the safety net never propagates. **Re-raise**
`CycleTimeout` (or the equivalent) *before* the generic handler:
```python
try:
result = call_provider(...)
except CycleTimeout:
raise # let the safety net escape
except Exception:
log_and_continue() # only ordinary failures land here
```
## Required Guards
- **Symmetric deadline-passed guards in every fallback tier.** A fallback chain
(primary → secondary → tertiary provider) must check the deadline *before
each* tier, not only before the first. Otherwise the chain keeps trying new
providers well past the cycle deadline.
- **Explicit headroom reservation for the next-tier fallback.** Reserve time so
a fallback can still run after the primary times out. Subtract a named
reserve constant (e.g. `MC_RESERVE_SEC`) from the budget handed to each tier:
`tier_budget = (deadline - now) - RESERVE_SEC`. Without headroom the primary
consumes the whole budget and the fallback is dead on arrival — producing
duplicate timeout alerts with no recovery.
## Checklist
- [ ] Each timeout tier is strictly smaller than the tier enclosing it (a<b<c<d).
- [ ] Cycle deadline computed once with a monotonic clock at cycle start.
- [ ] Per-call timeout never floored back above the remaining budget.
- [ ] Deadline checked before **every** external call and **every** fallback tier.
- [ ] SIGALRM (or equivalent) armed for C-level blocked syscalls.
- [ ] `CycleTimeout` re-raised before any generic `except`.
- [ ] Explicit headroom reserved for the next fallback tier.
- [ ] Shell `timeout --kill-after` wraps the whole invocation as outermost guard.From Arcanada-one/datarim, MIT.
More from Arcanada-one/datarim
- 0.642score
human-outcome-reporting
Arcanada-one
Explain human-facing task outcomes with requirements, evidence, honest acceptance status and read-only re-explanation, inside or outside Datarim.
SkillAFreshness: A★ 16Claude Code +9 - 0.640score
finishing-a-development-branch
Arcanada-one
Use when implementation is complete and all tests pass.
SkillAFreshness: A★ 16Claude Code +9 - 0.639score
hypothesis-validation
Arcanada-one
Use when a product decision depends on an uncertain claim and needs a bounded, falsifiable check.
SkillAFreshness: A★ 16Claude Code +9 - 0.637score
diataxis-docs
Arcanada-one
Diátaxis documentation taxonomy mandate four orthogonal categories tutorials how-to reference explanation for every Datarim-managed repo and product site
SkillAFreshness: A★ 16Claude Code +9 - 0.637score
artifact-context
Arcanada-one
Canonical conventions for native agents generating or editing Datarim artifacts, including stage headers, frontmatter, and exact contract quotations.
SkillAFreshness: A★ 16Claude Code +9 - 0.637score
customer-delivery
Arcanada-one
Enforce delivery from a verbatim requirement through pre-work knowledge selection, production evidence, and disposition; excludes enabling-only closure.
SkillAFreshness: A★ 16Claude Code +9 - 0.637score
ai-quality
Arcanada-one
Five pillars of AI-assisted development — decomposition, TDD, architecture-first, focused work, context.
SkillAFreshness: A★ 16Claude Code +9 - 0.637score
brainstorming
Arcanada-one
MUST use this before any creative work — features, components, functionality, behavior changes.
SkillAFreshness: A★ 16Claude Code +9 - 0.637score
compliance
Arcanada-one
Post-QA hardening — detects task type (code, docs, research, legal, content, infra) and applies the matching verification checklist before archiving.
SkillAFreshness: A★ 16Claude Code +9 - 0.637score
consilium
Arcanada-one
Assemble a panel of Datarim agents for multi-perspective analysis of decisions.
SkillAFreshness: A★ 16Claude Code +9 - 0.637score
context-window-self-clearing
Arcanada-one
Preserve Datarim task continuity while orchestrated Claude Code or Codex sessions compact or clear context at deterministic pressure thresholds.
SkillAFreshness: A★ 16Claude Code +9 - 0.637score
adversarial-review
Arcanada-one
Forces an adversarial mindset on a plan, PRD, design, or code change — break it rather than bless it.
SkillAFreshness: A★ 16Claude Code +9
Signals
- Stars
- 16
- Forks
- 1
- Open issues
- 0
- Last commit (this folder)
- Oct 4, 2026 (25 days ago)
- Last release
- Oct 22, 2026 (6 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/Arcanada-one/datarim
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from Arcanada-one
- 0.642score
human-outcome-reporting
Arcanada-one
Explain human-facing task outcomes with requirements, evidence, honest acceptance status and read-only re-explanation, inside or outside Datarim.
SkillAFreshness: A★ 16Claude Code +9 - 0.640score
finishing-a-development-branch
Arcanada-one
Use when implementation is complete and all tests pass.
SkillAFreshness: A★ 16Claude Code +9 - 0.639score
hypothesis-validation
Arcanada-one
Use when a product decision depends on an uncertain claim and needs a bounded, falsifiable check.
SkillAFreshness: A★ 16Claude Code +9 - 0.637score
brainstorming
Arcanada-one
MUST use this before any creative work — features, components, functionality, behavior changes.
SkillAFreshness: A★ 16Claude Code +9 - 0.637score
artifact-context
Arcanada-one
Canonical conventions for native agents generating or editing Datarim artifacts, including stage headers, frontmatter, and exact contract quotations.
SkillAFreshness: A★ 16Claude Code +9 - 0.637score
ai-quality
Arcanada-one
Five pillars of AI-assisted development — decomposition, TDD, architecture-first, focused work, context.
SkillAFreshness: A★ 16Claude Code +9
Cite this page
cron-agent-patterns skill. Agent Mart. https://agentmart.dev/skills/arcanada-one-cron-agent-patterns (last updated 2026-10-24)