-
Notifications
You must be signed in to change notification settings - Fork 0
Multi Loop Orchestration
As autonomous agent workflows mature, a single repository will frequently run multiple concurrent or staggered loops. Multi-Loop Orchestration governs how multiple autonomous processes collaborate without corrupting shared state or generating merge conflicts.
The primary mechanism for concurrent agent execution is isolated Git Worktrees:
MAIN REPOSITORY (.git/)
β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
βΌ βΌ βΌ
WORKTREE 1: CI SWEEPER WORKTREE 2: PR BABYSITTER WORKTREE 3: TRIAGE
[Branch: agent/ci-fix] [Branch: agent/rebase-42] [Branch: main (read-only)]
-
Isolated Working Directory: Each loop operates in a physically separate directory (
.worktrees/<loop-name>/), preventing file write collisions. -
Dedicated Branching: Every loop automatically branches off the latest
origin/maincommit (agent/<pattern>-<timestamp>). -
Automated Teardown: Once a PR is opened or the task is finished, the worktree is cleanly removed:
git worktree remove --force .worktrees/ci-sweeper git branch -D agent/ci-fix-temporary
To prevent API rate-limiting, compute contention, and race conditions on pull requests, loops are scheduled with staggered cadences:
00:00 βββΊ DAILY TRIAGE (Scans backlog, prepares priorities)
01:00 βββΊ DEPENDENCY SWEEPER (Audits dependencies)
Every 15m βββΊ CI SWEEPER & PR BABYSITTER (Micro-maintenance)
23:00 βββΊ CHANGELOG DRAFTER (Summarizes day's merges)
Loops can be composed into serialized multi-stage pipelines where one loop's output becomes the input context for the next:
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β ISSUE TRIAGE β β CI SWEEPER β β PR BABYSITTER β
β Categorizes & ββββββββΊβ Reproduces bug ββββββββΊβ Ensures clean β
β validates issue β β & writes fix β β rebase & checks β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
-
Issue Triage Loop evaluates incoming issues, confirms reproduction, and applies the
agent-readylabel. - Implementation / Sweeper Loop detects the label, checks out a worktree, applies the minimal diff, and submits a PR.
- PR Babysitter Loop monitors the resulting PR, verifies CI, and requests human review once green.
When two loops require access to the shared STATE.md:
-
Atomic State Updates: Loops acquire a temporary file lock (
.state.lock) before modifyingSTATE.md. -
Append-Only Logging: Historical events are appended to
loop-run-log.md, avoiding merge conflicts. -
Drift Reconciliation:
npx @cobusgreyling/loop-sync .is executed prior to any state commit to detect and resolve divergent claims.
STOP PROMPTING / DESIGN THE LOOP / GET A SCORE
Loop Engineering Β· Autonomous Code Agent Tooling, Strict Eval Frameworks & Local-First CLI Utilities
Sololys Systems & Engineering Β· sololys/loop-engineering