r/MachineLearning • • 2h ago

Research Train the context, not the weights: optimizing only an agent's harness matched RL fine-tuning (Nemotron 3.5 Super, AutomationBench) [R]

Write-up: afnio.ai/blog/train-the-context-not-the-weights

Can an agent get RL-level gains without any weight updates? Most of what makes an agent fail in practice lives in its harness: the prompts, tool descriptions and skills around the model. We tested how far optimizing only that gets you.

Setup:

  • Benchmark: AutomationBench (agent solving everyday office tasks).
  • Trainable: the system prompt, tool descriptions and skills. Model weights are frozen throughout.
  • Method: when a run fails, written feedback is backpropagated through the agent's graph to the component that caused it, and only that component is rewritten. Candidates are selected on a validation set.
  • Baseline: every model was run first on its stock harness, then on the trained one. We ran all of these ourselves, except the RL result for Nemotron 3.5 Super, which comes from Surge AI's published paper.

Findings:

  1. Matches RL on the weights. On Nemotron 3.5 Super, RL on the weights gained +15.0 points [7, 23] (single reported run). Harness training gained +12.0 [7, 18] on average over 3 runs, and +15.3 [8, 23] in the best run, reaching the same 22.0% pass rate, up from ~7%.
  2. It learns the same habit RL did. Surge's RL-trained model learned to look before acting. The trained harness learned it too: writing before reading the inbox or Slack dropped from 29% to 7% of tasks. The difference is that here the lesson is written into the harness, where you can read it.
  3. Lifts every model, even at max reasoning. GPT-5.6 Luna 27.8 → 37.8, DeepSeek V4.1 Flash 42.3 → 58.5, Claude Sonnet 5.5 54.0 → 61.0, GPT-6 Astra 56.0 → 67.0.
  4. Open-weight beats frontier. With a trained harness, DeepSeek V4.1 Flash (58.5) outscored Sonnet 5.5 and GPT-6 Astra on their stock harness.
  5. It transfers. Trained on finance, marketing, ops and support tasks; the gains held on sales tasks it never saw.

On "training": the weights never change, but the harness does learn from failures on the training split, using textual feedback instead of numerical gradients.

Caveats: we used our simplest selection strategy; most results are on one benchmark, with more in progress.

So a large part of what holds an agent back seems to sit in its context, and it can be found and fixed automatically.

Disclosure: I'm the author and work on Afnio (Tellurio), the optimizer used here. The SDK is open source, and the optimizer runs as a hosted service. Happy to answer questions!

15 Upvotes

19 comments sorted by

7

u/HatefulWretch 2h ago

What you’ve described is TextGrad. There are considerably stronger harness optimizers available now (GEPA, Metaharness, HyperAgents, etc etc etc).

1

u/dmpiergiacomo 2h ago

Well spotted! The main author of TexGrad is one of our reviewers and we thanked him in the acknowledgements section. We added a few things to the textual gradients concept (better described in the article). We also benchmarked against GEPA and Microsoft SkillOpt in a dedicated section.

3

u/HatefulWretch 2h ago

Those are weak baselines. I think you’d want Metaharness, HyperAgents/Darwin Gödel Machines, anything which allows the optimizer free code rewriting.

1

u/dmpiergiacomo 2h ago edited 2h ago

Thanks for the input! Yes, we are totally running more experiments on more benchmarks and against more solutions. Meta-Harness is totally among them. Which are the ones you'd recommend on top of the ones you listed?

1

u/HatefulWretch 2h ago

It’s worth considering the explicitly evolutionary lineage, eg Sakana’s ShinkaEvolve. If you’re interested in controlling for optimization budget, BudgetAPO has some interesting ideas.

1

u/dmpiergiacomo 2h ago

Thanks I'll pull those in. Any tips on the benchmarks to use? Ideally not something too expensive.

3

u/tbroe 2h ago

Very cool approach! Looking forward to giving this a try!

1

u/dmpiergiacomo 2h ago

Thanks a lot! Every feedback on the method and our research is very welcome!

2

u/hapliniste 2h ago

This makes me sadder we use kilo code at work 😭 it's quite bad

2

u/dmpiergiacomo 2h ago

Oh no, sorry to hear! Since it's open source, tuning its harness could be a fun project. Why is it bad for you? And does it struggle with something specific, like your own repo or internal company tools maybe?

1

u/hapliniste 1h ago

For a start, the compaction system is stuck in 2024.

Just give the agent the full thread as a file and let it output a compaction result Wtf is this shitty one format no tool compaction?

I'm not trying to be rude but that one part is really lightyears behind while all you have to do is let the agent handle it.

1

u/hapliniste 34m ago

Also there are bits to love about kilo like the agent manager. A quick UX rework could do wonders on that but in term of features that part is great.

2

u/keepthepace 1h ago

Hopefully there are some prior work, but that's the first time I heard about this idea. That sounds super interesting!

It makes me wonder if there are people out there trying to train a dataset. That would probably be an order of magnitude harder, but I wonder if there are experiments in that direction?

1

u/dmpiergiacomo 1h ago

Thanks! There's a lot of prior work here, from prompt optimizers like DSPy, TextGrad and GEPA to harness work like Meta-Harness. Our angle is developer experience: we want to plug into the agent you already have, so you don't have to rewrite it in a new framework.

On training a dataset, that's a funky one! Do you mean something like dataset distillation?

2

u/Time_for_Sicily 56m ago

Intresting approach! Which kind of things did the trained agent learn?

1

u/dmpiergiacomo 45m ago

Mostly good habits. Before training, the agent counted a test deal in a pipeline report because it never checked a Salesforce note saying to skip it. After training, it read the note first and got it right. Across tasks, writing stuff before checking the inbox or Slack dropped from 29% to 7%. Funny enough, Surge's RL learned the same 'look before you act' thing, just in the weights instead of in the harness.

2

u/[deleted] 1h ago

[removed] — view removed comment

1

u/dmpiergiacomo 1h ago

This describes tremendously well our philosophy too