WHALE: A Simple Recipe for Joint Harness–Weight Optimization
arXiv ↗PDF ↗Paper ↗Code ↗Blog ↗
Read first: Meta-Harness: End-to-End Optimization of Model Harnesses · STaR: Bootstrapping Reasoning With Reasoning
TL;DR. An agent is a model and a harness: the code that decides what enters the context, how tools are called, how errors come back and when to stop. Optimise only one and the frozen one becomes the ceiling. WHALE (Weight–Harness Alternating LEarning) alternates a weight phase (online rejection-sampling fine-tuning, harness frozen) with a harness phase (Meta-Harness searching harness code, model frozen). With one fixed schedule it beats weight-only, harness-only and prompt-only co-training in search QA, math with a Python tool and chess puzzles. The analysis is the real lesson: either component can be the bottleneck, a small weight update can make harness search work where it failed, and per-phase length must sit between “too noisy” and “over-fitted to a partner that will change”.
Why it matters now. Meta-Harness closed by naming co-evolution of harness and weights as an open question; WHALE gives a controlled, budget-matched answer from overlapping authors. Earlier joint methods such as BetterTogether only let the context side be prompts. For an IR person the SearchQA results are the striking part: query rewriting, top-k and ranking live in the harness, and harness search alone more than doubled retrieval accuracy.
Key idea
Section titled “Key idea”One objective, two blocks (§3). Let be the weights and an executable harness program. Together they induce a trajectory distribution , and with a binary verifier the system’s value is
is not separable: the best weights depend on the harness and vice versa. Write the best responses and . Weight-only training can reach at most , harness-only search at most , and both can sit well below the joint maximum. That is the blog’s “whichever half you freeze becomes the ceiling”.
Alternation = block coordinate ascent (Eq. 4).
With exact best responses, . WHALE keeps only part of this guarantee: the harness archive is seeded with and the best-scoring entry is returned, so the harness phase never lowers the empirical training score. RSFT steps have no such guarantee, and the training score is a noisy estimate. The authors pick alternation over running both at once because a concurrent update is scored against a moving partner, which confuses credit assignment.
Weight phase: online RSFT (§3.1). Sample rollouts per prompt under , keep those with (the set ), and maximise token-normalised log-likelihood on model-generated tokens only (tool outputs and prompts are masked):
For an RL beginner: this is success-filtered maximum likelihood. At the sampling policy its gradient is proportional to a binary-reward policy-gradient estimate, but the later minibatch updates (no importance correction) are not in general unbiased REINFORCE. Only successes push. It is simpler than GRPO; the paper cites prior work for stability but does not establish a head-to-head stability advantage. It gets no signal from failures and none at all if nothing succeeds (the STaR family has the same property).
Harness phase: Meta-Harness (§3.2). Each iteration, one Claude Opus 4.7 session reads the archive (code, per-example outcomes, trajectory logs) and writes candidates. Each is scored with one rollout on each of 256 harness-training examples, so an iteration costs 768 rollouts. The phase returns the archive’s argmax. The search may change prompts, tool I/O formatting, feedback after a tool call, stopping and turn allocation, plus domain-specific parts: query rewriting, retrieval parameters and ranking in SearchQA; code extraction and error surfacing in Math; board presentation and move parsing in Chess (it may not choose the move).
One cycle (Algorithm 1): what is fixed where.
model θ harness h archive A data scoredweight phase trained (RSFT) frozen at h_k not used D_weight: G=8 rollouts/prompt, E epochsharness phase frozen at θ_{k+1} searched (MH) reset to {h_k}, grows D_harness: 256 ex × 1 rollout × M=3, I itersend of cycle θ_{k+1} kept h_{k+1} = argmax A discarded D_test: mean@8 logged (best cycle reported)When to switch. The schedule sets epochs per weight phase and iterations per harness phase; the main runs use . Adaptive WHALE replaces it with per-phase patience on training signals only. The weight phase stops after a minimum length once the windowed rollout reward has not set a new phase best for steps ( epoch). The harness phase stops after iterations once the best archive score has not improved for iterations. Any improvement, however small, resets patience.
What the numbers say
Section titled “What the numbers say”Setup. Qwen3.5-2B for SearchQA (Search-R1 data: 18,946 HotpotQA+NQ training questions, 700 test questions over seven QA sets, Wikipedia 2018 with FAISS) and Math (DAPO-Math-17K training, 60 AIME 2024+2025 test problems, Python interpreter); Qwen3.5-4B for Lichess puzzles (256 test). Accuracy is best test mean@8. Baselines get budgets matched to WHALE’s cumulative epochs and iterations. FST here is a control with WHALE’s operators and schedule but search limited to the system and user prompts.
Main comparison (Table 2, ).
| Domain | Harness-only | Weight-only | FST (prompt-only) | WHALE |
|---|---|---|---|---|
| SearchQA (avg of 7) | 38.29 | 38.27 | 35.34 | 48.34 |
| Math (AIME 24/25) | 0.42 | 15.42 | 17.92 | 24.79 |
| Chess puzzles | 19.82 | 22.17 | 25.68 | 29.83 |
WHALE beats the stronger single-component baseline by 7.67–10.05 points and FST by 4.15–13.00. The paper’s 24.38 upper figure is against harness-only in Math, the weaker baseline. WHALE is best on every individual benchmark.
Dominance regimes (§6.1).
- SearchQA is harness-dominant. Harness-only matches weight-only’s peak with 30,720 rollouts versus 530,432 (5.79%). Retrieval accuracy (a trajectory retrieves at least one document containing the answer) goes from 26.88% to 60.61% under harness search alone; WHALE reaches 65.41%. Weights win on answer extraction (79.93% vs 57.28% peak). The discovered harness allows three searches over four turns, adds a verification checklist, and inserts a “titles retrieved so far” state line between turns.
- Math is model-dominant. 95.83% of base responses are truncated at the token limit; weight-only cuts this to 30.83%. Harness-only tries response caps, turn limits and an answer-recovery step, but the tested harness-only search did not overcome this baseline’s truncation behaviour. After one small weight update, the first harness phase lifts format accuracy from 0.83% to 4.38% in 4,608 rollouts; harness-only spent 46,080 to go from 0.00% to 0.63%.
Schedules (Table 3, best mean@8 and rollouts to reach it).
| Run | SearchQA | rollouts | Math | rollouts |
|---|---|---|---|---|
| Stagewise | 43.02 | 604,160 | 15.63 | 893,952 |
| 46.63 | 526,336 | 16.67 (stopped) | 240,128 | |
| 50.09 | 589,824 | 28.33 | 599,040 | |
| 48.84 | 378,880 | 17.92 | 582,656 | |
| 48.34 | 382,464 | 24.79 | 720,384 | |
| 45.93 | 294,400 | 24.79 | 510,464 | |
| Adaptive | 52.82 | 295,424 | 26.46 | 689,152 |
- Stagewise loses by 5.32 (SearchQA) and 9.16 (Math); WHALE passes it after 29% and 49% of its rollouts. In Math the 60-iteration stagewise harness search kept raising its training score yet added only +0.21 test points over weight-only.
- Bigger phases never help past in either domain, and and interact: in Math, 0.2 → 0.6 helps at but hurts at .
- Adaptive WHALE gives the best SearchQA point (+4.48 over , +2.73 over , 23% fewer rollouts than to its best). In Math it is +1.67 over but 1.87 below . Realised phases have median 0.24 / 0.29 epochs and 7 iterations, close to .
Caveats
Section titled “Caveats”- Test-set selection. Reported numbers are best-so-far test accuracy, and the algorithm returns the cycle with the best test score. A validation split would separate method gains from selection.
- Small test sets, no error bars. Math has 60 problems (about ±5.6 points SE at 25% accuracy); no seeds or confidence intervals are reported, and one run was stopped.
- Rollouts are not cost. Proposer compute is excluded by design; an Opus 4.7 session per iteration may cost more than the 2B rollouts it saves.
- Harness overfitting. Each candidate is judged on 256 examples with one rollout; the stagewise Math result shows the archive can climb on training noise.
- Scope. 2B/4B models, binary verifiers (a GPT-5.4-mini judge for SearchQA), and an FST re-implementation with RSFT and Meta-Harness rather than FST’s original RL and reflective prompt evolution.
- Adaptive is not free of hyperparameters. Window, minimum length and patience replace , and they were set once without a reported sweep.
Connections
Section titled “Connections”- The harness operator: Meta-Harness is used unchanged inside each harness phase; WHALE answers its open question about co-evolving weights.
- Prompt-side ancestors: BetterTogether alternates DSPy prompt optimisation with fine-tuning; GEPA is an analogous reflective, prompt-only optimizer (not a literal special case of WHALE’s harness phase). WHALE widens the context-side variable from prompt text to code.
- Why harness choice moves generalization: harness generalization argues the harness decides what each model call sees, which fits SearchQA being harness-dominant.
- Weight phase lineage: STaR (self-training on own successes) and the RFT / online-RFT view in DeepSeekMath / GRPO; Math data and the strict boxed verifier come from DAPO.
- Freeze-the-context, train-the-weights: Engram notes + RL runs one weight phase (GRPO + LoRA) under frozen notes, harness and GEPA-tuned prompt; WHALE’s results suggest asking whether a harness or prompt re-search after that RL would add more.
- SearchQA setup: data, retriever and test sets follow Search-R1, which keeps the harness fixed and trains only weights.
- Evaluation hygiene: LLM-as-judge and statistics and judge calibration for the judge and small-sample caveats.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Derive / compute
Every harness-search iteration scores M = 3 candidates with one rollout on each of 256 harness-training examples. Weight updates sample G = 8 rollouts per prompt, and one WHALE cycle in Math is 0.6 epochs of the 17,917-problem training set plus I = 6 search iterations. Compute the rollout cost of one search iteration, of harness-only search in SearchQA (40 iterations) and Math (60 iterations), and of one Math cycle. Then compare format-accuracy gain per 1,000 rollouts for the first Math harness phase (+3.54 points) and for harness-only search on the base model (+0.63 points), and say what the rollout count leaves out.
What a strong answer covers
- One iteration = 256 × 3 × 1 = 768 rollouts; SearchQA harness-only = 40 × 768 = 30,720, which is 5.79% of the 530,432 rollouts weight-only needed to reach the same peak (38.27 vs 38.29).
- Math harness-only = 60 × 768 = 46,080; the first WHALE harness phase = 6 × 768 = 4,608.
- One Math weight phase ≈ 0.6 × 17,917 ≈ 10,750 prompts × 8 ≈ 86,000 rollouts, so the harness phase is only about 5% of a cycle's rollouts, approximately 90,610 target-model rollouts per Math cycle.
- Gain per 1,000 rollouts: 3.54 / 4.608 ≈ 0.77 points versus 0.63 / 46.08 ≈ 0.014 points, roughly 56× more efficient after one small weight update.
- The count covers only target-model rollouts; Claude Opus 4.7 proposer sessions (one per iteration, reading code and traces) are excluded, and could dominate dollar cost for a 2B model.
- Connect
BetterTogether, Fast–Slow Training (FST) and WHALE all alternate a context-side update with a weight update. In this paper FST uses the same RSFT and Meta-Harness operators and schedule as WHALE but may only edit the system and user prompts. FST scores 35.34 in SearchQA, below both weight-only (38.27) and harness-only (38.29), yet beats both in Math (17.92 vs 15.42) and Chess (25.68 vs 22.17). Use the coordinate-ascent view and the SearchQA base harness to explain this pattern.
What a strong answer covers
- In coordinate ascent the reachable value is limited by the feasible set of each block: restricting h to prompts shrinks max over h of J(θ, h), so the best response to any θ can be much worse.
- The SearchQA base harness forwards queries unchanged, returns one 200-token passage and stops after two assistant turns; prompt edits cannot change top-k, query rewriting, ranking or the turn budget, which is where the retrieval bottleneck sits (retrieval accuracy 26.88% → 60.61% under full harness search).
- Prompt-only search can still push format and answer style, so weights may co-adapt to prompts that look good on 256 training examples but do not fix retrieval, a plausible reason FST falls below both single-component baselines.
- Math and Chess are model-dominant, so prompt edits that steer an improving model (e.g. answer format, move format) add to the weight updates.
- BetterTogether alternates DSPy prompt optimisation with fine-tuning; WHALE generalises the context side to executable code. GEPA is an analogous prompt-only optimizer, not literally a limiting case of WHALE's particular proposal-and-update algorithm.
- Mechanism
In Math, harness-only search on the base Qwen3.5-2B gains almost nothing (0.42% test accuracy after 46,080 rollouts), but the same Meta-Harness search run after one 0.6-epoch RSFT phase raises format accuracy from 0.83% to 4.38%. Explain, in terms of the binary verifier, what the harness can and cannot control, and the information available to the proposer, why a small weight update turns an ineffective search into an effective one.
What a strong answer covers
- The base model reasons in prose until it hits the 8,192-token limit (95.83% of responses truncated), so almost no rollout contains a parsable boxed answer and R = 0 nearly everywhere.
- With near-zero reward for every candidate on 256 examples, the archive argmax is driven by noise and the traces all show the same failure; the proposer has no contrast to learn from.
- Harness levers (response caps, turn limits, a final-answer recovery step) can stop generation, but truncation does not produce a correct answer. In these experiments, harness-only interventions did not make the baseline solve reliably before its limit.
- The verifier selects correct, parseable completions within the budget, so RSFT shifts the length distribution (truncation falls to 30.83% after weight-only training). Interpreter use is an observed strategy, not a requirement of the acceptance rule.
- Once the model emits short turns and code calls, harness changes such as more assistant turns and a reminder to box the settled result after tool output start to produce reward differences, so search has signal. The authors call this a catalytic interaction.
- Analogy: GRPO gets zero advantage when every sample in a group fails; harness search equally needs reward variance across candidates.
- What if…
The Math schedule sweep gives best test mean@8 of 16.67 for (E, I) = (0.2, 2) (run stopped after it destabilised), 17.92 for (0.6, 2), 28.33 for (0.2, 6), 24.79 for (0.6, 6) and (1.0, 10), and 15.63 for stagewise (4.3 epochs then 33 iterations). Explain the two failure modes this sweep exposes. As part of the answer, estimate the standard error of a harness's training score (one rollout on each of 256 examples, true accuracy about 0.3) and say how it bears on the noisy end.
What a strong answer covers
- Under an illustrative iid Bernoulli model, SE ≈ sqrt(0.3 × 0.7 / 256) ≈ 2.9 points. For six independent Gaussian score errors the expected maximum is about 1.27 SE, or 3.6 points. Real candidates share examples and are adaptively proposed, so this is a toy illustration, not an estimated bias for WHALE.
- Noisy end: with I = 2 the phase stops before real improvements clearly exceed this noise; (0.2, 2) accepted a chance-inflated harness, the model then trained on rollouts under it, and the run destabilised.
- Nuance: more iterations also mean more candidates and a larger max-of-noise; longer search helps because real proposer gains grow faster than the inflation, not because selection noise disappears.
- Over-optimised end: J(θ, h) is not separable, so a long phase fits one component to a counterpart that will change; stagewise harness search kept raising its training score across 60 iterations yet gained only +0.21 points on test (15.63 vs 15.42).
- E and I interact: raising E from 0.2 to 0.6 helps at I = 2 (16.67 → 17.92) but hurts at I = 6 (28.33 → 24.79), so neither budget can be tuned alone.
- Critique
WHALE's headline claim is that small alternating phases beat every single-component and prompt-only baseline, with Math gains such as 28.33 for (0.2, 6) vs 24.79 for (0.6, 6) on a 60-problem AIME 2024+2025 test set. Identify the main threats to validity in how results are selected and reported, and design the experiment that would most change your confidence.
What a strong answer covers
- Each run reports its best-so-far test mean@8, and Algorithm 1 returns the cycle with the best test accuracy, so model selection happens on the test set; a held-out validation split for checkpoint selection is missing.
- Sixty test problems give limited resolution, but a marginal binomial SE cannot establish that a paired schedule difference is noise. Bootstrap paired per-problem mean@8 scores and repeat training and search seeds; do not treat 480 rollouts as 480 independent problems.
- No seeds or confidence intervals are reported, and the (0.2, 2) run was stopped, so run-to-run variance of a noisy harness-acceptance process is unknown.
- Proposer compute (Claude Opus 4.7) is excluded from rollout budgets; the FST control replaces its original RL update and reflective prompt evolution with RSFT and Meta-Harness, so it tests search space, not FST as published.
- Small models (2B and 4B, learning rate 1e-7) and a GPT-5.4-mini judge in SearchQA; whether the regime findings hold for larger models that already follow formats is open.
- Better test: 3+ seeds per schedule, validation-based selection, a larger math test set, and cost reported in dollars including proposer tokens.
- Design
You train a 4B search agent over a fixed corpus with BM25 and a dense retriever, with a budget of about 400,000 target-model rollouts and a limited proposer-token budget. The harness may change query rewriting, top-k, fusion and reranking, deduplication, the turn budget and the answer prompt. Design an adaptive WHALE-style schedule: the harness-training set, the stopping rules for each phase, the diagnostics you log, and how you select the final pair.
What a strong answer covers
- Start with a short harness-only search as a cheap diagnostic, as the paper suggests: if retrieval recall (fraction of trajectories retrieving an answer-bearing document) jumps, the task is harness-dominant like SearchQA.
- Harness set: a few hundred hard but solvable training queries. At fixed rollout budget, repeats reduce within-query sampling noise but sacrifice query diversity; estimate both variance components, re-score promising candidates on held-out queries, and consider a margin before an improvement resets patience (the paper accepts any margin).
- Weight phase: windowed rollout reward with minimum length, window and patience (the paper used 0.2 epochs each); harness phase: minimum iterations and patience on best archive score (the paper used 6 and 2), plus a cap on iterations so search cannot overfit the scored examples.
- Log per-cycle retrieval recall, correctness given a relevant document, format rate, turns and search calls, so you can see which component is the bottleneck, as in Figure 3.
- Count proposer tokens in the budget; select the final (θ, h) on a held-out validation split, not test, and audit harness code for hard-coded queries or answers.