README.md

March 31, 2026 · View on GitHub

OpenHarness Banner

⚙️ OpenHarness For Codex

Let your Agent act as the Product Owner. Let Codex write the code. You just describe what you want.

Build Status Release License Requires Codex CLI

"You are not the developer. You are the architect. Codex is your hands."

OpenHarness For Codex is a specialized variant of the OpenHarness framework designed for AI-driven software development. It turns your Agent into a Product Owner + Verifier, while delegating all code writing to Codex CLI. The result is a fully autonomous, multi-round development loop that runs 24/7 until your project passes validation.


🤔 Why OpenHarness For Codex?

Most "AI coding" workflows look like this: you ask the AI to write code, it looks plausible, you run it, it breaks, you paste the error back, repeat forever — manually.

OpenHarness For Codex automates this entire loop:

CapabilityWithout OpenHarness For CodexWith OpenHarness For Codex
Multi-round iterationManual copy-pasteFully automated
Error diagnosisYou read the logsAgent extracts & feeds to Codex
Service validationYou run it manuallyharness_service.py + harness_eval.py
Cross-session recoveryStarts from scratchheartbeat.md breakpoint resume
Completion standardSubjective ("looks good")Machine-verifiable eval report

🏛️ Architecture

The framework enforces a strict two-role separation:

RoleExecutorResponsibilitiesHard Constraint
Requester + VerifierYour AgentRead requirements, design architecture, write docs, construct Prompts, start/stop services, check logs, evaluate quality, drive iterationsNever write business code directly
Executor (Hands)Codex CLIWrite, modify, and refactor code based on PromptsNever modify framework state files

The Automated Development Loop

User describes project in mission.md

Agent reads requirements → writes tech_spec.md

Agent constructs Prompt → calls Codex CLI (full-auto)

Codex writes code into project_src/

harness_service.py: install deps + start service

harness_eval.py: HTTP health check + log analysis → eval_report.json

Agent reads report → writes iteration_N.md

  [FAIL] → Agent extracts error logs → constructs fix Prompt → back to Codex
  [PASS after N rounds] → package deliverables → mission_complete

Workspace Structure

After initialization, your project workspace looks like:

my-project/
├── mission.md           ← 📜 Your requirements (read-only "constitution")
├── playbook.md          ← 🗺️ Agent's execution playbook
├── eval_criteria.md     ← 🔍 Validation criteria
├── heartbeat.md         ← 💓 Cross-session state (Agent reads/writes)
├── progress.md          ← 📊 Execution history log
├── project_src/         ← 💻 Code written by Codex
├── reports/             ← 📝 Agent's technical docs and iteration reports
│   ├── tech_spec.md
│   ├── iteration_1.md
│   └── iteration_2.md
├── logs/                ← 🗂️ Service logs, eval reports, Codex prompts
│   ├── service.log
│   ├── eval_report.json
│   └── codex_prompt_iter1.txt
├── deliverables/        ← 📦 Final packaged output
└── scripts/             ← ⚙️ Framework scripts (auto-copied on init)
    ├── harness_boot.py
    ├── harness_heartbeat.py
    ├── harness_service.py
    ├── harness_eval.py
    ├── harness_orchestrator.py
    ├── harness_cleanup.py
    └── harness_setup_cron.py

📦 Installation

Prerequisites

  • OpenHarness core harness installed in ~/.openclaw/workspace/harness/
  • Codex CLI installed and available as codex in your $PATH
  • Python 3.9+

Setup

Clone this repository into the same workspace directory, alongside the main harness:

cd ~/.openclaw/workspace/harness/
git clone https://github.com/thu-nmrc/OpenHarness-For-Codex.git openharness-for-codex

Verify Codex CLI is available:

which codex
codex --version

🚀 Quick Start

Step 1: Initialize a project workspace

python3 ~/.openclaw/workspace/harness/openharness-for-codex/scripts/harness_boot.py ~/my-project --init

Step 2: Fill in your requirements

Open ~/my-project/mission.md and describe what you want to build. For example:

Develop a full-stack web app "AI Resource Pack Generator".
Frontend: React + Tailwind. Backend: FastAPI.
Feature: user inputs a topic, backend calls OpenAI API to generate a resource pack, 
packages it as a ZIP for download.
Target: 3 iteration rounds.

Step 3: Trigger the Agent with one sentence

In your Agent (e.g., OpenClaw), simply say:

Read the SKILL.md in openharness-for-codex, then execute the development task in ~/my-project.
Workspace path: ~/my-project

The Agent will automatically:

  1. Run harness_boot.py to check state and resume from breakpoint if needed
  2. Read mission.md, design the architecture, write tech_spec.md
  3. Construct a Codex Prompt and call Codex CLI to generate code
  4. Run harness_service.py to install dependencies and start the service
  5. Run harness_eval.py for external validation (HTTP probe + log analysis)
  6. Write an iteration report, construct a fix Prompt, and loop again
  7. Repeat until validation passes for the target number of rounds, then package and deliver

🔧 Script Reference

ScriptCalled ByFunction
harness_boot.pyAgentInitialize workspace / check state, output Agent-friendly action instructions
harness_heartbeat.pyAgentState machine: start / done / fail / next_iteration / blocked / mission_complete
harness_service.pyAgentAuto-detect project type, install deps, start/stop service, HTTP health check
harness_eval.pyAgentExternal validation: code integrity + HTTP probe + log analysis → eval_report.json
harness_orchestrator.pyAgent / CLICore orchestrator: drives the full multi-round development loop autonomously
harness_cleanup.pyAgentEntropy control: compress old logs, prevent context window bloat
harness_setup_cron.pyAgentRead cron_config.md, output parameters for the schedule tool

🛠️ Troubleshooting

Task is blocked

  1. Check the last 50 lines of logs/service.log for the root cause.
  2. Manually fix the critical issue in project_src/ (e.g., dependency version conflict).
  3. Reset heartbeat.md: set Current Status to idle and Consecutive Failures to 0.
  4. Re-trigger the Agent.

Codex is not generating files

Verify Codex CLI is in your PATH: which codex. If using a different Agent CLI (e.g., aider), modify the run_codex() function in harness_orchestrator.py.

Service starts but eval still fails

Run python3 scripts/harness_service.py ~/my-project status to check service state, then inspect logs/service.log for detailed errors.


📄 License

Source-available under Business Source License 1.1.

Free for academic, research, and non-commercial use. Commercial use requires a separate license — contact syycy2021@gmail.com.