DRSR: Learning Set-Level Deletion Risk for Efficient Long-Horizon Agents
Organizations: TierFlow Team · Gaoling School of Artificial Intelligence, Renmin University of China · Tsinghua University
Abstract
Long-horizon language-model agents accumulate reasoning traces, tool exchanges, and observations whose relevance changes with the current decision. Existing compression strategies often score historical units independently, but the safety of deleting several units is generally not determined by their singleton scores: redundant evidence, accumulated small effects, and the information that remains after deletion all matter. We introduce Direct Relational Set-Risk Pruning (DRSR), which formulates agent-history compression as risk-constrained selection over deletion sets. Offline, DRSR constructs exact counterfactual supervision by jointly deleting protocol-valid history Blocks and measuring the change in teacher-forced likelihood of the same recorded next output. A lightweight scorer then predicts set-level harm from online-visible relations between candidate history and the current pre-action state, together with deleted-retained and pairwise set structure. At deployment, DRSR evaluates a small set of structurally valid deletion candidates with the lightweight scorer and removes the largest feasible set under recency, protocol, budget, and learned-risk constraints, abstaining when no set is sufficiently safe. On WorkBuddyBench Full260, DRSR increases mean reward from 0.699 to 0.802 while reducing total model tokens by 20.820%. On the fixed Eval40 comparison, it obtains 0.794 reward at 1.211M tokens per task, using 35.850% fewer tokens than the uncompressed agent. Mechanistic analyses and ablations further show that decision-conditioned relations, retained-context information, pair interactions, and abstention each contribute to reliable pruning.
Figures & tables
| Rule | Pair Acc. |
| Sum | 58.94% |
| Mean | 56.81% (-3.61%) |
| Maximum | 46.17% (-21.67%) |
| Minimum | 14.89% (-74.74%) |
| Method | MAE |
| Singleton additive | 0.018 |
| + exact pair interaction | 0.008 |
| Method | Code | Office | Security | Web | Overall | |||||
| Baseline | 0.770 | 1.370 | 0.818 | 1.198 | 0.478 | 5.977 | 0.721 | 2.429 | 0.699 | 2.685 |
| Structural Pruning | 0.703 | 1.380 | 0.814 | 0.893 | 0.640 | 4.961 | 0.659 | 2.046 | 0.701 | 2.292 |
| DRSR | 0.858 | 1.235 | 0.824 | 0.997 | 0.756 | 4.569 | 0.760 | 1.858 | 0.802 | 2.126 |
| Method | Code | Office | Security | Web | Overall | |||||
| Baseline | 0.729 | 1.438 | 0.816 | 1.040 | 0.446 | 3.973 | 0.710 | 1.098 | 0.675 | 1.887 |
| Sliding Window ( ) | 0.668 | 3.123 | 0.674 | 3.982 | 0.323 | 2.126 | 0.590 | 2.577 | 0.564 | 2.952 |
| Sliding Window ( ) | 0.744 | 1.756 | 0.731 | 1.816 | 0.401 | 0.819 | 0.610 | 3.547 | 0.621 | 1.985 |
| Sliding Window ( ) | 0.793 | 1.419 | 0.851 | 2.231 | 0.403 | 1.132 | 0.700 | 3.300 | 0.687 | 2.020 |
| Periodic Summary ( ) | 0.654 | 1.913 | 0.677 | 2.135 | 0.263 | 0.990 | 0.827 | 3.819 | 0.605 | 2.214 |
| Variant | Code | Office | Security | Web | Overall | ||||||
| Direct | |||||||||||
| DRSR | 0.856 | 1.216 | 0.788 | 0.724 | 0.700 | 1.616 | 0.833 | 1.288 | 0.794 | 1.211 | 25.155 |
| w/o retained | 0.722 | 0.716 | 0.779 | 0.266 | 0.698 | 1.254 | 0.800 | 1.731 | 0.750 | 0.992 | 12.633 |
| w/o pair pooling | 0.756 | 0.567 | 0.678 | 0.606 | 0.796 | 1.094 | 0.796 | 2.535 | 0.757 | 1.201 | 32.205 |
| w/o abstention | 0.833 | 1.205 | 0.801 | 0.447 | 0.573 | 0.963 | 0.800 | 1.553 | 0.752 | 1.042 | 30.093 |
Appendix figures & tables20 assets
Supplementary material from the paper’s appendix.
Appendix
| External-trajectory supervision | |||||
| Source trajectories | Decision states | Set-level labels | Train / validation / test | ||
| 566 | 1,698 | 80:10:10 by trajectory | |||
| Task evaluation | |||||
| Set | Code | Office | Security | Web | Total |
| Full260 | 80 | 50 | 60 | 70 | 260 |
| Eval40 | 10 | 10 | 10 | 10 | 40 |
| Configuration item | Value |
| Representation and scorer | |
| Representation backbone | Frozen Qwen3.5-9B |
| Acting model | DeepSeek-V4-Flash |
| Candidate features / embedding | 1,154 / 64 dimensions |
| Set representation / shared hidden state | 451 / 64 dimensions |
| Attention layers | 4, 8, 12, 16, 20, 24, 28, 32 |
| Measurement / representation | Value |
| History granularity | |
| Median within-state Step-harm range | 0.312 |
| Median within-state Block-harm range | 0.028 |
| Unsafe parent Steps containing a safe Block | 71.400% |
| Controls: pair accuracy at harm margin 0.020 | |
| Current state only | 50.000% |
| Method | Total (M) | Per task (M) |
| DeepSeek-V4-Flash | 75.50 | 1.887 |
| Sliding Window ( ) | 118.08 | 2.952 |
| Sliding Window ( ) | 79.39 | 1.985 |
| Sliding Window ( ) | 80.82 | 2.020 |
| Periodic Summary ( ) | 88.57 | 2.214 |
| Periodic Summary ( ) | 94.85 | 2.371 |
| Domain | Reward | (M) | Direct (K) |
| DRSR | |||
| Code | 0.856 | 1.216 | 46.6 |
| Office | 0.788 | 0.724 | 6.8 |
| Security | 0.700 | 1.616 | 37.6 |
| Web | 0.833 | 1.288 | 9.7 |
| w/o retained | |||
| Variant | Input (M) | Output (K) | Cache read (M) | Cache create (M) | Total (M) |
| DRSR | 1.188 | 22.7 | 1.067 | 0.121 | 1.211 |
| w/o retained | 0.970 | 21.3 | 0.873 | 0.097 | 0.992 |
| w/o pair pooling | 1.178 | 22.2 | 1.052 | 0.126 | 1.201 |
| w/o abstention | 1.018 | 23.7 | 0.872 | 0.147 | 1.042 |
| Domain | Input (M) | Output (K) | Cache read (M) | Cache create (M) |
| DRSR | ||||
| Code | 1.205 | 11.2 | 1.052 | 0.153 |
| Office | 0.702 | 22.0 | 0.642 | 0.060 |
| Security | 1.589 | 26.4 | 1.429 | 0.161 |
| Web | 1.256 | 31.0 | 1.146 | 0.110 |
| w/o retained | ||||
| Domain | Base | DRSR | Base (M) | DRSR (M) | Direct (K) | ||
| Code | 80 | 0.770 | 0.858 | 1.370 | 1.235 | 46.9 | |
| Office | 50 | 0.818 | 0.824 | 1.198 | 0.997 | 6.8 | |
| Security | 60 | 0.478 | 0.756 | 5.977 | 4.569 | 31.0 | |
| Web | 70 | 0.721 | 0.760 | 2.429 | 1.858 | 38.2 | |
| Overall | 260 | 0.699 | 0.802 | 2.685 | 2.126 | 33.2 |
| Quantity | Offline training | Online selection | Post-hoc audit |
| Current query and observed history | Yes | Yes | Yes |
| Pre-action hidden states / attention | Yes | Yes | Yes |
| Candidate mask and token saving | Yes | Yes | Yes |
| Realized next output | Label only | No | Yes |
| Exact joint deletion harm | Supervision | No | Optional remeasurement |
| Task reward | Not a feature | No | System evaluation |
| Deletion size | Labelled sets | Mean interaction |
| 1 | 6,623 | 0 |
| 2 | 9,682 | 0.008 |
| 3 | 6,287 | 0.016 |
| 4 | 1,530 | 0.027 |
| Item | Validation search / rule | Frozen value |
| Maximum cardinality | 3 | |
| Uncertainty coefficient | 0 | |
| Risk threshold | observed validation scores | 0.0740822119017442 |
| Empirical unsafe-rate constraint | enforced in selection | |
| Mean selected exact-harm constraint | enforced in selection | |
| Full-request removal cap | fixed | 20% |
| Domain | # | Task ID |
|---|---|---|
| Code | 1 | api_contract-hard-markup_errors |
| Code | 2 | api_contract-hard-openapi_params |
| Code | 3 | api_contract-hard-token_errors |
| Code | 4 | api_contract-hard-validation_errors |
| Code | 5 | bug_fix-easy-a_crash_in_local |
| Code | 6 | bug_fix-easy-filtered_relation_queryset_arg |
Context Compression
Context compression reduces the information or memory a model must carry while preserving what it needs to answer questions and act.
See all 90 papers