thruwire/foreman
An agent supervisor and software factory foreman powered by decision models
Foreman – Semantic Supervision for AI Coding Agents
What it is
- A native Python
asyncioruntime that watches a coding‑agent (e.g., Codex, OpenCode, Hermes, DeepAgents) while it works on a software‑engineering task. - It feeds the agent’s output and repository state to a decision model (TypeSafe Jev or OpenAI Decisions API) which returns probabilities for a set of responsibilities (completion, verification, worker health, drift, human escalation, etc.).
- Based on those probabilities a deterministic policy chooses one directive (continue, steer, stop, retry, start verifier, finish, or escalate to a human).
Key concepts
- Factory floor – the coding worker runs independently; Foreman observes its events, runs checks, and decides what to do next.
- Responsibilities & checks – pluggable groups of probability questions (e.g.,
implementation_complete,worker_stuck). Each check is answered by the decision model. - Decision model adapters – default is TypeSafe Jev (
Noulquestions); optional OpenAI adapter (gpt‑6‑luna). - Worker back‑ends – interchangeable via
FOREMAN_WORKER_BACKEND(codex(default),opencode,hermes,deepagents). - Evidence providers – bounded snapshots of the repo (diff,
git status, test output, custom CLI commands) that are sent to the model. - Live steering – only the Codex App Server backend can inject guidance into an in‑flight turn; other back‑ends fall back to stop/retry.
Typical workflow
1. `foreman run --repo ./my-project --job "Add rate limiting and tests"`
2. Foreman launches the selected coding worker.
3. Worker emits events (tool usage, file edits, test runs).
4. Foreman batches evidence, asks the decision model the built‑in checks.
5. Model returns probabilities; Foreman selects a directive.
6. Directive is applied (continue, steer, start verifier, finish, or escalate).
7. Loop repeats until the job is declared finished or escalated.
Installation
# Core package (includes the `foreman` CLI)
python -m pip install foreman-core
- Requires Python 3.11+.
- For OpenAI support:
pip install 'foreman-core[openai]'and setFOREMAN_DECISION_PROVIDER=openai. - Install the appropriate coding‑agent CLI (Codex, OpenCode, Hermes, or DeepAgents) and configure API keys as described in the README.
Running a demo (no API keys needed)
foreman demo --repo .
A deterministic simulation shows the full loop from coding to verification to FINISH.
Extensibility
- Add new responsibilities by dropping a TOML definition into
src/foreman/responsibilities/definitions/or pointing--responsibilities-dirto a custom folder. - Implement additional evidence commands in the central config to feed custom tool output into checks.
- Write a new worker adapter that follows the small
Workerprotocol (JSON‑line events, turn lifecycle).
Why it matters
- Provides a thin supervisory layer that can be swapped onto any existing LLM‑based coding agent without modifying the agent itself.
- Turns vague “is the worker stuck?” questions into quantitative probabilities, enabling safe, automated steering of AI‑generated code.
- Supports human escalation when confidence thresholds (e.g.,
needs_human ≥ 0.80) are crossed, keeping the loop trustworthy.
Links
- Documentation: theory, decision models, routing, extensions, hooks, steering, etc. (see
docs/folder). - Plugins: Codex marketplace plugin, Deep Agents integration.
- Contributing: see
CONTRIBUTING.md.
Foreman is a real open‑source project that builds a semantic supervision layer for AI‑driven software development.
Related
- Project
- Project
- Project
- Project
- Project