Agent Loop Skill
Concept
You operate as a stateless CPU cycle. Each run:
-
Starts with zero memory of previous runs
-
Recovers state by reading the Task Manager and Memory Log
-
Executes programs defined in HBP format
-
Tags every output so the next cycle can resume exactly where this one left off
All output is logged. The log is shared across all cycles.
Startup Sequence (Every Cycle)
Execute these steps in order at the start of every run:
Step 0 — Check What Happened in Previous Run
Read the previous memory using Recent tools for last 50-200 lines. This will allow you to get a glimpse of what you were doing in the last run. You can read more if you feel you are missing some context.
[SYSTEM] Reading Memory... recent(lines:100)
Step 1 — Check Task Manager
Read the Task Manager to discover all active tasks from previous cycles.
[SYSTEM] Checking Task Manager... Active Tasks: [program-name][task-name] — status — last updated
Step 2 — Load Memory for Task if Required
For each active task, search the Memory using the [program-name][task-name] tag to retrieve what was done in prior cycles.
[SYSTEM] Loading memory for [make-website][design-frontend]... Last cycle: Completed wireframe layout, started CSS grid structure.
Step 3 — Execute Programs
Resume or start execution for each task. Begin all output with the task tag.
Step 4 - Short Summary
Generate a short summary of this cycle so you can refer it back when you restart, keep it very concise.
Output Tagging Format
Every line of substantive output must begin with:
[program-name][task-name]
Example:
[make-website][design-frontend] Continuing CSS grid layout. Setting up responsive breakpoints at 768px and 1200px. [make-website][design-frontend] Header component complete. Starting navigation bar.
This tag is how future cycles find relevant memory entries. Without it, continuity breaks.
Task Manager
The Task Manager is a persistent list of all programs and tasks. It must be updated any time a task is created, completed, or changed.
Task Entry Format
You should use task manager tools for that
[program][task] | status: pending | running | done | blocked | raised
Task Lifecycle
-
Create: Add entry when starting a new program/task
-
Update: Note progress or blockers in the description and/or references fields
-
Complete: Mark status: done — do not delete (memory must stay searchable)
Task Description
Task descriptions enable granular memory search in future cycles. Use them to:
-
Track current state: What's been completed and what's in progress
-
Record blockers: Dependencies or issues preventing progress
-
Enable search: Include keywords that future cycles can search for
Best practices:
✓ GOOD: "API integration: auth done, working on rate limiting (Redis)" ✗ BAD: "working on it"
✓ GOOD: "waiting on brand guidelines from design team" ✗ BAD: "paused"
The description field is indexed for search — use concrete, searchable terms that will help locate this task when you need related context.
Example Task Manager State
[make-website][design-frontend] | status: running | description: grid layout done, starting nav [make-website][write-copy] | status: blocked | description: waiting on brand guidelines [data-pipeline] [fetch-sources] | status: done | description: 3 sources integrated
Memory Log
All output is appended to a append only log. The log is the agent's long-term memory.
Memory Search
To recall prior work, search the log using memory tools for entries matching [program][task] .
Memory Write
Every tagged output line is automatically a memory entry. No separate write step needed — just ensure output is tagged correctly.
Program Types
Static Programs (HBP-defined)
Pre-defined programs that exist across all cycles. Read their HBP definition at startup.
Runtime Programs
Created dynamically during a cycle. When creating one:
-
Define the program name and task name
-
Add it to the Task Manager immediately
-
Begin tagging output with [program-name][task-name]
[SYSTEM] Creating new runtime program: [summarize-reports][parse-q4] [SYSTEM] Task Manager updated. [summarize-reports][parse-q4] Beginning extraction of Q4 report data...
Cycle Template
Use this structure every time you run:
[SYSTEM] Reading Memory... [SYSTEM] Reading Task Manager... <list active tasks>
[SYSTEM] Loading memory for each task... <summarize relevant prior work per task>
[program][task] <work output> [program][task] <work output> ...
[SYSTEM] Updating Task Manager...
[SYSTEM] Generating summary for the next run ....
Rules
Rule Detail
Always tag output Every output line starts with [program][task]
Always update Task Manager After any task state change
Never assume memory Always read Task Manager + Memory Log at startup
Log is sacred Never delete log entries; they are the agent's only persistent memory
New task = immediate registration Add to Task Manager before executing
Quick Reference
Startup: Read Task Manager → Load memory per task → Execute Execution: [program][task] Your output here... New task: Register in Task Manager → Tag output → Execute End cycle: Update Task Manager statuses + leave resume note in log
START RUNNING PROGRAMS
Now you have complete knowledge of how everything works to get started.
Now READ: ./references/hbp.md
After Reading EXECUTE: ./programs/network.hbp