arXiv:2610.03634cs.AIOct 2026

Manuscript Offprint

arXiv:2610.03634

Credit Where It Matters: Dependency-Aware Policy Optimization for Terminal Agents

Yu Li, Guangfeng Cai, Long-Fei Li, Shuo Han, Shengtian Yang, Han Luo, Kaibing Yang, Lei Feng

Abstract

Terminal-using agents benefit from reinforcement learning (RL) in coding, debugging, and other multi-step terminal tasks. In these tasks, later commands often depend on information or intermediate results produced by earlier commands. However, existing trajectory-level and step-level credit assignment methods do not explicitly trace the read-write dependencies through which commands affect the final outcome. Consequently, training signals could still be assigned to irrelevant operations, weakening learning from relevant steps. In this paper, we propose Dependency-Aware Group Policy Optimization (DepGPO), which uses execution dependencies between commands to guide credit assignment for terminal agents. Specifically, we construct a command dependency graph from execution traces and trace backward from the resources inspected by the task verifier. We then assign credit to relevant writes and their supporting reads along these paths, and use it to redistribute trajectory advantages across steps. Extensive comparative experiments and ablation studies demonstrate that DepGPO improves task performance and training stability on complex terminal tasks.

1. Introduction

Terminal-using agents (Anthropic, 2025, OpenAI, 2025, Google, 2025, Wang et al., 2025) have become a major application of language models for coding, debugging, and other multi-step terminal tasks (Yang et al., 2024, Merrill et al., 2026, Ivison et al., 2026, Gandhi et al., 2026). These tasks involve multi-turn interactions with a persistent environment, where later commands use information and intermediate results produced by earlier ones. Recent work improves these agents through reinforcement learning (RL), with outcome rewards determined by task verifiers that check whether the resulting environment satisfies task requirements (Shen et al., 2026, Ivison et al., 2026, Yao et al., 2026). A common approach uses group-based algorithms such as GRPO (Shao et al., 2024) and DAPO (Yu et al., 2025), which compare outcome rewards across sampled trajectories. In their outcome-based formulations, a trajectory-level advantage is shared across all generated steps. However, commands can play different roles: an inspection may guide a later repair, whereas a write may be overwritten before its output is used. This mismatch calls for step-level credit assignment that reflects how individual commands contribute to task completion.

To refine this within-trajectory credit assignment, recent work has developed several step-level methods. GiGPO compares actions taken from the same environment state (Feng et al., 2025), and HGPO further accounts for historical context when forming groups (He et al., 2026). GAGPO uses grouped state values to propagate outcome supervision through time (Zhu et al., 2026). Graph-based methods, including GEPO (Yuan et al., 2025), GraphGPO (Cheng et al., 2026), and G2PO (Wang et al., 2026b), construct state-transition graphs and derive credit from structural importance, goal progress, or state values. HCAPO provides another route by using a language model to reassess intermediate actions in hindsight (Tan et al., 2026). Although

Corresponding author(s): Lei Feng, fenglei@seu.edu.cn

(a) Vanishing advantages

Figure

(b) Singleton anchor states

Figure

(c) Read-write dependency path

Figure

(d) Credit concentration

Figure

Figure 1: Pilot analysis of credit assignment in terminal tasks. (a) With K = 4, an SFT policy yields zero group-relative advantages on 61% of tasks. (b) Sparse anchor-state recurrence in our terminal implementation of GiGPO. (c) Example command dependencies and raw credits; E denotes the resources read by the verifier. (d) Cumulative distributions of the fraction of commands connected to E in passing Terminal-Bench 2.0 reference trajectories (n = 51) and the subset with at least five commands (n = 18). Pink guides illustrate GRPO's uniform step weights.

these methods enable finer-grained credit assignment, they do not explicitly trace how information and intermediate results flow between commands. In fact, terminal execution traces can expose these read-write dependencies, linking individual commands to the resources checked by the verifier and providing direct evidence for credit assignment.

To examine the limitations of existing credit assignment and assess whether execution dependencies can support finer-grained attribution, we conduct a pilot study (Figure 1). With four rollouts per task from a model trained by supervised fine-tuning, 61% of 1,376 task groups yield identical binary rewards and zero group-relative advantages (Figure 1(a)). DAPO can filter these groups through dynamic sampling, but allocating the remaining nonzero advantages across commands remains unresolved. For GiGPO, exact matching in our terminal implementation yields only four recurring anchor states out of 25 in the two traced tasks with the most anchors, limiting step-level comparisons (Figure 1(b)). We further analyze Terminal-Bench 2.0 reference solutions and denote the set of files and other resources read by the task verifier by E. Execution traces reveal command dependency paths leading to this resource set (Figure 1(c)). Across 51 passing reference trajectories, the median fraction of commands on these paths is 0.57, falling to 0.18 for the 18 trajectories with at least five commands (Figure 1(d)). Together, these findings highlight the need to distinguish command contributions more carefully and show that execution dependencies provide observable evidence for allocating outcome-based learning signals to relevant steps.

Building on these pilot findings, we develop Dependency-Aware Group Policy Optimization (DepGPO), which redistributes trajectory advantages using command dependencies connected to task verification. Specifically, we construct a directed command graph from recorded resource reads and writes and subsequent uses of command outputs, then trace backward from the verifier's read set E. For file writes, credit is the fraction of written lines that reach E. A line reaches E if it remains in a file read by the verifier, or if a later command on a dependency path to E reads it before it is overwritten. Reads then accumulate credit from the relevant writes they support, with each contribution decaying with shortest-path distance in the dependency graph. We then aggregate command credits within each agent step and normalize them into nonnegative, unit-mean step factors. Multiplying these factors by the original trajectory advantage produces per-step advantages for the clipped policy objective. In this design, group-relative outcomes determine the sign of the learning signal, while execution dependencies determine its allocation across steps.

Our main contributions are as follows:

• We propose Dependency-Aware Group Policy Optimization (DepGPO), which uses execution dependencies between commands to redistribute group-relative advantages through distinct credit assignment rules for relevant writes and their supporting reads.

• We analyze training dynamics through controlled experiments and show that DepGPO delays training degradation and improves the stability of reinforcement learning for terminal agents.

• We conduct experiments with Qwen3.5-9B and Qwen3.6-27B using both SETA and TMAX training data, demonstrating consistent improvements in task performance and training stability.