Trajectories That Segment Themselves: Agent-Declared Boundaries as a Training Unit
Abstract
A long coding-agent trajectory has no obvious training unit. One action carries no stable value. An episode label puts one bit on a run that mixed productive exploration with abandoned directions, and a fixed window cuts wherever the logging falls. We take the boundary from the agent instead. In collection-time semantic self-segmentation, a contract asks the acting agent to state its current falsifiable hypothesis about the cause of the bug. The stretch one hypothesis governs is a semantic phase; the next declaration ends it. The boundary comes out of the same rollout as the trajectory: no milestone vocabulary, gold patch, environment replay, teacher logits, or after-the-fact segmenter places it. A named conjecture is also addressable: a reviewer holding the answer can negate one without naming a file or line, which is how we get the wrong-cause-then-correction transitions recorded work rarely contains. One collection yields four supervised targets from the failed regions an episode label throws away. We then delete the declarations. Given the cut points but not the hypothesis text, a model attributes action blocks to their governing hypothesis at over twice chance, and beats equal-length blocks on the same trajectories (paired sign test, p = 0.0002); the result survives a model-free lexical control and collapses under a label permutation. Asked to place the cuts instead, a code-blind annotator matches 24 of 40 against 11.5 for random placement, while a mechanical test-event rule beats chance at neither end of a strict-to-permissive sweep. Downstream, standard DPO fits 2,551 phase-boundary pairs. No decision changes on 91 adversarially built held-out items; on 60 built the way the training pairs were, four change, all from wrong to right, where two controls change none. Since 1,825 pairs come from one generator family, what those sets separate is how the pairs were written, so the next variable to vary is the pair corpus, not the boundary.