You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add lightweight pre-step to skip agent when no programs are due
The pre-step runs in Python before the agent starts and checks:
- Which programs are due based on per-program schedule + last_run
- Which are unconfigured (sentinel/placeholders still present)
- Which are paused or plateaued (5+ consecutive rejections)
If no programs are due, the workflow exits with no agent invocation.
This avoids burning agent compute on schedule ticks where nothing
needs to happen.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
result = {"due": due, "skipped": skipped, "unconfigured": unconfigured, "no_programs": False}
176
+
177
+
os.makedirs("/tmp/gh-aw", exist_ok=True)
178
+
with open("/tmp/gh-aw/autoloop.json", "w") as f:
179
+
json.dump(result, f, indent=2)
180
+
181
+
print("=== Autoloop Program Check ===")
182
+
print(f"Programs due: {due or '(none)'}")
183
+
print(f"Programs skipped: {[s['name'] for s in skipped] or '(none)'}")
184
+
print(f"Programs unconfigured: {unconfigured or '(none)'}")
185
+
186
+
if not due and not unconfigured:
187
+
print("\nNo programs due this run. Exiting early.")
188
+
sys.exit(1) # Non-zero exit skips the agent step
189
+
PYEOF
190
+
66
191
---
67
192
68
193
# Autoloop
@@ -99,7 +224,7 @@ Each program runs independently with its own:
99
224
- PR title prefix: `[Autoloop: {program-name}]`
100
225
- Repo memory namespace: keyed by program name
101
226
102
-
On each scheduled run, the workflow iterates through **all configured programs** and runs one iteration perprogram. Programs with the `<!-- AUTOLOOP:UNCONFIGURED -->` sentinel are skipped.
227
+
On each scheduled run, a lightweight pre-step checks which programs are due (based on per-program schedules and `last_run` timestamps). **If no programs are due, the workflow exits before the agent starts — zero agent cost.** Only due programs get iterated.
103
228
104
229
### Per-Program Schedule and Timeout
105
230
@@ -151,16 +276,18 @@ If **all** programs are unconfigured, exit after creating the setup issues. Othe
151
276
152
277
### Reading Programs
153
278
154
-
At the start of every run:
279
+
The pre-step has already determined which programs are due, unconfigured, or skipped. Read `/tmp/gh-aw/autoloop.json` at the start of your run to get:
280
+
281
+
-**`due`**: List of program names to run iterations for this run.
282
+
-**`unconfigured`**: Programs that still have the sentinel or placeholder content — run the **Setup Guard** for each of these (create setup issues).
283
+
-**`skipped`**: Programs not due yet based on their per-program schedule — ignore these entirely.
284
+
-**`no_programs`**: If `true`, no program files exist at all — create a single issue explaining how to add a program.
155
285
156
-
1. List all `.md` files in `.github/autoloop/programs/`.
157
-
2. If the directory is empty or doesn't exist, also check for a single `.github/autoloop/program.md` or `program.md` in the repo root as a fallback (for single-program setups).
158
-
3. For each program file:
159
-
a. Check for the `<!-- AUTOLOOP:UNCONFIGURED -->` sentinel — if present, run the **Setup Guard** for that program and skip it.
160
-
b. Parse the three sections: Goal, Target, Evaluation.
161
-
c. Validate that all three sections have non-placeholder content. If any section still contains `TODO` or `REPLACE` markers, treat it as unconfigured — create/update the setup issue for that program and skip it.
162
-
d. Read the current state of all target files.
163
-
e. Read repo memory for that program's metric history (keyed by program name).
286
+
For each program in `due`:
287
+
1. Read the program file from `.github/autoloop/programs/{name}.md`.
288
+
2. Parse the three sections: Goal, Target, Evaluation.
289
+
3. Read the current state of all target files.
290
+
4. Read repo memory for that program's metric history (keyed by program name).
0 commit comments