Agents that write code. Humans who hold the keys.
A pipeline of four AI agents — planner, coder, reviewer, fixer — orchestrated as a LangGraph state machine. Every risky transition passes a human approval gate, every file passes a safety scan, and every run is checkpointed to SQLite so it can pause, resume, and remember.
Why put a state machine between an LLM and your shell?
Letting a single LLM generate and run code in one shot is fast — and unaccountable. You can't see the plan before the code, the code before it runs, or the review before you accept it. This project makes each of those moments a first-class, durable decision point.
The problem with one-shot codegen
- No inspection point between "idea" and "executed code"
- Dangerous patterns (
eval,subprocess, network calls) run unnoticed - Failures loop forever or die silently — no cost ceiling
- Every session starts from zero; lessons are never retained
What the pipeline changes
- Plan, execution, and verdict each pause for explicit human approval
- Deterministic AST scan flags risky code before the sandbox
- Reflection loop capped at 3 fixes; token budget enforced per run
- Review findings distill into lessons the planner recalls next session
One run, eight moves
A task enters as plain text and leaves as a reviewed, human-accepted multi-file Python project in workspace/<run_id>/.
Input guardrail
A cheap LLM classifier answers one question: is this a legitimate coding task? Malicious or off-topic requests end the run immediately.
Plan planner
A strong LLM drafts files, steps, and a test strategy — after recalling relevant lessons from previous runs out of SQLite memory.
Gate 1 — approve the plan
The graph pauses via interrupt(). The human sees the structured plan and approves or rejects before a single line is written.
Code, then scan coder
The coder returns files as a validated tool call. A deterministic AST + regex scan flags eval, subprocess, network imports, path escapes.
Gate 2 — approve execution
The human reads the actual generated files next to the safety-scan flags and decides whether the code may run in the sandbox.
Execute executor
Files land in a path-jailed workspace; pytest or the entrypoint runs in a subprocess with a stripped environment and a hard timeout.
Review & Gate 3 reviewer
Severity-ranked findings plus a pass/fail verdict. The human accepts the code, sends it to the fixer, or rejects the run.
Fix loop, then out
The fixer repairs and re-enters the scan → gate → execute → review cycle — at most 3 times. The output guardrail moderates the final summary; lessons are saved.
Nodes, edges, and every conditional path
This is the exact topology compiled in src/graph.py. Solid animated edges are the
happy path; amber is the reflection loop; dashed
red edges are conditional exits (rejections, errors, guard refusals).
Diamond-labelled routers are LangGraph conditional edges.
A real run, gate by gate
Captured live from the Streamlit app — task: “Build a CLI temperature converter (Celsius/Fahrenheit) with tests.”
Task input & run history
The sidebar lists previous runs straight out of memory.db — outcome, fix count, task. Cross-session memory isn't a claim, it's on screen.

Approve the plan
The graph is paused here — a durable interrupt() checkpoint. The structured plan (files, steps, test strategy) renders as JSON; nothing proceeds until a human clicks Approve.

Read the code before it runs
Every generated file is inspectable, and the deterministic safety scan reports next to it. The human — not the model — decides whether this code touches the sandbox.

The reviewer earns its keep
Verdict: fail — the coder shipped pure functions but no CLI entrypoint and no tests. Severity-ranked findings feed the fixer if the human chooses “Send to fixer”.

Done — and remembered
The output guardrail moderates the final summary, the run lands in the history sidebar, and high-severity findings become lessons the planner will recall on the next similar task.

Eight agentic patterns, each with an address
Planning & Reasoning
Structured plan with files, steps, test strategy; memory lessons injected into the prompt.
src/agents/planner.pyTool Calling
Code returned as a validated {files:[{path,content}]} tool call — retried once on parse failure.
src/agents/base.pyAgent Memory
SQLite lessons ranked by keyword overlap; runs table powers the history sidebar.
src/memory/store.pyOrchestration
One StateGraph, deterministic conditional edges — no flaky LLM router.
src/graph.pyReflection Loop
reviewer → fixer → scan → gate → executor → reviewer, capped at 3 iterations.
route_verdict_gateHuman-in-the-Loop
Three interrupt() gates; Streamlit resumes with Command(resume=…).
hitl_* nodesGuardrails
Input classifier, AST safety scan, iteration/token caps, output moderation.
src/guardrails/Statefulness
SqliteSaver checkpoints every transition; any run resumes by thread_id after restart.
data/checkpoints.dbFour guardrails, one sandbox
| Layer | Mechanism | On breach |
|---|---|---|
| Input validation | LLM classifier on the task before the graph proceeds | Run ends with a refusal reason |
| Code safety scan | Deterministic AST + regex: eval/exec, os.system, subprocess, network imports, path escapes | Flags surface at Gate 2 — human decides |
| Loop & cost limits | Max 3 fix iterations + per-run token ceiling + graph recursion limit | Graceful end with partial results |
| Output moderation | LLM check on the final summary before display | Summary replaced or withheld |
| Execution sandbox | Path-jailed workspace, stripped env, 30s timeout, output truncation | Failure captured as data, fed to reviewer — never crashes the graph |