Research blog · December 2026

One target, many objectives: composing rewards in language model post‑training

In GRPO, we sample several answers to a prompt, score them, and update the model to favour the higher-scoring answers. Suppose we reward a tool-use agent for finishing the user's task and penalise it whenever it carries out an instruction planted in an email or a web page. That tells us how to score a batch of trajectories. Can it also tell us how often the agent should produce each trajectory, or how to combine a task-focused policy and a more cautious one we have already trained?

Last updated 4 December 2026.

Target distribution
π*(y | x) ∝ p(y | x) · exp(Σ λᵢ rᵢ)
add, re-weight or negate an objective = edit one sum gated terms only re-rank correct outputs

Every objective is a reward term; one weighted sum defines the target; the same target drives four uses.

Evaluated on held-out tasks; click a card to jump to it. Decode: at equal weights, gap to the jointly trained policy in pass rate or clean code, with experts trained by standard GRPO or by tilt-GRPO (KL coefficient one). Security: two seeds, our evaluation harness, against task-only RL on the same episodes (Gemma 4 26B: 2.1–2.5% vs 4.8–5.4%). Dial: Qwen2.5-7B, shown for security seed one (it replicates with seed two); two forward passes per token until distilled.

TL;DR

Part I · From a GRPO reward to a target

01From a GRPO reward to a target distribution

Start with the reference model. Give each trajectory its original probability, then multiply that probability by the exponential of its reward. This defines a target distribution. If two trajectories both finish the task, the security penalty tells us exactly how their relative odds should change. And because rewards add, their probability multipliers multiply. That is the composition rule we test in this post, on agents and also on code and math.

The target behind the GRPO update

$$\max_{\pi}\; \mathbb{E}_{y \sim \pi}\Big[\sum_i \lambda_i\, r_i(x, y)\Big] \;-\; \beta\, \mathrm{KL}\big(\pi \,\|\, p\big)$$ $$\Longrightarrow \qquad \pi^*(y \mid x) \;\propto\; p(y \mid x)\, \exp\!\Big(\frac{1}{\beta} \sum_i \lambda_i\, r_i(x, y)\Big)$$ The idealised KL-regularised objective; GRPO is the procedure that trains toward it.

In our target-fitting runs, we subtract the sampled sequence log-ratio \(\log(\pi/p)\) from the reward with coefficient one (\(\beta = 1\)), subtract the group mean, and keep the advantage in its original units.

Why call it an energy?

Write each reward term as an energy, \(E_i = -r_i\), so lower is better. The target becomes

$$\pi^*(y \mid x) \;\propto\; p(y \mid x)\, \exp\!\Big(-\frac{1}{\beta} \sum_i \lambda_i\, E_i(x, y)\Big)$$

the same shape as a Boltzmann distribution in physics, where states with lower energy are exponentially more likely. Here the reference model \(p\) plays the prior, \(\beta\) the temperature, and \(\lambda_i\) how much energy one unit of each penalty costs. The useful intuition is about odds. Take two trajectories that are identical except that one carries out the injected instruction: the target multiplies their odds by \(e^{-\lambda/\beta}\). At \(\lambda = \beta = 1\), the odds of the hijacked trajectory relative to the equally successful safe one fall to \(1/e\) (about 0.37) of their original value; at \(\lambda = 3\), to \(e^{-3}\), about 1/20. Energies from different sources add, so their odds factors multiply, and that is the composition rule below, seen from the other side. A tool-call count, a lint count, a binary checker or a learned score can all play the role of an energy.

The composition rule

If separately trained policies reach their respective targets for a shared base \(p\) and the same KL coefficient \(\beta\), then at the sequence level

$$\pi^*_{A+B}(y \mid x) \;\propto\; \frac{\pi^*_{A}(y \mid x)\;\, \pi^*_{B}(y \mid x)}{p(y \mid x)}$$ each expert already contains the base model, so multiplying the experts counts \(p\) twice; dividing by \(p\) once removes the extra copy

For the agent, let \(T\) be trained on the task reward and \(S\) on the task reward plus the security penalty. Then \(S/T\) carries the penalty alone, and mixing the two gives a target for any amount of caution, with no retraining:

$$\pi^*_{\text{task} \,+\, a \cdot \text{security}}(y \mid x) \;\propto\; T(y \mid x)^{1-a}\; S(y \mid x)^{a}$$ \(a = 0\) is the task agent, \(a = 1\) the security-trained policy, \(a > 1\) extrapolates. For code, where the lint policy was trained on lint alone, the general form of Section 09 mixes it with the correctness policy

The identities are exact for fixed rewards and policies that reach their targets. Two things can break them in practice. Online scores such as answer consensus depend on the other samples and on the policy generating them, so they change during training. And a trained policy's log-ratio to the base only approximates the reward it was trained on; for the agent, Section 05 shows that the real \(S/T\) also carries what task-only training on the injected episodes learns. How closely real policies get there is an empirical question, and the rest of the post measures it: first on agent security, then on code and math. Training with a KL coefficient of one and no division by the group's standard deviation gives the policy ratio a specific reward interpretation we can test. Whether the KL term sits in the reward, as in our runs, or in the loss does not change that ideal optimum. And none of this is a precondition for mixing: standard-GRPO experts also mixed well in our code experiments (Section 09).

Want the demonstration first? Jump to the interactive caution dial →

02Reward terms from any source

Each term in the sum is a cheap score of an output. The terms can come from almost anywhere, and nothing requires them to be trained together:

Learned head
A small MLP on frozen hidden states, e.g. a verifier score.
score: log P(correct)
Exact rule
Unit tests, lint findings, length, tool calls.
penalty: # lint findings
Group statistic
Agreement among the sampled answers: a consensus score, no labels needed.
score: log share(answer)
LM judge
A rubric score from a larger model.
score: expected rating
Security check
Did the agent carry out an injected goal?
penalty: 1[goal executed]
Gating
Diversity, speed and tool-call cost only re-rank outputs that are already correct, so novel, fast or cheap wrong answers earn nothing. Lint and security apply to every output.

Adding an objective adds a term. Re-weighting changes a \(\lambda_i\). Negating flips a sign. The object being edited is always the same weighted sum.

03Four uses of one target

USE 1Reweight at inference

Sample, weight each output by the exponential of its summed reward, resample.

MATH500 +5.8
USE 2Fine-tune on the target

Distil the reweighted samples into the model.

−18% length
USE 3The RL reward

The weighted sum as the GRPO reward, with a KL coefficient of one, so that the optimum is this target.

optimum = target
USE 4Compose at decode time

Mix trained policies token by token, \(p \prod_i (\pi_i / p)^{c_i}\), with an importance-weight correction.

no retraining

Both on Qwen2.5-Math-1.5B (base). Use 1: resampling 16 base samples by a verifier head (λ = 2) raises MATH500 per-sample accuracy from 41.1 to 46.9% against plain sampling at temperature 0.6, at unchanged pass@8; on GSM8K it beats every sampling temperature on both accuracy and pass@8. Use 2: fine-tuning on samples reweighted by verifier + conciseness heads cuts MATH500 answer length by 18% (242 → 199 tokens) against fine-tuning on the verifier alone, at similar accuracy (48.4 vs 48.2%); it also beats a weight soup of the two single-objective models.

Figure 1: method overview, six headline results across code, math, agents and security, and the caution dial curve with its distilled model.
Overview. (a) The method. (b) Headline numbers across domains and three model families, on held-out tasks. (c) The decode-time caution dial (Section 05) and the same dial distilled into a single model.
Part II · Case study: agent security

04RL can make agents easier to hijack, and a security penalty fixes it

AgentDojo plants attacker instructions inside tool outputs (an email body, a web page) and checks whether the agent carries them out; its tools are in-memory simulations, so nothing real is executed. Our BFCL-trained Qwen2.5-7B agents turned out about 50% more hijackable than the instruct model they started from: 12.3% → 18.4% and 18.3% in two seeds, on the official benchmark. Chat safety barely moved, so a chat-safety eval would have missed it.

We add a security penalty to the reward: \(r = \mathbb{1}[\text{task done}] - \mathbb{1}[\text{injected goal executed}]\). In the notation of Section 01, the indicator is the energy (lower is better) and its negative is the reward contribution. The fair comparison is task-only RL on exactly the same injected episodes, which already helps a lot; the penalty goes further.

The headline, with its control. On held-out Qwen episodes using the trained attack template, task-only training already cut hijacking from 17.8% to 5.1–6.0%. Adding the security penalty brought it down to 1.8–2.9%, at a cost of 5–7 points of clean-task utility versus that control. Then turn the caution up or down at inference →

On held-out users and held-out injection goals:

Hijacked (%) on held-out AgentDojo episodes
attack template seen in trainingtemplates never used in training
Our evaluation harness, two seeds (bar = mean, labels = each seed). Against task-only RL on the same injected episodes: −3.1 to −4.1 points in both seeds on both templates, with BFCL success kept (49.9 / 50.0%). Not free: clean-task utility is 5.4 and 7.3 points below that control, and utility under attack 5.8 points below it in seed two (no significant loss vs the starting model). On the official benchmark the reduction is significant on the unseen template (7.4% vs 14.2%).

Does it transfer to a kind of scenario it never saw?

Every suite above (email and calendar, Slack, travel, banking) appears in training. So we also held out one whole suite at a time, its tools, data, user tasks and attacker goals, trained on the other three, and compared against task-only RL on exactly the same episodes.

Hijacked (%) on a suite never seen in training
starttask-only RLsecurity penalty (seen template)security penalty (unseen template)
Qwen2.5-7B, training seed one (shown). Each row runs from the start model (ring) through task-only RL (gray, dashed) to the security penalty (colored). On Slack the penalty learned elsewhere cuts hijacking a further 18 (seen) and 29 points (unseen template) beyond task-only RL; banking −8.7 / −6.4; travel −2.5 / −12.1; pooled −3.8 / −6.6, all significant, with no significant change in utility or BFCL overall. Transfer is partial (Slack: 14.8% vs 1.1% when Slack was in training) and on Slack this seed costs 7 points of utility under attack. Second training seed (Slack and banking only): the gain over task-only RL replicates on both suites and both templates (Slack −8.1 / −17.4, banking −9.2 / −5.7, all significant, no significant utility cost), but its size on Slack depends on the seed: seed one is the stronger of the two, while the task-only controls agree across seeds. Differences are paired means over episodes on unrounded values, so they can differ by 0.1 from differences of the rounded rates in the table.
Show the table
Held-out suiteSeen: start / control / securityUnseen: start / control / security
Slack61.0 / 28.1 / 9.885.0 / 61.4 / 32.9
Banking33.2 / 21.5 / 12.831.6 / 22.6 / 16.1
Travel25.0 / 2.7 / 0.247.3 / 26.8 / 14.6
Email, calendar, files2.9 / 0.6 / 0.48.4 / 2.9 / 1.8

Attack families never used in training

All attacks so far are AgentDojo's own templates. AgentDojo also ships attack families we never used anywhere in training: direct, injecagent, system_message, and a variant of the training template with the names removed. On the same 204 held-out episodes per attack (our harness, 4 samples each), pooled over the four:

Hijacked, pooled over 4 new attacksQwen2.5-7BGemma 4 26B
Instruct model8.2%4.8%
Task agent T (BFCL-only RL)13.7%–
Control: task-only RL on injected episodes (2 seeds)6.2 / 7.6%3.4 / 3.2%
+ security penalty (2 seeds)3.7 / 4.9%2.1 / 2.2%
Distilled dial (a = 1.5)1.8%–

BFCL-only RL (the task agent T vs the instruct model) raised hijacking on every one of the four new attacks (+3.8 to +8.3 points). The security penalty beats its matched control (task-only RL on the injected episodes) in both families (Qwen −2.5 and −2.7, Gemma −1.3 and −1.0, all significant). The gain is largest on the closest variant of the training template (−4.8 to −5.9 points on Qwen), smaller on injecagent and system_message, and not significant on direct, where hijacking is already low. Gemma sits at about 2% on the three different families for every model, so only the template variant moves. Qwen seed 2 again pays utility under attack (−5.7 points vs its control); seed 1 does not (−1.4, not significant).

What about defences that need no training?

AgentDojo ships three defences we could run: delimiting tool outputs and telling the model not to follow instructions inside them ("spotlighting"), repeating the user's request after every tool call, and a prompt-injection detector (a DeBERTa classifier) that replaces any tool output it flags with "data omitted". We ran them on the official benchmark (greedy decoding, held-out episodes), alone and on top of our models:

Hijacked, seen / unseen templateNo defenceSpotlightingRepeat user promptInjection detector
Qwen2.5-7B-Instruct9.3 / 12.79.8 / 14.710.3 / 10.82.9 / 8.8
Task agent T (BFCL-only RL)17.6 / 31.418.6 / 29.417.2 / 24.58.3 / 13.7
Control: task-only RL on injected episodes6.4 / 13.78.8 / 12.79.3 / 10.34.4 / 8.3
+ security penalty4.9 / 8.84.4 / 9.35.4 / 7.42.9 / 5.4
Utility under attack: instruct model / + security penalty33.8 / 34.830.4 / 32.836.3 / 43.616.2 / 19.6

Qwen2.5-7B, one seed of each trained model. The two prompting defences barely change hijacking for any model (the one significant effect: repeat-user-prompt lowers the task agent's unseen-template rate by 6.9 points). The detector is the one that clearly works: it lowers hijacking for every model, most for the task agent (−9.3 / −17.6 points), but it also blanks legitimate tool outputs, and utility under attack falls by 12.7 to 17.6 points for every model. The security penalty alone is hijacked less than the instruct model with either prompting defence (spotlighting −4.9 / −5.9, significant; repeat-user-prompt −5.4 seen, significant, −2.0 unseen, not), and about as often as the instruct model with the detector (+2.0 / 0.0, not significant) at 18.6 points more utility under attack. It is hijacked less than task-only training under every defence (significant on at least one template each). Stacking: a prompting defence on top of the penalty adds no security, though repeat-user-prompt raises utility under attack by 8.8 points; the detector on top gives the lowest hijacking in the table (−2.0 / −3.4 vs the penalty alone, significant) at 15.2 points of utility under attack. AgentDojo's tool-filter defence only supports OpenAI-API models, so we could not run it.

05The caution dial

The security-trained policy S and the task agent T it started from can be mixed at decode time, \(T^{1-a} S^{a}\), with no retraining. Drag the dial: hijacking falls smoothly while task success stays flat, and going past the trained policy (a > 1) buys more safety. (Qwen2.5-7B. The dial mixes two models, so every setting other than a = 0 or 1 costs two forward passes per token; the transfer buttons mix a third agent with \(S/T\) or \(S/C\), three per token.)

a = 0

a = 0 is the task agent; a = 1 is the security-trained policy.

Hijacked, seen attack16.9%
Hijacked, unseen attack25.0%
Task success (BFCL)47.5%
task successhijacked, seenunseen

Measured settings only, held-out AgentDojo and BFCL episodes. The dial runs its own token-by-token decoder (temperature 0.7, full softmax), so its end points are fresh samples: a = 0 reads 16.9 / 25.0% hijacked and 47.5% BFCL where our standard vLLM evaluation of T reads 17.8 / 27.0% and 48.9%, and a = 1 reads 1.5% seen where S reads 1.8%. These are two sampled evaluations of the same models. a = 0.5 vs a = 0: hijacking −10.5 (seen) and −10.3 (unseen), significant. The dial shown uses security seed one; it replicates with seed two (at a = 1.5: 1.2% seen and 3.2% unseen hijacking, no significant difference from seed one). The two transfer buttons add a learned direction, \((S/T)^{a}\) or \((S/C)^{a}\), to a different agent that never saw AgentDojo. S/T (security policy over the task agent it started from) carries everything learned from training on the injected episodes, and cuts that agent's hijacking by 13.2 and 16.7 points. But task-only training on the same episodes (the control C) already learns most of that. S/C, the part due to the security penalty alone, transfers more weakly: hijacking −6.1 points on the unseen template (significant) and −3.2 on the seen one (not significant), with utility under attack +6.1.

Where the dial stops working. On Gemma 4 26B (Section 06), turning the dial from a = 1 to a = 2 gives no significant additional security gain and costs 2.5 points of utility under attack: most remaining hijacks there are ambiguous episodes that every model fails. Extrapolation helped on Qwen because its security policy still had room to improve.

Then distil the dial back into one model

Mixing two policies costs two forward passes per token. So we sampled the dial at a = 1.5 on the training episodes and fine-tuned the task agent on those samples. No checker filters them, so no labels are used:

STEP 1 · RLTrain S with a security penalty
hijacked1.8 / 5.9%
BFCL success49.9%
passes / token1
STEP 2 · DECODEExtrapolate: \(T^{-1/2} S^{3/2}\)
hijacked0.5 / 2.2%
BFCL success50.5%
passes / token2
STEP 3 · DISTILFine-tune T on its samples
hijacked s10.9 / 2.2%
hijacked s21.3 / 2.5%
BFCL s1 / s252.0 / 53.0%
passes / token1

Hijacked: the training-time attack template / the one held-out template used for the dial (tool_knowledge). s1, s2: students distilled from the dials of security seeds one and two; steps 1 and 2 show seed one. Each student is statistically indistinguishable from the dial it learned from and is hijacked less than its own RL-trained security policy on the held-out template (−3.7 for seed one; −5.9 for seed two, which is also lower on the training template, −1.6). Weighting the samples by their exact importance weights gave the same result. (The task agent T alone, standard vLLM evaluation: 17.8 / 27.0% hijacked, BFCL 48.9%; the dial at a = 0 reads 16.9 / 25.0%.)

06A second family: a 26B mixture-of-experts

We repeated the security experiment on Gemma 4 26B-A4B (instruction-tuned, about 4B active parameters) with full-parameter RL. Its results are in the Gemma tab of the chart in Section 04: hijacking 5.4 / 4.8% after task-only RL, 2.5 / 2.1% with the security penalty (−2.9 and −2.7, significant), with no significant loss in clean utility or BFCL.

Strong models leave RL almost nothing to learn on standard benchmarks. Gemma solves BFCL 69% of the time and AgentDojo tasks 86%, and only 5–18% of training episodes give the mixed outcomes GRPO learns from. So we built harder training episodes inside AgentDojo, graded by its own checks:

Compose user taskstwo tasks of a suite in one episode (513 of 1,252 pairs pass replay)
20 new attack templatesplus 3 held out for evaluation only
Keep mixed outcomesepisodes where the base model sometimes fails
915
training episodes, vs about 57 in the original split

The caution dial works on Gemma too (hijacking 5.4 → 3.7 → 2.5 → 2.0% for a = 0, 0.5, 1, 2), though going from a = 1 to 2 adds no significant safety and costs 2.5 points of utility under attack. Adding the penalty-only direction S/C (relative to the matched task-only control) to the untrained base halves its hijacking (7.6 → 3.4%), at a cost of 4 points of clean utility. Effects are smaller than on Qwen because Gemma starts low and about 2.5% of episodes are ambiguous by construction (for example, a user task that says "follow the instructions in the file precisely").

Part III · Code, math and tool use

07Does training reach the target?

Section 01 defined the target; here we check whether trained policies actually land on it. Standard GRPO has the same kind of ideal optimum, but with a tiny KL coefficient, so its target puts nearly all mass on the highest-reward outputs. As usually configured it also divides advantages by the group's standard deviation, which rescales the reward prompt by prompt; our code baseline did not (every code arm here uses group-centred advantages without that division), so the difference between our two code arms is the KL coefficient (0.001 as a loss, against 1 in the reward) and how far training got. In our code runs the standard-GRPO policy at KL weight 0.001 ends up well off the predicted family, which is where the side effects showed up. With the KL term still in the loss, raising its coefficient from 0.001 to 0.05 reduced the four-metric distance from 3.1 to 0.6, like the tilt-GRPO runs, at a cost of 2.5 pass@1 points. So in this Qwen code run a larger coefficient was enough; the sweep does not test whether placement matters at a matched coefficient.

With a KL coefficient of one and no division by the group's standard deviation (we put the KL term in the reward and call this regime tilt-GRPO), the predicted family can be computed before any training, by reweighting base-model samples by \(e^{\lambda r}\). Each trained checkpoint can then be placed on, or off, that family. The distance to the family is the root mean square, over four observables (pass rate, share of lint-clean solutions, length, and effective number of distinct correct solutions), of the gap between the policy and its best-fit family member, with each gap divided by that observable's measured single-run seed-to-seed spread (0.2 points, 3.9 points, 4.6 tokens and 0.29 solutions).

Trained policies vs the family predicted from base samples
predicted familytilt-GRPOstandard GRPO, KL 0.001standard GRPO, KL 0.01 / 0.05
Held-out code problems, Qwen2.5-Coder-1.5B. The predicted family keeps the number of distinct correct solutions; tilt-GRPO stays on it, while standard GRPO at KL weight 0.001 buys pass rate by collapsing onto fewer solutions, and at 0.05 stays on the family. Distance from the family over four observables, in units of each observable’s measured seed-to-seed spread: 0.4–0.5 for the two tilt runs (0.3–0.9 for every checkpoint of longer runs, 0.6–0.7 with lint terms); for standard GRPO 3.1 at KL weight 0.001, 2.0 at 0.01 and 0.6 at 0.05. The contrast is weaker in deepseek-coder.

Not a new formula. The tilted optimum of KL-regularized RL is classic: it is the derivation behind DPO, and PPO-based RLHF put the KL penalty in the reward before GRPO moved it to the loss. What we add is using this regime on purpose, with a reward built from several terms, then measuring that trained policies land on the target and compose.

Honest caveat. Tilt-GRPO moves along the family, but slower than the nominal λ (10–20% of it at our budgets). A pre-registered "pick λ from base samples, train once" test failed: it predicted an effective strength of 1.35–1.75 where training reached 0.95–1.25. What we did establish: the Qwen correctness runs landed on the predicted family on four measured statistics; where along it they land had to be fit.

08Composition repairs RL side effects

Training a code model only for correctness, with GRPO's usual tiny KL weight (0.001 here), makes its code messier. Adding a lint penalty to the reward removes the mess at a small pass@1 cost, and the composed reward beats the obvious alternative, averaging the weights of a correctness model and a lint model (Rewarded Soups).

A simpler fix to check first: a stronger KL weight. Much of this side effect comes from the tiny KL weight. With the same correctness-only reward and a KL weight of 0.05, standard GRPO keeps the code at least as clean as the base model and restores its diversity (table below), at 2.5 points of pass@1 after the same 39 steps. The lint penalty is still worth having when you want cleaner code than the base model: 89% lint-clean at 63.3 pass@1, against 73.5% at 61.6 for the stronger KL weight.

Correctness-only GRPO, held-out KodCodepass@1pass@8lint-cleandistinct correct solutions
Base model56.473.970.06.26
KL weight 0.001 (two seeds)64.1 / 63.976.7 / 76.758.9 / 68.44.80 / 4.86
KL weight 0.0163.676.872.05.29
KL weight 0.0561.676.273.56.48
KL weight 0.001 + lint penalty (two seeds)63.3 / 63.276.7 / 76.689.3 / 89.5–

Qwen2.5-Coder-1.5B, 39 steps, standard GRPO with the KL term as a loss and no std division; one seed for the stronger KL weights. Against KL 0.001 (seed 1): KL 0.05 has −2.5 pass@1 (significant), −0.5 pass@8 (not significant), +14.6 lint-clean (significant). Distinct solutions: anonymised syntax trees, mean over problems (the base model's count comes from a second evaluation of the same model).

Pass rate vs clean code: composed reward vs weight soups
weight soupscorrectness only+ lint penaltylabel-free consensus
Held-out KodCode problems, two seeds. At about equal cleanliness, the composed reward has +3.4 points of pass rate over the soup; at about equal pass rate, +8.5 points of clean code.

What it actually changes

We looked at the code. Most of the lint gain is formatting debt that correctness RL itself introduced (whitespace on blank lines); substantive findings barely move. We report it that way.

Correctness-only GRPO 2 × whitespace on blank line

def reverse_string_by_words(s: str) -> str:
    if not s:
        return ""
····
    words = s.split()
    words.reverse()
····
    return ' '.join(words)

+ lint penalty 0 findings

def reverse_string_by_words(s: str) -> str:
    if not s:
        return s
    words = s.split()
    reversed_words = words[::-1]
    return ' '.join(reversed_words)

A held-out problem; both versions pass the unit tests. Red dots mark invisible indentation. Correctness-only: 16 of 16 correct samples have a finding; with the lint penalty, 0 of 16.

Diversity, too

Base model
6.26
distinct correct solution structures
Correctness RL
4.80
collapses onto fewer solutions
+ diversity bonus
7.0–7.7
above the base model; pass@8 +1.2 / +1.7 vs the same seed

Distinct correct solutions per problem after anonymising identifiers. A gated diversity bonus with a length term, two seeds, at a cost of 2.0 and 2.3 points of pass@1. A stronger KL weight (0.05) also undoes the collapse, to 6.48, at a similar pass@1 cost; the diversity bonus goes further (7.0–7.7) and is the arm that raises pass@8 (77.9 / 78.5, against 76.2 for KL 0.05).

09Train once, mix at decode time

If each RL-trained policy is (approximately) the base model tilted by its own reward, then a product of policies is the base model tilted by the sum of rewards. So instead of training a joint model, train each objective once and combine at inference:

$$q(y \mid x) \;\propto\; p(y \mid x) \prod_i \left(\frac{\pi_i(y \mid x)}{p(y \mid x)}\right)^{c_i}$$mixed token by token; a sequence-level importance weight corrects what the token-level product gets wrong
A continuous dial over the lint policy's weight
weight soupsdecode-time dial (weight −0.5 … 2)jointly trained
Correctness and lint policies, each trained separately with standard GRPO and mixed token by token at inference, 1,000 held-out problems. Weight 0 is the correctness policy; a negative weight negates lint (clean −30.7 points); weight 1 lands 1.5 points of pass rate below joint training with +1.2 clean, and for weights between 0 and 1 the dial lies above the soup curve (the negative weight is not comparable with soups, and at weight 2 a soup is better). Same in deepseek-coder (−1.4 pass, −1.3 clean vs joint).

Why is the token-by-token mix not exact? A prefix's soft value for an objective is the expected exponentiated reward of the completions that start with it, under the base model: how promising that prefix is for the objective. Multiplying two policies' next-token probabilities gets the sequence-level target exactly right when their soft values do not move together across the candidate next tokens; otherwise our theory gives the error exactly, through that conditional covariance, and a sequence-level importance weight corrects it. At equal weights, every comparison we ran lands within 3 points of joint training:

Equal-weight mix vs jointly trained policy (code)Pass rateClean code
Qwen, standard-GRPO experts, token-level mix (the chart above)−1.5+1.2
Same, resampled with the exact sequence weights−1.7+1.6
deepseek-coder, standard-GRPO experts, token-level mix−1.4−1.3
Qwen, experts trained with KL coefficient one, token-level mix−1.1−2.9
Label-free: consensus and lint policies, token-level mix−0.7+0.2

Points versus the jointly trained policy of the same training regime, 1,000 held-out problems. Resampling changes the equal-weight results by under a point in every row. Away from equal weights the picture changes: at weight 2 the dial loses 7.0 points of pass rate against joint training, and at the negative weight, resampling pushes clean code from 28% down to 10%.

10A normalization pitfall

GRPO usually divides advantages by the group's standard deviation. With composed rewards that is not harmless: when the primary reward term is constant within a group (all correct, or all wrong), dividing by the spread of the remaining terms silently rescales them prompt by prompt. Per-reward z-scoring (as in GDPO) does the same with a different weighting. Raising a conciseness weight \(\gamma\) from 0.1 to 0.3 on math:

Std division
\(\gamma\) ignored
nearly the same model for \(\gamma\) = 0.05–0.2
GDPO
−11.6
GSM8K points: z-scores amplify length when the group agrees
Unnormalized (ours)
−2.9
the weight keeps its meaning

On code, where lint varies inside every group, GDPO and our reward perform the same, as the analysis predicts.

11Tool-use agents

On multi-turn tool use (BFCL, held-out tasks, Qwen2.5-7B-Instruct) we wrote a token-exact rollout harness and a safe executor that never evaluates model text. Success-only RL nearly doubles task success but adds tool calls. A gated tool-cost penalty keeps the full gain and removes them.

Same success, fewer tool callstwo seeds; bar = mean, labels = each seed

Both arms at iteration 60, two seeds. Composed vs success-only: success not significantly different; calls −1.4 and −3.1, failed calls −0.26 and −0.19 (significant).

Part IV · Limits and wrap-up

12What did not work

samplingMCMC samplersSuffix Metropolis–Hastings, twisted SMC and gradient-steered proposals all lost to plain importance resampling, which used a fraction of their tokens.
theoryPredicting where RL lands from λOur pre-registered λ = 8 prediction expected an effective strength of 1.35–1.75; training reached 0.95–1.25. On the family, but slower.
agentsLabel-free consensus for agentsAt 7B, picking from the largest final-state cluster adds only 2.4 points (a richer signature that also matches tool outputs adds 5.9): read-only work leaves the state unchanged, so many failures share one state.
codeLint is mostly formattingSubstantive findings move from 10.6% to 9.5%; a substantive-only lint penalty barely helped.
compositionComposing constraint policiesOne policy per instruction-following constraint, composed for unseen combinations: joint RL already generalized (98.8%), and composed modules trailed joint training with the same reward form by 3.1 points (while beating weight averaging by 9.1). Side result: tilt-GRPO policies (KL coefficient one) composed cleanly; plain-GRPO ones produced degenerate text 20% of the time.
codeSide effects depend on the model and the KL weightIn deepseek-coder, correctness RL made code cleaner, not messier; composition still added its objective at no cost, but there was little to repair. In Qwen, a KL weight of 0.05 instead of 0.001 removed most of the side effect on its own.

14Takeaways

Write the objective once. A weighted sum of reward terms is easier to edit, audit and reuse than a hand-mixed reward.
Keep the KL coefficient meaningful. With a coefficient of one and no std division, the family of RL targets can be previewed from base samples, and the Qwen correctness runs landed on it on four measured statistics (the strength along it had to be fit). In our code runs, raising a tiny KL weight was enough to remove most of the side effects.
Compose instead of retraining. Separately trained policies, mixed at decode time with equal weights, come within 3 points of joint training on code, and give a dial without retraining, at extra inference cost until distilled.
Check what RL broke. Task-only RL on BFCL made agents easier to hijack; one extra penalty brought hijacking below task-only training in two model families and, on Qwen, carried over to an application suite held out from training.

15What I'm thinking about next

Can one model learn the whole caution dial? Right now I distil one setting at a time: set the teacher's dial to 1.5, collect its trajectories, and fine-tune a student that runs at normal cost. The next step is a single student that takes the dial value as an input. The test I have in mind: train it on a few settings, leave one out, and ask for that missing setting on a tool suite it has never seen. If it lands where the teacher would, the dial no longer needs two models at inference. Hijacking and task success have to be checked together here, because a student that simply refuses more often can look safer while losing the behaviour we wanted to keep.

Does the dial survive the agent learning a new tool suite? Adding a skill is exactly the kind of update that broke security the first time. The plan is to train a policy on the new suite alone, compose it with the current agent, and compare that with plain sequential RL and with training on a mix of old and new tasks, then turn the caution dial again. Two things to watch: whether the agent starts using familiar tools differently when the suites share them, and whether it is better to keep the security penalty on during the update or to add the security direction back afterwards. As everywhere in this post, the comparison is an agent trained on the same episodes without the penalty.

Can reward weights be chosen before paying for a run? On code, reweighting base samples previewed the trade-off well, but my guess of how far training would actually move was too optimistic. So the first question is a smaller one: does the preview at least rank which settings are worth training? On long agent trajectories there is a second question, how many samples really carry the estimate, since a handful can end up dominating it.

If you're working on any of these questions, or want to try the dial on your own agents, I'd love to hear from you.

Citation

To cite this post:

@misc{runwal2026onetarget,
  title  = {One target, many objectives: composing rewards in language model post-training},
  author = {Bharat Runwal},
  year   = {2026},
  note   = {Blog post},
  url    = {https://bharat-runwal.github.io/composing-rewards/}
}