Engineer agent loops
Skill Rowan2005321/loop-contracts/skills/engineer-agent-loops
Machine-checkable control contracts between agent harnesses and repeated agent loops
npx -y skills add Rowan2005321/loop-contracts --skill engineer-agent-loopsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 18 days oldThe repository was created 18 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Design, audit, and repair bounded agent execution loops by connecting harness capabilities to explicit state, progress signals, budgets, verification, recovery, observability, human gates, and stop conditions. Use when Codex needs to turn a recurring or long-running agent workflow into a machine-checkable loop contract, diagnose retries or false completion, compare loop designs, or add safety and resumability to autonomous work.
SKILL.md
5.1 KB, 968 tokens by cl100k_base, as published. Nobody here has run it
Engineer Agent Loops
Core model
Treat the harness and the loop as different layers:
Harness = what an agent can observe and do during a run
Loop = when and why the run repeats, changes state, stops, or escalates
Contract = harness capabilities + temporal control + evidence
Produce a loop contract, not a new agent framework. Keep model choice and runtime implementation replaceable.
Choose the task mode
- Design: create a new contract from a workflow or recurring task.
- Audit: inspect an existing agent loop, scheduler, workflow, or orchestration file without changing it.
- Repair: modify a contract or loop design to fix specific findings.
- Compare: score two designs against the same invariants and explain the tradeoffs.
Do not create a persistent loop for a one-shot task unless repetition, resumption, or unattended execution is actually required.
Workflow
-
Inventory the harness
- Identify available tools, permissions, context sources, state storage, sandboxes, hooks, and external side effects.
- Separate confirmed capabilities from proposed capabilities.
- Mark destructive actions, external writes, money movement, credential use, and permission expansion as high risk.
-
Define the loop boundary
- State one measurable objective and the work-discovery source.
- Declare
execution_modeassingle-run,event-driven,scheduled, orqueue-worker. - Define the smallest independently verifiable unit of work.
- Name the initial, recovery, terminal, and human-escalation states.
- Prefer
observe -> plan -> act -> verifyover a free-formwhile trueloop.
-
Specify evidence and progress
- Use deterministic verification when available: tests, schemas, exit codes, hashes, diffs, or policy checks.
- Do not let the producing agent be the only judge of success.
- Define progress signals and a fingerprint that detects repeated state/action/observation triples.
- Require verification evidence before entering
done.
-
Bound and recover
- Set at least two hard budgets, normally iterations plus wall time; add cost or tool-call budgets where relevant.
- Bound every retry by failure class.
- Define rollback, checkpoint, resume, no-progress, and budget-exhaustion behavior.
- Escalate when the loop lacks authority or new evidence, rather than repeating a failed action.
- For scheduled or queue-worker loops, define per-item budgets, lease expiry, a durable cursor, quarantine-and-continue behavior, concurrency, and a disable switch.
-
Draft the contract
- Copy
assets/loop-contract.template.jsonand adapt it. - Read
references/contract-schema.mdwhen changing fields or writing an integration. - Read
references/loop-patterns.mdonly for the relevant loop shape.
- Copy
-
Validate and visualize
-
Run:
python scripts/loop_contract.py validate <contract.json> python scripts/loop_contract.py score <contract.json> python scripts/loop_contract.py diagram <contract.json> -
Fix all errors. Explain accepted warnings rather than hiding them.
-
Treat the score as a coverage heuristic, not proof that the runtime is safe.
-
-
Hand off implementation
- Name the runtime hooks needed for each transition, signal, gate, and verifier.
- Preserve the contract as the source of truth; avoid duplicating rules only in prompts.
- Do not enable schedules, external writes, or production execution unless the user requested that operational change.
Non-negotiable invariants
- Every loop has reachable terminal states for success and escalation or failure.
- Every cycle is bounded by budgets and a no-progress detector.
- Every retry is failure-specific and finite.
donerequires recorded evidence from named verification conditions.- State is externalized enough to resume or explain why resumption is impossible.
- High-risk actions have explicit permissions and human gates.
- Traces record state transitions, actions, observations, verification, interventions, and the stop reason.
- A new attempt must change evidence, strategy, authority, or context. Repetition alone is not recovery.
- One malformed queue item must be quarantined after bounded attempts and must not block unrelated work.
Output contract
Return:
- confirmed harness inventory and unresolved assumptions;
- the loop contract path or proposed contract;
- validator errors, warnings, and score;
- a state diagram;
- runtime integration points;
- residual risks and the next safe test.
Never claim that static validation proves model correctness, business correctness, or production safety.
What ships with it: 5 files
45.2 KB alongside SKILL.md, 1 of them executable
agents/
- openai.yaml240 B
assets/
references/
- contract-schema.md5.4 KB
- loop-patterns.md2.6 KB
scripts/
- loop_contract.pyruns32.7 KB