Text Classification
Transformers
Safetensors
English
roberta
agent-traces
post-training
sft-filter
rl-rollouts
renaissancelabs
text-embeddings-inference
Instructions to use RenaissanceLabsEU/trace-loop-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RenaissanceLabsEU/trace-loop-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="RenaissanceLabsEU/trace-loop-classifier")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("RenaissanceLabsEU/trace-loop-classifier") model = AutoModelForSequenceClassification.from_pretrained("RenaissanceLabsEU/trace-loop-classifier", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 6,022 Bytes
4ab7986 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | ---
license: apache-2.0
base_model: distilroberta-base
datasets:
- open-thoughts/AgentTrove
- Agent-Ark/Toucan-1.5M
- openbmb/UltraData-SFT-Agent-2609
- jupyter-agent/jupyter-agent-dataset
- FineEnvs/SmolDataEnvs-sft
- jedisct1/security-audits
- SWE-bench/SWE-smith-trajectories
- Lego-X/LegoFlow-SWE
language:
- en
tags:
- text-classification
- agent-traces
- post-training
- sft-filter
- rl-rollouts
- renaissancelabs
library_name: transformers
---
# trace-loop-classifier
A fast, lightweight (82M-parameter `distilroberta-base`) binary classifier trained by [Renaissance Labs](https://renaissancelabs.eu) to detect **agent stall loops and semantic repetition** in multi-turn tool-calling and coding-agent trajectories — built to complement exact-match regex filters in SFT data curation and RL rollout monitoring (motivated by [Marin `#12264`](https://github.com/marin-community/marin/issues/12264)).
Labels:
- `0` (`clean`): normal multi-turn progress (including legitimate single-retry-then-succeed recoveries)
- `1` (`loop_or_stall`): consecutive stalls, argument-jittered retries, A-B-A-B oscillations, circular apology/plan-restate stalls, or doom-loop suffix repetition
---
## Benchmark results (vs. exact-match regex baselines)
Evaluated on both **in-distribution held-out trajectories** (`test_id`, 217 traces from 6 permissive sources) and **unseen-source OOD trajectories** (`test_ood`, 500 traces from `SWE-bench/SWE-smith-trajectories` and `Lego-X/LegoFlow-SWE`, never seen during training):
### In-distribution test (`test_id`, `n = 217`)
| Detector | F1 | Precision | Recall | Accuracy | AUROC | Latency |
|---|---:|---:|---:|---:|---:|---:|
| Regex: consecutive exact stall (`>=3x`) | `0.3762` | `1.0000` | `0.2317` | `0.7097` | `0.6159` | `<0.1 ms` |
| Regex: spread exact duplicate (`>=30%`) | `0.5487` | `1.0000` | `0.3780` | `0.7650` | `0.6890` | `<0.1 ms` |
| Regex: combined (`exact OR spread`) | `0.6102` | `1.0000` | `0.4390` | `0.7880` | `0.7195` | `<0.1 ms` |
| **`RenaissanceLabsEU/trace-loop-classifier`** | **`0.9487`** | **`1.0000`** | **`0.9024`** | **`0.9631`** | **`0.9587`** | **`17.7 ms/trace` (M5 MPS)** |
### Unseen-source OOD test (`test_ood`, `n = 500`: `SWE-smith` + `LegoFlow-SWE`)
| Detector | F1 | Precision | Recall | Accuracy | AUROC | Latency |
|---|---:|---:|---:|---:|---:|---:|
| Regex: consecutive exact stall (`>=3x`) | `0.4266` | `1.0000` | `0.2711` | `0.6720` | `0.6356` | `<0.1 ms` |
| Regex: spread exact duplicate (`>=30%`) | `0.0769` | `1.0000` | `0.0400` | `0.5680` | `0.5200` | `<0.1 ms` |
| Regex: combined (`exact OR spread`) | `0.4483` | `1.0000` | `0.2889` | `0.6800` | `0.6444` | `<0.1 ms` |
| **`RenaissanceLabsEU/trace-loop-classifier`** | **`0.9933`** | **`1.0000`** | **`0.9867`** | **`0.9940`** | **`0.9912`** | **`18.1 ms/trace` (M5 MPS)** |
### OOD breakdown by subtype (`test_ood`)
| Subtype | True label | Count | Accuracy |
|---|---:|---:|---:|
| `clean` (real unseen SWE traces) | `0` | `225` | `100.0%` |
| `hard_neg_single_retry` (1 retry → success) | `0` | `50` | `100.0%` |
| `exact_stall` (3–5× consecutive repeat) | `1` | `54` | `100.0%` |
| `jitter_retry` (argument/comment-tweaked retries) | `1` | `36` | `100.0%` |
| `ab_oscillation` (A-B-A-B cycle) | `1` | `42` | `100.0%` |
| `apology_stall` (circular plan-restate / apology) | `1` | `40` | `100.0%` |
| `doom_suffix` (repeated tail chunk) | `1` | `50` | `100.0%` |
| `real_loop` (natural spread-out repeats in 99-turn `LegoFlow-SWE` runs) | `1` | `3` | **`0.0%`** *(see Limits)* |
---
## Run Card
- **Base model:** `distilroberta-base` (82M params, Apache-2.0)
- **Splits:** `1,346` train / `209` val / `217` ID test (from 6 Apache-2.0 / MIT HF trace datasets: `AgentTrove`, `Toucan-1.5M`, `UltraData-SFT-Agent-2609`, `jupyter-agent-dataset`, `SmolDataEnvs-sft`, `security-audits`) + `500` unseen-source OOD test (`SWE-smith-trajectories`, `LegoFlow-SWE`).
- **Truncation:** `max_length=512`, `truncation_side="left"` (always preserves the tail of the trajectory where stalls occur).
- **Hyperparameters:** full fine-tune in fp32, `AdamW`, `lr=3e-5`, cosine warmup, `batch_size=8`, `grad_accum=2` (eff batch 16), `4` epochs, best checkpoint selected by validation F1 (`0.9867`, val AUROC `0.9999`).
- **Hardware & wall-clock:** Apple M5 (MPS), `429.5s` (~7 minutes total).
---
## Quick start
```python
from transformers import pipeline
clf = pipeline(
"text-classification",
model="RenaissanceLabsEU/trace-loop-classifier",
truncation=True,
max_length=512,
)
# Format trajectory as [ROLE] content lines (keep the tail for long runs)
trace = "[USER] Fix failing tests\n[ASSISTANT] Running pytest...\n[TOOL] Exit code 1\n..."
print(clf(trace))
```
---
## Honest limits & recommended usage
1. **512-token tail window misses early-episode spread-out repeats:** On the 3 natural `real_loop` traces in `test_ood` (`LegoFlow-SWE`, averaging ~99 turns), the repeated actions happened earlier than the final 512 tokens, so the model scored `0/3`. **Recommended production setup:** run this classifier **together with** a cheap whole-episode exact-duplicate counter (`spread_repeat >= 30%` OR `trace-loop-classifier >= 0.5`).
2. **Synthetic semantic-loop positives:** Because natural permissive trace datasets contain relatively few labeled semantic loops, the `jitter_retry`, `ab_oscillation`, `apology_stall`, and `doom_suffix` positives were injected onto real clean trajectories. Real-world semantic loops outside those templates should be audited before relying on this model as a sole gate.
3. **English-primary:** Trained on English-dominant coding and tool-calling traces.
## Links & license
- **Agentic Traces Audit & Shortlist:** [RenaissanceLabs-EU/datasets/agentic-traces](https://github.com/RenaissanceLabs-EU/datasets/blob/main/agentic-traces/SHORTLIST.md)
- **Open Agent Skills:** [skills.renaissancelabs.eu](https://skills.renaissancelabs.eu)
- **Lab:** [renaissancelabs.eu](https://renaissancelabs.eu)
- **License:** Apache 2.0.
|