Closed-loop AI agent workflows — phase-based execution with validation feedback
Project description
macrocycle
Closed-loop AI agent workflows.
Phase-based execution with validation feedback -- each phase is a control loop where the agent iterates until tests pass, linters are clean, or whatever your definition of done is.
Why?
AI agents are powerful but undisciplined. They rush to implement, skip analysis, and produce brittle code. Macrocycle fixes this by forcing your agent through structured phases with automated validation feedback loops.
The control loop is the product. Integrations (Sentry, GitHub, etc.) are left to the IDE or tools like Claude Code.
Installation
pipx install macrocycle
Quick Start
macrocycle init # Initialize .macrocycle/
macrocycle run fix "ValueError in process_request" # Run workflow
macrocycle run fix "..." --until analyze # Stop after a phase
macrocycle list # List workflows
macrocycle status # Latest run info
How It Works
Each workflow is a graph of phases. Each phase is a closed-loop control system:
Phase = Control Loop
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Setpoint │───>│Controller│───>│ Actuator │
│(success │ │(Phase │ │(AI Agent) │
│ criteria)│ │Executor) │ └─────┬─────┘
└──────────┘ └────┬─────┘ │
│ ┌────▼─────┐
┌────▼─────┐ │ Plant │
│ Error │<────│(Codebase)│
│ Signal │ └────┬─────┘
└──────────┘ ┌────▼─────┐
^ │ Sensor │
└───────────│(pytest, │
│ ruff...) │
└──────────┘
- Execute steps (LLM prompts, shell commands)
- Validate via a shell command (the sensor)
- If validation fails, feed the error back into the next iteration
- Repeat until convergence or iteration budget exhausted
- Route to next phase
Workflow Definition
Workflows live in .macrocycle/workflows/ as JSON:
{
"id": "fix",
"name": "Fix Issue",
"agent": {"engine": "cursor"},
"phases": [
{
"id": "analyze",
"steps": [{"id": "impact", "type": "llm", "prompt": "Analyze: {{INPUT}}"}],
"on_complete": "implement"
},
{
"id": "implement",
"steps": [
{"id": "code", "type": "llm", "prompt": "Implement: {{PHASE_OUTPUT:analyze}}"},
{"id": "test", "type": "command", "command": "pytest --tb=short"}
],
"validation": {"command": "pytest -q"},
"max_iterations": 5,
"context": ["analyze"],
"on_complete": "review"
},
{
"id": "review",
"steps": [{"id": "review", "type": "llm", "prompt": "Review changes..."}],
"validation": {"command": "pytest && ruff check ."},
"max_iterations": 3,
"context": ["implement"]
}
]
}
Step types: llm (AI prompt) / command (shell command)
Variables: {{INPUT}} / {{PHASE_OUTPUT:id}} / {{STEP_OUTPUT:id}} / {{ITERATION}} / {{VALIDATION_OUTPUT}}
Agent config cascade: Workflow -> Phase -> Step (use cheaper models for iteration-heavy phases)
Artifacts
.macrocycle/
workflows/fix.json
runs/
20260312_143052_fix/
input.txt
manifest.json # Checkpoint for crash recovery
analyze/output.md
implement/output.md
review/output.md
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file macrocycle-0.4.0.tar.gz.
File metadata
- Download URL: macrocycle-0.4.0.tar.gz
- Upload date:
- Size: 26.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b928b539be81cdc9ac78efc81de7c18da929ddf86c8915777da795a7ebe2def0
|
|
| MD5 |
4c8cd7308a417827d03de663e68e14c1
|
|
| BLAKE2b-256 |
1a420d68fa48db96c12fa8440face863c0d9ac5c7e8f1b644035a93d5d038bdc
|
Provenance
The following attestation bundles were made for macrocycle-0.4.0.tar.gz:
Publisher:
publish.yml on MilanPecov/macrocycle
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
macrocycle-0.4.0.tar.gz -
Subject digest:
b928b539be81cdc9ac78efc81de7c18da929ddf86c8915777da795a7ebe2def0 - Sigstore transparency entry: 1092169820
- Sigstore integration time:
-
Permalink:
MilanPecov/macrocycle@d3e57bfe99af29659a05768829a773470efc6c70 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/MilanPecov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d3e57bfe99af29659a05768829a773470efc6c70 -
Trigger Event:
push
-
Statement type:
File details
Details for the file macrocycle-0.4.0-py3-none-any.whl.
File metadata
- Download URL: macrocycle-0.4.0-py3-none-any.whl
- Upload date:
- Size: 41.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c8716999a430ec34973f7580bd408ee0e3fd16bbb6204328143ccff472aa90c
|
|
| MD5 |
32b73fc29950153ff4fa51786091983b
|
|
| BLAKE2b-256 |
8138ddfb07e582eb5d1b6153b4a90b7c5944dd5071aeee3fbce4d0a0ccbb9a11
|
Provenance
The following attestation bundles were made for macrocycle-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on MilanPecov/macrocycle
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
macrocycle-0.4.0-py3-none-any.whl -
Subject digest:
1c8716999a430ec34973f7580bd408ee0e3fd16bbb6204328143ccff472aa90c - Sigstore transparency entry: 1092169821
- Sigstore integration time:
-
Permalink:
MilanPecov/macrocycle@d3e57bfe99af29659a05768829a773470efc6c70 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/MilanPecov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d3e57bfe99af29659a05768829a773470efc6c70 -
Trigger Event:
push
-
Statement type: