Designing a Harness for Agentic Autonomy (Part 1)

Starting from no harness at all and a simple prompt to add a new feature, we learn what difference an agentic harness makes. The goal with a harness is for the agent to make autonomous decisions about code changes that align with the qualities you value. This learning hour was originally designed as a longer workshop, so it is split into several parts. See also Agentic Harness Part 2.

Learning Goals

Session Outline

Connect

Ask: In what ways can you influence the code produced by a coding agent? Give me Three Facts. You are hoping for answers like - through the prompt, through the AGENTS.md file, through the documentation in the project, through documentation it can find on the internet.

Concept

Even if they seem to understand all this from the Connect discussion, it’s worth going over some basic terms.

A Harness might include:

Concrete

Introduce the exercise. The “WarehouseDesktopApp” manages inventory. The starting code contains basic functionality and a description of a new desired feature in “feature.md”. The code has a Long Method code smell and there are no unit tests. The README file contains information about how to build the code and run the “Demo Day” application.

Note: Some people might have files in their user home folder that the agent will automatically load - we suggest disabling them for this exercise so you can see what the agent does without any harness.

Step 1: No Harness

Use this prompt:

Implement the feature from feature.md

If it can’t work out how to build the code and run the Demo Day application, give it that information in the prompt too.

Review the quality of the code changes. Usually with this prompt, the agent implements the feature but does not create any unit tests or address the code smell. (If your agent does, try again with a less good/cheaper LLM!)

Step 2: Agent Instruction File

Revert the code. Create an AGENTS.md file in your repository and include this text:

Add unit tests for new features

Start a new context window and give this prompt again:

Implement the feature from feature.md

Review the code changes. Hopefully, this time it will have created unit tests. Usually, it will not have fixed the code smell. (If your agent does, try again with a less good/cheaper LLM!) Discuss anything it did which doesn’t align with your preferences for test design.

Step 3: Iterate to improve the Agent Instruction File

Update the AGENTS.md file with additional information about your preferences for test design. For example, you might want it to use a particular test framework or style of assertions. If it has only created tests for the new functionality, tell it to add regression tests for the rest of the code too.

Repeat the process of reverting the code (while keeping your changes in the AGENTS.md file) and use a new context window with the same prompt every time until the code it writes has good enough tests.

At the end of the exercise, commit your code so you can resume with Part 2 in the next learning hour.

Conclusions

Ask people to explain the main idea of an agentic Harness.