Skip to the entry
AgenticRLEnvironments.com

How to build environments for training and testing AI agents with RL: state and actions, app clones, task generators, graders, rewards and versioning.

Reward design for agentic RL: sparse, dense, outcome and process rewards

At a glance

Start an agent environment with a sparse outcome reward checked by code on the final state. Add partial credit, shaping or format rewards only when learning stalls, prefer potential-based shaping because it keeps the optimal policy the same, and treat each added term as a new exploit.

Compiled by
First recorded
Last revised
Reading time
5 min

Reward design is choosing the number an agent environment returns, and when. For agentic tasks the safest default is a sparse outcome reward: 1 when a program confirms the final state is right, 0 otherwise. Everything else, from partial credit to shaping, is a tool for making learning faster that also gives the agent more to exploit.

What reward types can an agent environment use?

An agent environment can combine five reward types: outcome, partial credit, shaping, process and format rewards.

Table: Reward types for agent environments

TypeGiven whenHelps withMain risk
Outcome (sparse)End of episode, success or notA clear, hard-to-game targetNo learning signal until the agent sometimes succeeds
Partial creditEnd of episode, fraction of goals metGraded signal on long tasksAgent settles for the easy part
ShapingDuring the episode, for progressFaster learning on long horizonsChanges what is optimal unless potential-based
ProcessPer step, from labels or a modelCredit for good intermediate stepsCostly labels; learned process models can be gamed
FormatWhen output follows the required formParseable actions early in trainingWell-formed but wrong answers

Why start with a sparse outcome reward?

Start with it because it measures exactly what you want and nothing the agent can satisfy cheaply. A reward of 1 only when the database shows the right end state cannot be earned by sounding confident.

Published reasoning-model training made the same choice for a stated reason. The DeepSeek-R1 report describes a rule-based system of "accuracy rewards and format rewards", and says the authors did not use a neural reward model because "neural reward models are susceptible to reward hacking during large-scale reinforcement learning" (DeepSeek-R1, arXiv 2501.12948, read 2026-11-26).

The cost of a sparse reward is exploration. If the agent never succeeds, every episode scores 0 and there is nothing to learn from. Fix that with easier tasks first (see generating tasks with a difficulty knob) before adding reward terms.

When should I give partial credit?

Give partial credit when a task has several independent goals and an agent that meets some of them is genuinely better than one that meets none.

Two published environments show the pattern:

  • WebShop's end-of-episode reward is the fraction of the instruction's attributes, options and price limit the bought product matches, multiplied by a product-type match score, so it lies between 0 and 1 (WebShop, arXiv 2207.01206, read 2026-11-26).
  • ScienceWorld gives each task "between 2 and 15 optional subgoals" to "reduce reward sparsity", and normalises scores between 0 and 1 (ScienceWorld, arXiv 2203.07540, read 2026-11-26).

Do not give partial credit for steps that are only useful as part of a whole. Credit for "opened the right file" teaches an agent to open files.

How do I shape rewards without changing the goal?

Shape rewards with a potential function: add F(s, s') = γ·Φ(s') − Φ(s), where Φ scores how close a state is to the goal and γ is the discount factor.

Andrew Y. Ng, Daishi Harada and Stuart Russell introduced this in "Policy Invariance Under Reward Transformations: Theory and Application to Reward Shaping" (ICML 1999, pages 278 to 287; ML Anthology entry, read 2026-11-26). A later paper restates the result: "Ng et al. proved that the optimal policy keeps unchanged after adding the potential-based shaping reward to an MDP environment", and the potential form is both a sufficient and a necessary condition for that guarantee in their setting (Lu, Schwartz and Givigi, JAIR 41, 2011, read 2026-11-26).

Why the form matters: a bonus that is not a difference of potentials can create loops the agent profits from. DeepMind's specification-gaming write-up gives the boat-race example, where an agent paid for hitting targets along the course learned to go "in circles and hitting the same green blocks over and over again" instead of finishing (Specification gaming, 2020, read 2026-11-26).

For a tool-use agent, a usable potential is the number of required end-state facts already true. Making one true raises the potential; undoing it lowers it by the same amount, so the agent cannot farm the bonus.

Should I reward the process or only the outcome?

Reward the outcome by default, and add process rewards only where you can label steps reliably.

"Let's Verify Step by Step" compared "outcome supervision, which provides feedback for a final result" with "process supervision, which provides feedback for each intermediate reasoning step". On math problems, its process-supervised model solved 78% of a representative subset of the MATH test set, beating outcome supervision; the released PRM800K dataset has 800,000 step-level human labels (Lightman et al., arXiv 2305.20050, read 2026-11-26).

For agents that call tools, "a correct step" is harder to define than in a proof, and a learned process model becomes something to exploit. Where steps can be checked by code, such as "the query the agent ran returns the right rows", a step reward is cheap and safe. Where they cannot, keep to outcomes.

How big should a format reward be?

Keep a format reward small next to the outcome reward, and remove it once the agent's outputs parse reliably.

A format reward pays for structure, such as a valid JSON tool call or reasoning inside the required tags; DeepSeek-R1-Zero's format reward asked the model to put its reasoning between <think> and </think> tags (DeepSeek-R1 report, read 2026-11-26). If the format reward is large, a well-formed wrong answer scores well. In a Gymnasium environment the simplest alternative is to return an error observation for a malformed action, as in our worked example, and pay only for outcomes.

What should I check before training on a new reward?

Check the reward against a fixed set of episodes whose correct ranking you know:

  1. A reference solution gets the highest reward.
  2. Doing nothing gets zero.
  3. A partial solution scores between the two, if you give partial credit.
  4. Repeating a rewarded action does not increase the total, unless repetition is the task.
  5. Known exploits, such as editing tests or claiming success, get zero.

If any check fails, fix the reward before spending compute. See reward hacking in agent environments for what to watch for during training.

What we read for this article

Field questions

What is a sparse reward?

A reward given only at the end of an episode, usually 1 for success and 0 otherwise. It is hard to exploit because it checks the outcome, but it gives the agent nothing to learn from until it succeeds at least sometimes.

What is potential-based reward shaping?

Adding a bonus of the form gamma times Phi of the next state minus Phi of the current state, where Phi is any function of state, such as progress towards the goal. Ng, Harada and Russell showed in 1999 that shaping of this form leaves the optimal policy unchanged.

What is the difference between outcome and process rewards?

An outcome reward scores the final result. A process reward scores each intermediate step. On math problems, a published comparison found process supervision trained a better reward model, but process labels cost far more to collect and are harder to define for tool use.

Should I reward the agent for using the right output format?

A small format reward can help early in training, and published reasoning-model training used one. Keep it small relative to the outcome reward and check the agent does not learn to produce well-formed but wrong answers.