Pranav

Writing

I treat the harness as 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.

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.

The harness, layer by layer
Table
LayerWhat it decides
ModelProposes reasoning and actions.
Context and memoryWhich evidence and past experience the model sees.
Tools and environmentWhat the agent can inspect, change, run and observe.
Workflow and subagentsHow work is split up, and how state is kept apart.
Verification and permissionsWhat counts as done, and which changes are allowed.

Where I ran into it

The scraper workflow 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.
Time to author a scraper
Chart

About 3 hours by hand; 15 minutes with the workflow.

Minutes to author one scraper

The axis starts at zero.

By hand180 min
Agentic workflow15 min

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

Fig. 1Time to author one custom scraper, by hand and with the agentic workflow, 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.

It is the standard I held my papers on ELITS and data attribution to: every result against a named baseline.

A first attempt in code

AutoPilot 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.

(1)

The same step in two frameworks:

One training step
Code
loss.backward()optimizer.step()
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.

The improvement loop
Film

Run. Candidate 1 runs forward; the loss gathers feedback.

Fig. 2A schematic run of AutoPilot: two candidate changes, one kept and one 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
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
pranftw/autopilot at 78e0c54, src/autopilot/core/optimizer.py, lines 203 to 225Source
Fig. 3The optimizer base class in AutoPilot, read from the repository at a pinned commit.

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 is my small autograd framework. Its backward method is where the loop above gets its gradients.

How neograd runs backward
Walkthrough
  1. Guard. Only a tensor that requires a gradient can start a backward pass.

    neograd/autograd/tensor.py

    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.
    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.
    self.accumulate_grad(upper_grad) # Setting the grad of the current Tensor by adding the upper_gradnode = graph.get_node(self)node.backward(retain_graph)
neograd/autograd/tensor.py
Python
  def backward(self, upper_grad=1., retain_graph=False):    '''Kicks off the backward pass to calculate gradients     Starts the gradient calculation for the backward pass from the    Tensor, by calling the backward method of its corresponding Node          Args:      upper_grad (int or float or list or np.ndarray): The gradient with which to start the        gradient calculation. Shape of upper_grad and shape of Tensor must be the same.        Defaults to 1 as usually backward is called on a loss Tensor that has a scalar value      retain_graph (bool): If the graph should be retained after backward pass or should be reset.        Auto-removal of Tensors from the graph, which happens when the gradients of all tensors of        node's parents have been calculated will be turned off.        Raises:      ValueError: If called on a Tensor that doesn't have requires_grad      ValueError: If shapes of upper_grad and Tensor doesn't match    '''    if not(self.requires_grad):      raise ValueError("Only tensors who requires_grad can call backward")    from .utils import get_graph    graph = get_graph()    upper_grad = process_data(upper_grad)    if self.shape!=upper_grad.shape:      raise ValueError("Shapes of grad and Tensor data must match!")    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)    if not(retain_graph):      graph.reset_graph() # tensors are auto-removed, this is just for redundancy / safety    def _backward(self, node, retain_graph, calculate_grads=True):    '''The essence of autograd, final gradient calculations for the Tensor is performed here     The gradient of each child is taken as upper gradient, the backward_fn of the     Node of the Tensor is executed to set the grad_fn of Tensor.     grad_fn is executed, the grad is then unbroadcasted, if Tensor has been broadcasted    during the Operation. auto-removal of Tensor from the graph is performed when    retain_graph is False     Args:      node (Node): The Node corresponding to the Tensor      retain_graph (bool): Whether the graph needs to be retained or reset      calculate_grads (bool): Whether gradients should be calculated or not,        Defaults to True    '''    from .utils import get_graph    graph = get_graph()    for child in node.children:      if self.requires_grad and calculate_grads:        child.backward_fn(*[node.tens for node in child.parents])        upper_grad = child.tens.grad        grad = self.grad_fn(upper_grad)        grad = unbroadcast_data(grad, self.shape, child.parent_broadcast_shape)        grad = grad.reshape(self.shape)        self.accumulate_grad(grad)      if not(retain_graph) and child.are_parents_visited():        graph.remove_tensor(child.tens)    if not(retain_graph) and node.are_parents_visited():      graph.remove_tensor(node.tens)
pranftw/neograd at e9e81a8, neograd/autograd/tensor.py, lines 44 to 104Source
Fig. 4The start of Tensor.backward in neograd, read from the repository at a pinned commit.

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
The first slide: Small models, honest baselines. Pranav Sastry, MS in CS at Georgia Tech.
Fig. 5A short talk on ELITS, from the deck file.

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

The loop
Diagram
Run > Evidence > Change
Change > Kept, Rolled back
Run
Evidence
Change
Kept
Rolled back
Two illustrations
Comparison
The Indian Institute of Science main building
The glasshouse at Lalbagh
IIScGlasshouse
Fig. 6Drag the handle, or use the arrow keys, to move between the two.
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.

References

  1. ELITS: efficient lightweight imputation for time series. Sastry et al., AAAI 2026 workshop on AI for time series. Paper