# The harness is part of the system

Three decisions behind my scraper agent at Sarvam AI, none of them to the model, and how I would test changes like them.

- Web page: https://pranavsastry.com/posts/the-harness
- Kind: Post
- Headline: I treat the harness as part of the **system**.
- Type: Research
- Year: 2026

When I built an agent workflow at Sarvam AI, the decisions that shaped it all sat in the harness around the model: the prompts, the tools, the context, the workflow, and the checks that decide when the work is done. This post describes that harness and how I would test changes to it.

## What the harness is

Two agents built on the same model can behave very differently, because their harnesses show the model different information, give it different actions and judge its work differently.

**Figure 1. The harness, layer by layer.**

| Layer | What it decides |
| --- | --- |
| Model | Proposes reasoning and actions. |
| Context and memory | Which evidence and past experience the model sees. |
| Tools and environment | What the agent can inspect, change, run and observe. |
| Workflow and subagents | How work is split up, and how state is kept apart. |
| Verification and permissions | What counts as done, and which changes are allowed. |

## Where I ran into it

The [scraper workflow](https://pranavsastry.com/career/sarvam-ai-ai-engineering-intern.md) I led as an intern turns a plain-language request into a web scraper whose code has been run against the live site. On four client deployments it brought authoring from about three hours per scraper to 15 minutes. Each of its three main decisions sits in a different layer of the table above:

1. **Context.** Exploring a site corrupted the main agent’s context, so a subagent does the exploring.
2. **Tools.** Where a site serves its data through a backend API, the workflow finds the API at runtime and uses it instead of parsing pages.
3. **Verification.** The agent runs each generated snippet against the live site, so the code it keeps has been run.

**Figure 1. Time to author a scraper.** Time to author one custom scraper, by hand and with the agentic workflow, in four client deployments.

| Measure | Series | Value |
| --- | --- | --- |
| Minutes to author one scraper | By hand (baseline) | 180 min |
| Minutes to author one scraper | Agentic workflow | 15 min |

Result: About 92% less time per scraper, in four client deployments.

I arrived at all three by reading failures myself. The loop below is what I would want doing that reading for me.

## The missing loop

Every run already produces the raw material: the task, the context, the commands, the tool calls, the errors, the tests, the cost and the outcome. What is missing is a loop that turns that record into a tested change.

1. **Capture** what happened in the run.
2. **Locate** the decision that shaped the result.
3. **Test** one bounded change against the same objective.
4. **Keep** it only if the evidence holds, and keep the failed attempt too.

## What counts as evidence

Evidence is something another person or program can check: a reproduced failure, a comparison against a baseline, a passing regression suite, an execution trace, or a negative result that was written down. A run that looks right, or a model that sounds sure, does not qualify.

> I used to work out gradients by hand and thought autograd was magic. Neograd was how I found out: a framework in plain Python and NumPy, small enough to read.
> — Pranav Sastry, Neograd. [Project](https://pranavsastry.com/projects/neograd.md)

It is the standard I held my papers on [ELITS](https://pranavsastry.com/papers/elits-efficient-lightweight-imputation-for-time-series.md) and [data attribution](https://pranavsastry.com/papers/an-efficient-subset-selection-strategy-using-text-guided-data-attribution-to-mitigate-simplicity-bias.md) to: every result against a named baseline.

## A first attempt in code

[AutoPilot](https://pranavsastry.com/projects/autopilot.md) is my prototype of the loop. It borrows the shape of a PyTorch training loop: structured feedback takes the place of gradients, and edits to prompts or code take the place of weight updates.

The update it replaces is the plain gradient step in (1), applied once per batch.

**Equation (1).**

$$
\theta_{k+1} = \theta_k - \eta \nabla L(\theta_k)
$$

The same step in two frameworks[1]:

**One training step: PyTorch**

```python
loss.backward()
optimizer.step()
```

**One training step: JAX**

```python
grads = jax.grad(loss)(params)
params = params - lr * grads
```

**The loop in AutoPilot, adapted from its README**

```python
module.train()
for epoch in range(5):
  for batch in train_loader:
    data = module(batch)
    loss(data, batch)
  loss.backward()     # feedback fills param.grad
  optimizer.step()    # applies the edit
  optimizer.zero_grad()
```

A policy gate decides whether an epoch is accepted, and if it is not, the experiment rolls back to the last accepted snapshot.

**Figure 2. The improvement loop.** A schematic run of AutoPilot: two candidate changes, one kept and one rolled back.

What the animated figure shows: A candidate change runs forward, loss, backward and step; when the evidence holds it is checkpointed, when it does not it is rolled back.

The optimizer is the part of the loop that applies the edit. AutoPilot's base class leaves `step` to its subclasses and clears each parameter's gradient in `zero_grad`.

**optimizer.py** (pranftw/autopilot at 78e0c54, src/autopilot/core/optimizer.py, lines 203 to 225; [source](https://github.com/pranftw/autopilot/blob/78e0c54dc28abcd0b188b4450d614034952fcacc/src/autopilot/core/optimizer.py#L203-L225)). The optimizer base class in AutoPilot, read from the repository at a pinned commit.

```python
  def step(self) -> None:
    """Apply one optimizer step using current parameter gradients.

    Subclasses read ``param.grad`` on each managed parameter. There is no
    separate ``grads`` iterable -- gradients are always accessed via
    ``param.grad``.

    Raises:
      NotImplementedError: Subclasses must implement parameter updates.
    """
    raise NotImplementedError

  def zero_grad(self) -> None:
    """Clear gradients and stale AccumulateGrad handles on all managed parameters.

    Clears both param.grad (the gradient value) and param.grad_accumulator
    (the AccumulateGrad node reference from the previous forward graph), including
    for frozen parameters (requires_grad=False). Fresh AccumulateGrad nodes are
    created on the next forward pass via AccumulateGrad.get_or_create(param, graph).
    """
    for param in self.parameters:
      param.grad = None
      param.grad_accumulator = None
```

AutoPilot is a prototype with tests and examples; I have not published benchmarks from it yet.

On the scraper agent, the objective would have been authoring time, and the check would have been whether each snippet runs against the live site.

## How a gradient is computed

[Neograd](https://pranavsastry.com/projects/neograd.md) is my small autograd framework. Its `backward` method is where the loop above gets its gradients.

**How neograd runs backward.** The start of Tensor.backward in neograd, read from the repository at a pinned commit.

1. **Guard.** Only a tensor that requires a gradient can start a backward pass. (neograd/autograd/tensor.py, lines 62 to 63)

```python
    if not(self.requires_grad):
      raise ValueError("Only tensors who requires_grad can call backward")
```

2. **Check.** The starting gradient must have the tensor's shape. (neograd/autograd/tensor.py, lines 66 to 68)

```python
    upper_grad = process_data(upper_grad)
    if self.shape!=upper_grad.shape:
      raise ValueError("Shapes of grad and Tensor data must match!")
```

3. **Start.** The gradient is set on the tensor, then its node runs backward. (neograd/autograd/tensor.py, lines 69 to 71)

```python
    self.accumulate_grad(upper_grad) # Setting the grad of the current Tensor by adding the upper_grad
    node = graph.get_node(self)
    node.backward(retain_graph)
```

- Source: [pranftw/neograd at e9e81a8, neograd/autograd/tensor.py, lines 44 to 104](https://github.com/pranftw/neograd/blob/e9e81a8ddd4f52b7f0f7d2dee625f0f4bb24d9d2/neograd/autograd/tensor.py#L44-L104)

## Placeholders for the rest of the kit

The parts below are here to show the kit, not to argue anything. The first is the deck I made for the ELITS paper.

**ELITS, in six slides** (slides, 6). A short talk on ELITS, from the deck file.

- Open the deck: [https://pranavsastry.com/kit/decks/elits.html](https://pranavsastry.com/kit/decks/elits.html)

1. Title: Pranav Small models, honest baselines. Pranav Sastry, MS in CS at Georgia Tech. How ELITS fills gaps in sensor data with 11 thousand parameters.
2. Statement: Sensors drop readings. The best models for filling the gaps carry 9.4 million parameters.
3. Diagram: ELITS mixes across time and channels, then fills the gaps. Readings with gaps. Sensors drop values. Patches. Each channel is cut into short pieces. Two mixers. One across time, one across channels. Imputed. The gaps are filled in black.
4. Chart: ELITS is 858 times smaller, and more accurate. Parameters Drawn to scale. 9.438M 11K GPT4TS ELITS Average error Lower is better. 0.075 0.062 GPT4TS ELITS 858 times fewer parameters, with lower error. Fig. 1 Mean squared error, seven datasets, four masking rates.
5. Big number: 858× fewer parameters than GPT4TS, with lower error. 11 thousand parameters against 9.4 million, averaged over seven datasets and four masking rates.
6. Contact: Pranav Hiring for Summer 2027? Let’s talk. pranava.sri@gmail.com pranavsastry.com

A diagram drawn from text, and a comparison of two of my illustrations.

**Figure 4. The loop.**

What the diagram shows: A run feeds a change, which is kept or rolled back

- Run → Evidence → Change
- Change → Kept, Rolled back

**Figure 5. Two illustrations.** Drag the handle, or use the arrow keys, to move between the two.

What the comparison shows: IISc (The Indian Institute of Science main building) against Glasshouse (The glasshouse at Lalbagh).

![The Indian Institute of Science main building](https://pranavsastry.com/illustrations/iisc.33a7a4a99672444f.webp)
![The glasshouse at Lalbagh](https://pranavsastry.com/illustrations/glasshouse.126cc5c18ebef82d.webp)

![The Indian Institute of Science main building](https://pranavsastry.com/illustrations/iisc.33a7a4a99672444f.webp)

The Indian Institute of Science.

![The glasshouse at Lalbagh](https://pranavsastry.com/illustrations/glasshouse.126cc5c18ebef82d.webp)

The glasshouse at Lalbagh.

![A stone temple](https://pranavsastry.com/illustrations/temple.b1a9d30b86cb65f8.webp)

A stone temple.

![The temple at dusk](https://pranavsastry.com/illustrations/temple.b1a9d30b86cb65f8.webp)

One of my illustrations.

## What I want to study next

I want to test bounded changes to coding-agent harnesses against fixed objectives, and build the infrastructure that makes those tests cheap: persistent state, machine-readable traces and independent checks. The full question is in my [research statement](https://pranavsastry.com/research.md).

## References

1. **ELITS: efficient lightweight imputation for time series.** Sastry et al., AAAI 2026 workshop on AI for time series. [Paper](https://ai4ts.github.io/aaai2026)

## More posts

- [Evidence](https://pranavsastry.com/posts/evidence.md): How the ELITS ablation table and AutoPilot’s journal keep the reason next to the decision.
- [All posts](https://pranavsastry.com/posts.md)
- [Home and directory](https://pranavsastry.com/index.md)
