Dissecting AI
From the paper: Terminal-RSI: Recursive Self-Improving Terminal Agents via Recursive Self-Rewrite and Policy-Refine

Turn-Boundary Skip-Observation GAE

Observation tokens can add artificial decay to action credit; TB-GAE places discounting and trace decay on turn boundaries while preserving exact continuation across fixed-input chunks.

Read the paper ↗
The short version

What it is

  • Turn-level credit Compute action credit over generated decisions and interaction turns, rather than letting observation length insert extra decay steps.
  • Exact chunk continuation When splitting the backward calculation, carry both the next value estimate and next advantage; a compute boundary is not task termination.

Why it matters

Long observations should not silently decide how quickly action credit fades. TB-GAE ties decay to interaction turns, while making clear that changing this clock changes the learning objective and that chunking is exact only when the needed continuation state and conditioning are preserved.

Before getting into the mechanics, here is the short version: an agent alternates between generating actions and receiving observations, but observations are not themselves policy decisions. TB-GAE computes token-specific credit while making the decay clock follow interaction turns, and it spells out what information a chunk boundary must keep to match a single reverse pass.

  1. The credit clock: Standard GAE can run over a sequence that includes observations. Those positions may add decay even though the policy did not choose an action there. TB-GAE instead links generated positions to their values, turn IDs, and causally assigned rewards; observations affect the context for values but are not recursion steps.

  2. Where feedback belongs: Rewards here are assigned at rollout completion, so the point is not to smear terminal feedback across chunks. Think of a receipt attached to the purchase that caused it: copying it onto every page of a notebook would count the same event repeatedly. The analogy stops at bookkeeping—the estimator also combines rewards with values and a trace.

  3. What a chunk must remember: A long reverse calculation can be split, but a split is only computational, not a task ending. To continue exactly with unchanged retained inputs, carry both the successor value and successor advantage. Carrying the value while zeroing the trace drops future credit; a task-defined terminal budget is different because it really ends the task.

The mechanism’s clock has discount and trace-decay factors associated with turn boundaries. In words, each boundary applies the chosen turn-level decay, while true termination removes the successor contribution. Across several boundaries, attenuation depends on their count rather than on observation length or the number of generated tokens within a turn. That is the useful intuition—but it is not a free rewrite of the objective. Changing the clock changes what future rewards are discounted by.

So the real question is not just how to avoid extra decay through observations: which clock reflects the objective you want? I find the exact chunking condition especially useful because it exposes a common implementation trap: resetting a trace at a convenient compute boundary quietly changes the estimator. Summarization is another boundary of a different kind; it changes conditioning, so moving state across it does not by itself preserve the fixed-input calculation.

Read the deep dive

Why People Wanted It

An agent may generate many tokens, receive an observation, then generate more tokens before the task ends. Standard GAE can treat observation positions as recursion steps even though the policy made no decision there. The problem is not just sequence length: observation tokens can make credit fade without a corresponding action. So the real question was whether the credit clock should follow text positions or interaction turns—and how to split the calculation without changing it.

The Core Move

TB-GAE places its discount and trace-decay clock on generated positions and turn boundaries, while observations condition values but are not recursion nodes. For generated position jj, use its value vjv_j, causally assigned reward r~j\tilde r_j, and termination marker djd_j; the paper specifies the clock and recursion but the supplied page text does not preserve their displayed formulas legibly, so no missing algebra is reconstructed here.

Quiz
In TB-GAE, what role do observation tokens play in the advantage recursion?
They automatically mark task termination.
They receive a copy of the next generated token’s reward.
Each observation always adds one discount-and-trace step.
They condition values but do not become recursion nodes.

Why Observation Tokens Should Not Advance the Credit Clock

Now the version for readers who want more of the machinery: the key distinction is between a position at which the policy chooses an action and an observation that merely changes what the next action can depend on. TB-GAE links generated positions uju_j to pre-token values vj=V(huj)v_j=V(h_{u_j}), turn IDs t(j)t(j), and causally assigned rewards r~j\tilde r_j. Observation nodes can affect those values, but do not enter the advantage recursion.

The turn clock uses 0≤γturn,λturn≤10\leq\gamma_{\mathrm{turn}},\lambda_{\mathrm{turn}}\leq1. The boundary factors are Γj\Gamma_j and Λj\Lambda_j, and the combined recursion weight is wj=ΓjΛj(1−dj)w_j=\Gamma_j\Lambda_j(1-d_j). In words: discount and trace decay are applied at the relevant turn boundary, while true termination shuts off the successor trace. At termination, successor value and trace are zero; the clock factors are set to one rather than querying a nonexistent next turn. This makes attenuation across BB turn boundaries (γturnλturn)B(\gamma_{\mathrm{turn}}\lambda_{\mathrm{turn}})^B for fixed retained inputs, independent of observation length or token count within a turn. It also changes the discounted objective. What does that mean when feedback arrives only at the end?

Why Sparse Feedback Still Belongs to Its Causal Position

Here is the part that gets technical: a terminal reward must remain attached to its causal generated position, not be copied to every chunk or observation. If a turn receives reward only at its final generated token, telescoping within that turn yields prefix-specific advantages: positions can share a return while having different values and therefore different advantages. The terminal successor terms vanish, and each reward occurs once.

With unit clocks, the advantages reduce to the sum of subsequent assigned rewards minus the current value on complete episodes, matching standard GAE only when inputs, values, reward placement, and endpoints agree. This is not a license to move reward around: causal placement and multiplicity are part of the estimator. How can a long reverse scan be partitioned without changing that result?

Why Exact Chunking Needs Both Successor Quantities

Now the exact continuation condition: at a computational boundary bb, retaining the value bootstrap but resetting the trace loses the contribution of the future trace. Exact continuation requires both vb+1v_{b+1} and Ab+1A_{b+1}, or an unsplit reverse scan. A task-defined terminal budget sets d=1d=1; a sampling cut or computational partition does not automatically end the task. If the future trace is unknown, a cutoff is approximate.

The condition is fixed retained inputs. A summary changes conditioning, so transporting state across it does not establish equivalence to the original fixed-input continuation. Where, then, is the practical tradeoff between cleaner turn-level decay and the objective you intend to optimize?

Minimal Causal Code

This transparent sketch shows the reverse recurrence over generated positions only. clock(j) supplies the boundary factors described above; it is not an implementation of observation-token steps.

# Inputs are ordered generated positions; observations are not entries here.
advantages = [0.0] * len(rewards)
next_advantage = 0.0
next_value = 0.0

for j in reversed(range(len(rewards))):
    if done[j]:
        next_value = 0.0
        next_advantage = 0.0
        gamma_factor, lambda_factor = 1.0, 1.0
    else:
        gamma_factor, lambda_factor = clock(j)

    delta = rewards[j] + gamma_factor * next_value - values[j]
    weight = gamma_factor * lambda_factor * (1.0 - float(done[j]))
    advantages[j] = delta + weight * next_advantage
    next_value = values[j]
    next_advantage = advantages[j]

For chunked execution, the reverse scan must receive both successor value and successor advantage at the boundary. Resetting only the latter changes the result.

What You Gain, and What You Lose

Turn-boundary decay avoids making observation length itself the source of extra trace attenuation, and exact chunk continuation can preserve the unsplit calculation when retained inputs stay fixed. The costs are explicit: changing the clock changes the discounted objective; a task boundary must be distinguished from a compute or sampling cut; and unknown future traces force an approximation. Nor does the construction imply a universal variance reduction or policy-invariance guarantee. The choice is therefore about which credit clock matches the interaction and objective—not simply about making GAE faster.

Quiz
What must be retained at a chunk boundary for exact TB-GAE continuation with fixed inputs?
A summary of the preceding observations is always sufficient.
Both the successor value and successor advantage.
Only the terminal reward.
Only the successor value.
Core Takeaway

Skip observation positions in the credit clock, but never skip the successor trace when you split the reverse scan.