LangGraph-based agentic loop engine for IDE/CLI environments — enforces think→execute→critique→refine on every coding action
Project description
Global Loop Engine
Global Loop Engine is a robust, LangGraph-based execution and validation layer designed for LLM coding agents operating in IDE or CLI environments. It acts as an uncompromising gatekeeper, enforcing a strict "think → execute → critique → refine" cycle to ensure 100% deterministic code output and completely eliminate LLM hallucination or "cheat-to-pass" behaviors.
✨ Core Features
- 🛡️ Strict Sandbox Validation: Employs real subprocess verification (e.g.,
pytest,grep) to validate LLM outputs. It refuses to accept "mocked" data or verbal claims of success. - 🧊 Hot/Cold State Separation: Keeps context windows extremely small by passing only diffs and execution exit codes (cold state) to the LLM, preventing token explosion on large projects.
- 🧬 Anti-Hallucination Guardrails: Features a dedicated
CriticNodethat cross-references assertions with raw logs. If an LLM fabricates test results, the engine instantly intercepts it. - ⏱️ Atomic Git Snapshots: Automatically commits state checkpoints before execution. If the LLM enters a destructive spiral, the engine gracefully rolls back the entire workspace.
- ⚙️ Dangerous Command Filter: Uses Regex-based whitelists to instantly block destructive shell commands (
rm -rf /,DROP TABLE, etc.) before they hit your terminal.
🏗 Architecture
graph TD
classDef llm fill:#f9f2f4,stroke:#d67a8b,stroke-width:2px,color:#333;
classDef validator fill:#e6f7ff,stroke:#69b1ff,stroke-width:2px,color:#333;
classDef storage fill:#f6ffed,stroke:#95de64,stroke-width:2px,color:#333;
User([User Request]) --> A[LangGraph Orchestrator]
subgraph Global Loop Engine
A -->|Dispatch| C[AgentNode<br>Code Generation]:::llm
C -->|Propose Changes| B{CriticNode<br>Sandbox Validator}:::validator
B -->|Fake Data / Missing Evidence| C
B -->|100% Verified| D[StateSaver<br>Git Checkpoint & SQLite]:::storage
end
D --> Success([Final Output])
🚀 Quick Start
1. Installation
Choose one of the following methods to install (supports macOS, Windows, and Linux):
Method A: Install via PyPI (Recommended)
pip install global-loop-engine
Method B: Download Release Asset (Offline / Custom version)
- Go to the Releases page.
- Download the universal wheel package (e.g.,
global_loop_engine-0.1.0-py3-none-any.whlfor version0.1.0).Note: macOS, Windows, and Linux users all download this same universal file. Naming Rule: Python's packaging standard automatically replaces the hyphen
-in the project name with an underscore_for.whlfiles (while keeping the hyphen in.tar.gzfiles). - Run the installation (replace
0.1.0with the actual version you downloaded, or use a wildcard):pip install global_loop_engine-0.1.0-py3-none-any.whl # Or using wildcard: pip install global_loop_engine-*.whl
Method C: Developer Mode (Clone and build)
git clone https://github.com/WhitWei/global-loop-engine.git
cd global-loop-engine
cp .env.example .env
pip install -e .
2. Configuration
Open the .env file and configure your database path and retry thresholds (defaults are provided out-of-the-box).
3. Usage
You can invoke the engine directly via the global CLI command loop-engine:
# Run a task with strict single-pass validation (no retries)
loop-engine --task "Refactor the authentication module" --mode fast
# Run a task with the full LangGraph reflexion loop (auto-retries until success)
loop-engine --task "Implement Token Bucket algorithm and pass tests" --mode loop
🧠 Architecture Overview
The engine orchestrates agents through a compiled StateGraph:
- ComplexityScorerNode: Evaluates the task difficulty to determine maximum allowed retries.
- SanitizeNode: Pre-execution security filter blocking malicious shell commands.
- ExecuteNode: Runs the target code or tests in the shell, capturing
stdout,stderr, andexit_code. - CriticNode: The "Judge". Parses logs, detects hallucinations, increments retry counters, and routes the state.
- RefineNode: If tests fail, feeds the exact error signatures back to the LLM to patch the code.
🤝 Contributing
We welcome contributions! Please see CONTRIBUTING.md for details on how to set up your local development environment, run tests, and submit pull requests.
📄 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
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 global_loop_engine-0.1.2.tar.gz.
File metadata
- Download URL: global_loop_engine-0.1.2.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3911a121241acbf554d704033a77f2a90e46f09345714d51b44835af765f530
|
|
| MD5 |
7ab5d0a44a83d76f6cb243713d9048b8
|
|
| BLAKE2b-256 |
11abec24ff8c0ecee61c8e443c0cf8e910315b1bb6d82154cc0956c9bdab0b12
|
Provenance
The following attestation bundles were made for global_loop_engine-0.1.2.tar.gz:
Publisher:
publish.yml on WhitWei/global-loop-engine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
global_loop_engine-0.1.2.tar.gz -
Subject digest:
f3911a121241acbf554d704033a77f2a90e46f09345714d51b44835af765f530 - Sigstore transparency entry: 1966616441
- Sigstore integration time:
-
Permalink:
WhitWei/global-loop-engine@051d50b04d8f63ebc70932afbdf7784a565a42a0 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/WhitWei
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@051d50b04d8f63ebc70932afbdf7784a565a42a0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file global_loop_engine-0.1.2-py3-none-any.whl.
File metadata
- Download URL: global_loop_engine-0.1.2-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e310194af54e4fe09c1e5ddd912605432b70b1226a84ca16a803b641582eb851
|
|
| MD5 |
1e87ea9620f683395a997664f65354e5
|
|
| BLAKE2b-256 |
1fc54b140b7caedda96f980e703d92ec2da051bbc1b39cf41a06bc3e0ffc55ad
|
Provenance
The following attestation bundles were made for global_loop_engine-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on WhitWei/global-loop-engine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
global_loop_engine-0.1.2-py3-none-any.whl -
Subject digest:
e310194af54e4fe09c1e5ddd912605432b70b1226a84ca16a803b641582eb851 - Sigstore transparency entry: 1966616484
- Sigstore integration time:
-
Permalink:
WhitWei/global-loop-engine@051d50b04d8f63ebc70932afbdf7784a565a42a0 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/WhitWei
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@051d50b04d8f63ebc70932afbdf7784a565a42a0 -
Trigger Event:
push
-
Statement type: