Experiments实验›How to design reward function in Multi-Agent RL多智能体 RL 中如何设计奖励函数
Oct 4, 2026

How to design reward function in Multi-Agent RL多智能体 RL 中如何设计奖励函数

By Wenhao Chai作者 Wenhao Chai

Setup设置

The baseline is single-agent EasyPPO with its Frontier-CS settings: its Qwen3.5-9B SFT initialization, trained on 200 FrontierSmith problems and validated on 170 of the 172 Frontier-CS algorithmic problems (two prompts exceed the length limit), scored 0–100 as the mean per-test-case score by a local judge that follows the official rules; the last C++ block of an answer is the program judged, and every prompt says so. Ten of the 200 FrontierSmith problems had checkers that did not measure the algorithm: one gave full marks for any valid output, seven gave full marks at the statement's baseline, and two scored every correct program 0. FrontierSmith fixed them on October 17; the runs that ended before then trained on the original problems, and the agentic run trains on the fixed ones. A reply cut off at its token limit, or one that never closes its reasoning, scores 0 without being judged; here we differ from FrontierSmith, whose reward judges the code it finds in such a reply. This rule came in on October 7. Runs that were training then switched to it at their next 24-hour segment, except three that never trained under it: the feedback team with the difference reward and the two single agents with feedback. The first team study (a lead with three teammates) kept FrontierSmith's rule in all its arms; the experiment record says which. We replace the single agent with a team, one lead and four subagents as in DeepSeek-V4.1-Flash's Agent Team mode: the subagents are helpers that may test programs against the judge and report ideas, analysis or code, and only the lead's final submission scores the team. We compare ways to split the team's reward; compute is counted in generated tokens and latency in tokens on the critical path. The first four questions below were asked on competition math with FlashREINFORCE: the first two set up the trainer, and the next two asked the same thing there. Code: the team game, judge and scripts, the miles fork and the math runs; the experiment record links the exact commit of each finished run.

基线是单智能体 EasyPPO,用它的 Frontier-CS 设置:它的 Qwen3.5-9B SFT 初始化,在 200 道 FrontierSmith 题上训练,在 172 道 Frontier-CS 算法题中的 170 道上验证(另 2 道的 prompt 超过长度上限),由按官方规则实现的本地评测器打 0–100 分,即各测试用例得分的平均;评测的是回答里最后一个 C++ 代码块,每个 prompt 都写明了这一点。200 道 FrontierSmith 题里有 10 道的评测器不衡量算法:1 道对任何合法输出都给满分,7 道达到题面的基线就给满分,2 道给每个正确程序都打 0 分。FrontierSmith 在 10 月 17 日修好了这些题;在此之前结束的 run 用的是原题,agentic run 用修好的题训练。被 token 上限截断的回答,或推理没有结束的回答,直接记 0 分,不送评测器;这一点与 FrontierSmith 不同,它的奖励会评测这种回答里找到的代码。这条规则从 10 月 7 日起生效:当时正在训练的 run 从下一个 24 小时段起改用它,只有 3 个 run 从未在这条规则下训练,即差分奖励的带反馈团队和两个带反馈的单智能体;第一个团队实验(1 个 lead 加 3 个 teammate)的各组都保留了 FrontierSmith 的规则;实验记录写明了每个 run 用的规则。我们把单智能体换成团队,按 DeepSeek-V4.1-Flash 的 Agent Team 模式设为 1 个 lead 加 4 个 subagent:subagent 是帮手,可以把程序交给评测器自测,再汇报思路、分析或代码;只有 lead 的最终提交决定团队成绩。我们比较团队奖励的不同分法;算力按生成的 token 数计,延迟按关键路径上的 token 数计。下面前 4 个问题是在竞赛数学上用 FlashREINFORCE 做的:前 2 个搭好训练器,后 2 个问的是同一件事。代码:团队游戏、评测器和脚本、miles 分支和数学实验;实验记录里链接了每个跑完的 run 的准确提交。

--- baseline: one agent, one judged program (simplified)+++ ours: a team game with judge feedback (simplified) def episode(problem):-    return judge(problem, agent.solve(problem)).score+    # the lead writes one task per subagent# lead 给每个 subagent 写一条任务+    tasks = lead.plan(problem, n=4)+    # each subagent may test up to 3 programs, sees each result, then reports# 每个 subagent 最多自测 3 个程序,看到每次结果后写报告+    reports = [sub.explore(problem, t, judge, tests=3) for t in tasks]+    # the lead reads every report and submits the team's program# lead 读完所有报告,提交团队的程序+    final = judge(problem, lead.solve(problem, reports))+    # only the final submission scores the team; the split is what we compare# 只有最终提交决定团队成绩;比较的是奖励怎么分+    return split(final, reports)
How one rollout becomes gradients for the critic and the actor一个 rollout 如何变成 critic 和 actor 的梯度

Experiments实验

Answered已有结论Does FlashREINFORCE's quick-start recipe reproduce the paper on R1-Distill-1.5B?FlashREINFORCE 的快速入门配方能否在 R1-Distill-1.5B 上复现论文?

Yes: our run stays within about 2 points of the paper's arms at every reported step, and it ends about 2 points below the trust-region arm; each arm has one seed.

能复现:在论文给出的每个步数上,我们的 run 与论文两组相差都在约 2 分以内,结束时比信任域组低约 2 分;每组只有一个 seed。

FlashREINFORCEFlashREINFORCE Main主做法

One agent, asynchronous REINFORCE with a sequence trust region: the quick-start recipe with the paper's settings on our GPU layout.单个智能体,带序列信任域的异步 REINFORCE:快速入门配方,用论文的设置,GPU 布局按我们的节点。

The paper's curves论文的曲线 Baseline基线

The two arms the paper reports: with the trust region, and importance sampling only.论文报告的两组:带信任域的,以及只做重要性采样的。

Answered已有结论Does score centering remove the train/inference mismatch, and does it buy held-out accuracy?Score centering 能否消除训练/推理不一致?它能提高保留集准确率吗?

It removes the mismatch, and held-out accuracy stays the same, so the mismatch does not limit held-out accuracy.

能消除不一致,保留集准确率保持不变,所以不一致并不限制保留集准确率。

Score centeringScore centering Main主做法

Subtracts the expected score under the sampler's top-32 head, so the importance weight can be one; the trust region stays. Measured against the FlashREINFORCE recipe above.减去采样器 top-32 头下的期望得分,因此重要性权重可以取 1;信任域保留。对照是上面的 FlashREINFORCE 配方。

Weight one, no centering权重为 1,不做 centering Control对照

The same code, seed and weight with centering off.代码、种子和权重都相同,只关掉 centering。

Answered已有结论Does talking help a team of agents on math, and which credit makes it help?在数学题上,智能体之间交流有没有帮助?哪种功劳分配让它有帮助?

Untrained talking hurts, because agents copy each other. Paying each turn for its own gain gave the highest held-out accuracy, in a contrast that had no registered bar and two seeds.

未经训练的交流有害,因为智能体会互相照抄。按每一轮自己的增益给奖励时保留集准确率最高;这个对比没有事先登记门槛,只有两个 seed。

Talking peers交流的同伴 Main主做法

Four copies of one policy answer, read each other's notes, and answer again.同一策略的 4 个副本先作答,读彼此的笔记,再作答一次。

Silent peers不交流的同伴 Baseline基线

The same four answers at the same tokens, without the notes.同样 4 次作答、同样的 token,但不给笔记。

A reader汇总者

A fifth agent reads four solvers' answers and gives the team's answer.第 5 个智能体读 4 个解答者的答案,给出团队答案。

Answered已有结论Does DeepSeek-style lead-and-teammates training beat one agent with the same turn and token limits?DeepSeek 式的 lead 加队友训练,能否胜过同预算的单智能体?

No: the collaboration bonus makes the lead delegate more often, but the team does not beat the same lead working alone.

不能:协作奖励让 lead 更常委派,但团队没有胜过同一个 lead 单干。

Lead and teammateslead 加队友 Main主做法

A Qwen3.8-27B lead delegates to up to three teammates and answers; task reward plus a collaboration bonus minus latency, as in DeepSeek-V4.1-Flash.Qwen3.8-27B 的 lead 把子任务委派给最多 3 个队友,再给出答案;奖励是任务分加协作奖励减延迟,照 DeepSeek-V4.1-Flash。

The same lead alone同一个 lead 单干 Baseline基线

One agent with the same model, turns and token limits.同一个模型、同样轮数和 token 上限的单个智能体。

Answered已有结论Can a local judge stand in for the official Frontier-CS judge?本地评测器能否代替官方的 Frontier-CS 评测器?

Yes: it scores like the official judge on classic and interactive problems, and contestant code cannot read the test answers. Inside training, every judge after the first scored interactive answers 0, so the validation scores of those runs count interactive answers as 0.

能:它在普通题和交互题上的打分都与官方评测器一致,而且选手代码读不到测试答案。在训练中,第一版之后的各版评测器给交互题的回答全部打 0 分,所以这些 run 的验证集得分把交互题回答按 0 分计入。

Our judge本地评测器 Main主做法

The official rules re-implemented, with contestant code sandboxed and every case's output deleted as soon as it is scored.按官方规则重新实现,选手代码在沙箱里运行,每个测试点判完立即删除输出。

The official judge官方评测器 Baseline基线

Frontier-CS's own engine, run on the same node.Frontier-CS 自己的评测引擎,在同一节点上运行。

Answered已有结论Which starting point can RL train from on Frontier-CS?在 Frontier-CS 上,RL 能从哪个起点开始训练?

EasyPPO's SFT initialization: it finishes most of its answers, while the base model with reasoning mostly runs out of tokens.

EasyPPO 的 SFT 初始化:它大部分回答都能写完,而原版模型开启思考时大多用完了 token。

Base model, reasoning原版模型,开启思考

Qwen3.5-9B with its reasoning on.开启思考的 Qwen3.5-9B。

Base model, no reasoning原版模型,不思考

The same weights answering directly.同一份权重,直接作答。

EasyPPO's SFT initializationEasyPPO 的 SFT 初始化 Main主做法

Qwen3.5-9B fine-tuned on DeepSeek-V3.1 solutions by the EasyPPO authors.EasyPPO 作者用 DeepSeek-V3.1 的解答微调过的 Qwen3.5-9B。

Testing检验中Does our EasyPPO port train a single agent on Frontier-CS?我们移植的 EasyPPO 能否在 Frontier-CS 上训练单智能体?

Single agent, EasyPPO单智能体 EasyPPO Main主做法

One agent writes one program per problem; its judged score is the reward; a critic, trained alone for the first 30 rollouts.一个智能体每题写一个程序,评测分数即奖励;带 critic,前 30 个 rollout 只训练 critic。

Testing检验中Does a team without feedback beat one agent?没有反馈的团队能否胜过单智能体?

Team without feedback无反馈的团队 Main主做法

Three teammates write programs; the lead reads them without any scores and writes the final one.3 个队友各写程序;lead 看不到任何分数,读完后写最终程序。

One agent, same harness同一框架下的单智能体 Baseline基线

A single agent given the team's token budget.给单个智能体和团队同样的 token 预算。

Testing检验中With judge feedback, which reward split makes a team beat one agent at equal tokens?有评测反馈时,哪种奖励分法能让团队在相同 token 下胜过单智能体?

Team with feedback带反馈的团队 Main主做法

The lead writes four tasks; each subagent may test up to three programs, sees each result and reports; the lead's final submission is the team's. Measured against the EasyPPO single agent above.lead 写 4 条任务;每个 subagent 最多自测 3 个程序,看到每次结果后写报告;lead 的最终提交就是团队的提交。对照是上面的 EasyPPO 单智能体。

Revisions串行修改

One agent submits five times in one chat, seeing each result; only the fifth counts.一个智能体在同一对话里提交 5 次,每次都看到结果;只有第 5 次算数。

Best of five并行取最高

One agent submits five times independently; the best counts.一个智能体独立提交 5 次,取最高分。

Answered已有结论Why does each setup with feedback score as it does?带反馈的各做法,得分为什么高、为什么低?

Each setup is held back by its submission: except under the difference reward, every setup judged a better program before it submitted. The bonus wins because it pays subagents to test, which also teaches the one shared model to write programs that compile; the difference reward loses because a report whose tests all fail makes the lead's final worse, so the reward teaches subagents to stop testing. One seed.

各做法都受限于最后的提交:除差分奖励外,每个做法在提交之前都已评测过更好的程序。加分奖励赢,是因为它奖励 subagent 自测,共用的一个模型也因此学会写能编译的程序;差分奖励输,是因为自测全部失败的报告会拖低 lead 的最终程序,这个奖励便教 subagent 不再自测。只有一个 seed。

Testing检验中Does one agent with a shell (mini-swe-agent) score higher than one answer?给单个智能体一个 shell(mini-swe-agent),得分能否超过一次作答?

mini-swe-agentmini-swe-agent Main主做法

One agent in a sandboxed shell, one bash command per step: it writes and compiles files, runs the samples and its own tests, and submits one file. Only the submission meets the hidden tests. An episode had at most 40 steps until rollout 20; from rollout 21 only the token budget and the context end it, because 41% of episodes stopped at the 40th step. An episode without a submission scores 0.一个智能体在沙箱 shell 里工作,每步一条 bash 命令:写文件、编译、运行样例和自己的测试,最后提交一个文件。只有提交的文件会被隐藏测试打分。rollout 20 之前每局最多 40 步;从 rollout 21 起只由 token 预算和上下文长度结束一局,因为有 41% 的局停在第 40 步。没有提交的局记 0 分。

One answer一次作答 Baseline基线

The same model writes one program in one reply, as in EasyPPO.同一个模型在一次回复里写一个程序,与 EasyPPO 相同。

Testing检验中Does a swarm of four mini-swe-agents that coordinate only through one shared repo beat one agent with four times the steps?4 个 mini-swe-agent 组成的 swarm 只通过一个共享 repo 协作,能否胜过用 4 倍步数的单个智能体?

A swarm of four agents4 个 agent 的 swarm Main主做法

A swarm of four mini-swe-agents coordinates only through one shared git repo; each works under its own git name, and the repo's solution.cpp is the team's submission.4 个 mini-swe-agent 组成的 swarm 只通过一个共享的 git repo 协作;每个用自己的 git 名字工作,repo 里的 solution.cpp 就是团队的提交。

One agent, four times the steps单个智能体,4 倍步数 Baseline基线

One mini-swe-agent with four times the steps and tokens.一个 mini-swe-agent,步数和 token 都是 4 倍。

Testing检验中Why do most programs fail to compile, and does a prompt, the base weights or a lower temperature fix it?为什么大部分程序编译不过?换 prompt、换权重或降低温度能否解决?

SFT, plain promptSFT,原 prompt Baseline基线

The SFT initialization with the problem prompt alone.SFT 初始化,只给题目 prompt。

Checklist as a system message检查清单放进 system 消息

Declare every name, match every type, close every brace.声明每个名字,类型一一对应,括号全部闭合。

Checklist after the problem检查清单放在题目后面

The same checklist appended to the problem.同一份清单附在题目之后。

Base weights with the checklist原版权重加检查清单

The base model, reasoning on, with the system message.原版模型开启思考,加上同一条 system 消息。

Temperature 0.6温度 0.6

The SFT initialization sampled cooler.SFT 初始化,以较低温度采样。

Answered已有结论Does the trainer score tokens the way the rollout engine sampled them?训练器给 token 的打分,与 rollout 引擎采样时的打分一致吗?

Up to bf16 rounding: the two differ by as much as either side differs from itself when only the order of a sum changes, and the gap stays flat over training, so we apply no importance correction.

只差 bf16 的舍入:两者之间的差距,和任一侧只改变求和顺序时与自己的差距一样大,而且训练全程不变,所以我们不做重要性校正。

Every scorer on the same tokens同样的 token,每种打分方式 Main主做法

One rollout's response tokens, scored by the SGLang engine that sampled them, by Megatron's recompute and its replays at two tensor-parallel sizes, and by SGLang prefill alone, again and in one batch; the sampled tokens' log probabilities are compared token by token.取一次 rollout 的回复 token,分别由采样它们的 SGLang 引擎、Megatron 的重算及其两种张量并行规模下的重放、以及 SGLang 的 prefill(单条、重复一次、整批)打分,逐个 token 比较被采样 token 的 log 概率。

Takeaways核心结论

Acknowledgements致谢

The author is pleased to acknowledge that the work reported on in this post was substantially performed using the Princeton Research Computing resources at Princeton University. Princeton Research Computing is a consortium of groups including the Princeton Institute for Computational Science and Engineering (PICSciE) and Research Computing at Princeton University.

本文报告的工作主要使用普林斯顿大学 Princeton Research Computing 的计算资源完成。Princeton Research Computing 是由普林斯顿计算科学与工程研究所(PICSciE)和普林斯顿大学 Research Computing 等团队组成的联合体。

Experiment record实验记录

Citation

@misc{chai2026marl,
  title        = {How to design reward function in Multi-Agent RL},
  author       = {Chai, Wenhao},
  year         = {2026},
  howpublished = {Blog post},
  url          = {https://wenhaochai.com/exps/multi-agent-reward.html}
}
Experiments实验 Back to top回到顶部