FORGE Engine
FORGE is a terminal-based AI coding-agent harness that lets LLMs autonomously work on software tasks inside a sandboxed environment. It gives the model a fixed set of tools — read, write, list, and run commands — then independently verifies completion rather than trusting the model's own claim.
Works with any OpenAI-compatible API (OpenRouter, Ollama, local LLMs, etc.).
Available on PyPI: forge-engine
Installation
pip install forge-engine
Launch from any terminal:
forge
Quick Start
# Set your API key (defaults to OpenRouter)
export OPENROUTER_API_KEY="your-api-key"
# Launch interactive mode
forge
# Or run a one-shot task with verification
forge --task "Fix the bug in calc.py" --verify pytest
Using a Local Model
forge --base-url http://localhost:11434/v1 --model qwen2.5-coder:7b
Features
- Sandboxed Execution — Confines all file and command operations to a project directory. Blocks path traversal and absolute paths.
- Independent Verification — Runs
pytest,npm test, or any command to confirm the model's work is correct. The model cannot bypass verification. - Agentic Loop — Up to 40 turns per task. The model iteratively reads, writes, runs commands, and decides when it's done.
- Interactive CLI — Rich terminal UI with live streaming, code diffs, and slash commands for managing sessions.
- Session Persistence — Saves sandbox root, verification command, and model selection per project.
- One-Shot Mode — Scriptable single-task execution with
--taskand--verifyflags. - Model Agnostic — Works with any OpenAI-compatible API: OpenRouter, Ollama, vLLM, or any custom endpoint.
Slash Commands
| Command | Behavior |
|---|---|
/cwd <path> |
Change the active sandbox root to <path> |
/verify <command> |
Set the verification command (pytest, npm test, etc.) |
/model <name> |
Swap the LLM model without restarting |
/new-react <name> |
Scaffold a Vite React app with one command |
/clear |
Reset the session transcript (keeps settings) |
/help |
List all commands |
/exit or /quit |
Exit cleanly |
Architecture
┌─────────────────────────────────────────────────────┐
│ forge CLI │
│ (interactive / one-shot mode) │
└──────────┬──────────────────────────┬───────────────┘
│ │
┌──────▼──────┐ ┌───────▼────────┐
│ Orchestrator │ │ Sandbox │
│ (agent loop) │◄────────►│ (filesystem │
│ │ │ + commands) │
└──────┬───────┘ └────────────────┘
│
┌──────▼───────┐
│ LLM Client │────► OpenAI-compatible API
│ (transcript)│ (OpenRouter / Ollama / etc.)
└──────────────┘
| Module | Responsibility |
|---|---|
harness/orchestrator.py |
Agentic loop — manages turns, tool calls, guardrails |
harness/tools.py |
Tool definitions and dispatch (read, write, list, run, complete) |
harness/sandbox.py |
Path and command confinement to a project root |
harness/transcript.py |
Conversation history — compaction, trimming, metadata |
harness/verifier.py |
Runs a verification command and reports pass/fail |
harness/llm_client.py |
OpenAI-compatible chat-completions HTTP client |
harness/cli.py |
Interactive terminal UI with rich rendering |
harness/session.py |
Persists session state to .qwenagent-session.json |
Verification Flow
- Model calls
task_complete→ harness doesn't trust it - Verifier runs the configured command (
pytest,npm test, etc.) - If verification passes → task is accepted
- If verification fails → model gets the failure output and can try again
- If no verification command is set → auto-detects
pytest/npm test/make test, or prompts you
Development
# Clone and install in editable mode
git clone https://github.com/Devakesavan/Forge-Engine.git
cd Forge-Engine
pip install -e .[test]
# Run tests
python3 -m pytest -q
Contributing
Contributions are welcome. Please keep changes focused on one behavior at a time and ensure tests pass:
pip install -e .[test]
python3 -m pytest -q
License
MIT License — see LICENSE for details.
Release files for forge-engine 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| forge_engine-0.1.1.tar.gz | 17.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| forge_engine-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.9 kB
Release files / forge_engine-0.1.1.tar.gz
| Download URL | forge_engine-0.1.1.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad796a5ee3dd51faace85b7310f9bae6310e9b748b38bd72c20eb18454875e0b
|
|
BLAKE2b-256 checksum How to use checksums |
df1b1c62975688c26b51f992ea44940271172f42f54acd78878b010315f4b220
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Release files / forge_engine-0.1.1-py3-none-any.whl
| Download URL | forge_engine-0.1.1-py3-none-any.whl |
|---|---|
| Size | 21.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d2629472201eed8252c2311a24ec0a3477a22163a9b56dc06949aaf5b24f037
|
|
BLAKE2b-256 checksum How to use checksums |
1b0241df113562cde5723f7f62ba8efc276c0eb7191222bc0e39184d8ead7f8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|