Part II / Reinforcement Learning
Time, return, and credit
A reward is local feedback. Return is the future that follows from a decision. RL exists because those are rarely the same moment.
A trajectory records the ordered interaction.
Return accumulates future rewards from each step.
Assign delayed outcomes to earlier choices.
The restaurant bill arrives at the end
Imagine a meal with six courses and one final review. A five-star rating does not say which course earned it. A one-star rating does not identify whether the reservation, soup, main dish, or service failed. The sequence matters, the feedback is delayed, and many earlier actions contributed. This is temporal credit assignment.
Return rewinds the eventual bill onto each earlier moment. Credit assignment decides how much the policy should change because of that bill.
For a trajectory with rewards r_t, the return from time t is commonly written G_t. In an undiscounted finite episode, it is the sum of rewards from now until termination. With discount gamma, rewards farther in the future count geometrically less.
Four investigative choices, one outcome
The reasoning engine first checks only the recently changed gateway, then inspects both paths, then tests time alignment, then returns the correct cause. Intermediate rewards are [0, 0, 1, 5]: one point for the first discriminating evidence and five for the final supported diagnosis.
At gamma=0.9, the final five points still influence the first action, but less than the action immediately before the answer. A smaller gamma creates a shorter effective horizon. A gamma of one treats all later reward equally in a finite episode. In continuing tasks, discounting helps keep infinite sums finite; in stochastic tasks, it can encode uncertainty about distant consequences.
Do not choose gamma from habit. If a useful investigation typically takes fifteen steps, a gamma that effectively forgets after three steps fights the task. If rewards contain long-delayed noisy business outcomes, a very high gamma may create high-variance learning signals. Evaluate sensitivity using the task's real horizon.
Credit assignment has several tools
Monte Carlo return waits until the episode ends and uses the observed total. It is unbiased for the policy's sampled return but can vary enormously between trajectories. Temporal-difference learning bootstraps: it combines immediate reward with an estimate of what comes next. That lowers variance but introduces error from the estimate.
Eligibility traces and generalized advantage estimation blend information across several horizons.[source] Process rewards add feedback at intermediate steps. Reward shaping changes the reward landscape. Hierarchical actions group many low-level steps into meaningful skills. These methods attack the same structural problem from different angles: which earlier behavior deserves reinforcement?
For language models, a response contains many token actions but often one sequence-level reward. Implementations typically assign that reward across generated tokens through an advantage estimate. For agents, tool calls and observations extend the horizon further. If the model makes a decisive topology query at step three and answers at step twenty, the algorithm needs a signal that reaches the earlier token decisions responsible for that query.
The horizon is an engineering property
Tool latency, retry policy, context limits, maximum tokens, approval boundaries, orchestration, and model behavior jointly determine the mathematical episode length. Truncating every rollout at eight calls makes later rewards unobservable. Allowing unlimited calls may create unbounded cost and encourage wandering. A good environment exposes a realistic budget and records when the boundary, rather than the policy, caused termination.
That is one valid interpretation in some formulations, not its universal definition. Gamma is part of the objective. It controls how future rewards contribute to return and changes the policy you are asking the algorithm to prefer.
Counterfactual credit is the real question
A high-return trajectory does not prove every action was good. The policy might succeed despite an unnecessary query. Ideally we ask a counterfactual: compared with what the policy expected from this situation, did this action improve the outcome? That question leads to value functions and advantage in the next chapter.
In reasoning traces, avoid interpreting fluent chain-of-thought as causal evidence. A model can produce a convincing rationale after the decisive behavior occurred. Observable process signals should focus on checkable actions, evidence relationships, and state changes rather than assuming every narrated thought caused the answer.
References
- Sutton and Barto, chapters 3, 6, and 12, grounds return, discounting, TD learning, and eligibility traces.
- OpenAI Spinning Up's RL introduction provides a compact policy/value treatment for practitioners.
- Schulman et al. is the primary source for generalized advantage estimation.