LLM-Driven Harness Engineering: Automating the Loop from Planning to Delivery

    This article explores a paradigm shift in AI coding systems: as long-horizon model capabilities improve, the planner-generator-evaluator loop of the classic Harness framework can move from external orchestration code into the model itself. Using a real project—an ontology-based knowledge graph extraction and visualization system—as a case study, it walks through how a model autonomously planned, implemented, tested, and debugged a full-stack system over three hours and roughly 800,000 tokens. It also distills reusable practices: define deliverables instead of steps, establish data contracts early, make tests the fuel of the loop, intervene only at acceptance, and budget for evaluation-heavy token consumption.

    1. From External Scaffolding to In-Model Loops: A Paradigm Shift in Agent Engineering

    Over the past two years, many teams building AI coding systems have followed the industry-standard Harness (execution framework) design: a complex software engineering task is split among three roles. A planner decomposes the goal into executable steps; a generator produces code or solutions; an evaluator runs tests, reviews results, and feeds problems back. The three form a loop that repeats until evaluation passes and the task is delivered.

    The problem with this design is that the loop logic has to be written explicitly as code. You implement the task queue, result validation, retry policies, and context assembly yourself—a substantial engineering effort, and every failure mode at every stage needs its own handling.

    With the recent leap in long-horizon task capabilities, a significant change has emerged: a sufficiently capable model can play both generator and evaluator within a single context—writing its own code, running its own tests, discovering its own problems, and fixing them—without complex external orchestration. The developer only needs to provide a clear goal and constraints at the starting point, and the model can keep pushing forward until delivery.

    This article uses a complete engineering project—an ontology-based knowledge graph extraction and visualization system—as a case study to review how this paradigm works in practice and to distill a reusable methodology.

    2. Why This Project: Real Engineering, Not a Demo

    Knowledge graph extraction and visualization is a natural stress test for a model’s engineering loop capability, because it spans multiple technology stacks:

    • NLP layer: entity recognition, relation extraction, and event extraction, requiring prompt design and a structured output protocol;
    • Data modeling layer: ontology design, node/edge modeling in a graph database, and schema evolution;
    • Service layer: orchestration of the extraction pipeline, batch ingestion, and incremental updates;
    • Presentation layer: front-end visualization, graph layout algorithms, and query-linked interactions.

    A model that can only “build a front-end demo” will fail here. It must align data contracts across layers: the JSON structure of the extraction output must match the graph database schema, and the query API must match the data requirements of the front-end visualization. This is exactly what makes the project a litmus test for whether the “plan–generate–evaluate” loop is genuinely effective.

    3. Task Kickoff: A Clear Goal Beats Complex Orchestration

    Under the in-model loop paradigm, the quality of the kickoff phase determines the degree of autonomy for the following three hours. In practice, I’ve summarized three kickoff principles:

    3.1 Describe the goal as deliverables, not steps

    Don’t write “step one: extraction, step two: ingestion.” Instead, describe the final deliverable:

    1. Goal: Build a knowledge graph system that includes:
    2. 1. Taking unstructured text as input and outputting triples (in JSON format)
    3. that conform to a predefined ontology
    4. 2. Batch-writing triples into a graph database, with provenance and confidence
    5. attributes on nodes and edges
    6. 3. Displaying the graph on the web, supporting filtering by entity type,
    7. coloring by relation type, and clicking a node to view details
    8. 4. Providing an end-to-end test script covering the full chain:
    9. "text input → extraction → ingestion → query → rendering"

    3.2 State hard constraints upfront

    For example: the graph database is limited to a certain class of general-purpose graph storage engines; extraction output must conform to a given JSON Schema; the front end can use any mainstream framework. The clearer the constraints, the more stable the baseline for the model’s self-evaluation later.

    3.3 Define acceptance criteria

    Make explicit “what counts as done.” For example: the end-to-end test passes, the extraction accuracy on sample text is acceptable under manual spot-checking, and the front-end page is interactive. This gives the model’s “evaluator” role something concrete to rely on.

    4. How the Model Ran for Three Hours: The Loop in Action

    After kickoff, the model’s execution followed a rhythm worth examining in detail:

    Phase 1: Planning and skeleton generation

    The model first produced a system architecture description, dividing the system into modules and data flows, then generated the project skeleton: directory structure, inter-module interface definitions, and configuration files. The key point is that it did not jump straight into full implementations—it first pinned down the “data contracts,” namely the output format of the extraction module and the input format of the ingestion module. This mirrors the habit of senior engineers who define interfaces before writing implementations.

    Phase 2: The micro-loop of generate and evaluate

    While implementing each module, the model exhibited a stable cyclic pattern:

    1. Write code;
    2. Write the corresponding unit tests;
    3. Run the tests;
    4. Read the error messages and locate the problem;
    5. Modify the code and rerun.

    For example, in the relation extraction module, the structured output it generated initially had missing fields. After the test script caught this, the model adjusted the prompt template on its own and added output validation logic (automatic retry on non-conforming formats), then re-verified. There was no human intervention throughout.

    A typical self-validation output protocol looked like this:

    1. def validate_triple(t: dict) -> bool:
    2. required = {"subject", "predicate", "object", "confidence", "source"}
    3. if not required.issubset(t.keys()):
    4. return False
    5. return isinstance(t["confidence"], float) and 0.0 <= t["confidence"] <= 1.0
    6. # Validate after extraction; non-conforming triples trigger a retry
    7. triples = [t for t in raw_output if validate_triple(t)]

    This kind of defensive code was not something I asked for—the model added it itself during the “evaluate–fix” cycle. As the loop runs longer, the model naturally develops a tendency to write code in ways that “make the next evaluation easier to pass.”

    Phase 3: Cross-module integration and end-to-end verification

    Once individual modules passed, the most valuable part was end-to-end integration. The model constructed sample texts itself and ran the full chain of “extraction → ingestion → query → front-end rendering.” When it found that the data structure returned by the graph query API did not match what the front-end component expected, it chose to modify the back-end API by adding an adaptation layer rather than rewriting the front end. This kind of trade-off decision shows that the evaluation stage was no longer a simple “did the test pass,” but included judgments of engineering soundness.

    5. Token Consumption and Cost: What Do 3 Hours and ~800K Tokens Mean?

    The entire process consumed nearly 800,000 tokens. This number deserves a rational look:

    • The bulk went to evaluation: running tests, reading error output, and re-reading long files are all context-intensive operations. In other words, the model spent most of its budget on “confirming that it was right”—which is precisely why the evaluator role exists in the Harness philosophy.
    • Cost should be measured against the deliverable: if implemented by a junior engineering team, this system—from ontology design to front-end integration—would typically be measured in person-days. Comparing token cost against labor cost, the input-output ratio is computable in real engineering scenarios.
    • Context management is the hidden key: the ability to sustain a long-horizon task depends on the model summarizing completed modules and retaining records of failures. This self-management of “working memory” is a direct manifestation of long-context capability.

    6. Reusable Practical Recommendations

    Based on this experience, I’ve distilled five transferable lessons:

    1. Goal declaration takes priority over process orchestration: the stronger the model, the more engineering effort should go into writing clear goals, constraints, and acceptance criteria—not into writing complex agent orchestration code.
    2. Data contracts first: defining the input/output schemas between modules at kickoff drastically reduces integration friction later.
    3. Make tests the fuel of the loop: requiring every module to come with its own tests gives evaluation a handle and gives the model’s self-correction a basis.
    4. Place human intervention at “acceptance,” not “error correction”: only do manual spot-checks on milestone deliverables, and leave the intermediate process to the model’s autonomy for maximum efficiency.
    5. Include cost accounting in solution design: token consumption for evaluation-intensive tasks can far exceed intuition, so important projects should estimate a budget and set checkpoints in advance.

    7. Conclusion

    This three-hour experiment confirmed a judgment for me: when a model itself has sufficiently strong long-horizon reasoning and coding capabilities, the “plan–generate–evaluate” loop can be internalized from external engineering scaffolding into the model’s autonomous behavior. The developer’s role shifts accordingly—from “designer of the loop” to “definer of goals and acceptor of results.” This does not mean the Harness philosophy is obsolete; quite the opposite, its essence is now realized in a lighter form: engineering wisdom is moved upstream to the goal-setting stage, while execution intelligence is delegated to the model itself. For teams building AI coding workflows, now is a good time to reassess the balance between “scaffolding complexity” and “model capability.”