Kisson Songqi Lin

Author directory

2026

Long-horizon coding agents can make many edits before testing a task-wide assumption about an API, authentication mode, environment, or persistent state. A late verifier then exposes that the implementation rests on a false premise. We call the missing step contract acquisition and propose Contract Before Code (CBC), harness-level middleware that compiles historical failures into executable preflight gates. CBC normalizes trajectories, extracts recurring failure signatures, and compiles contracts containing an applicability condition, a probe template, and a planning consequence. At inference time, it retrieves applicable contracts and runs instantiated probes before broad implementation work. Among 1,421 parsed failed SWE-Marathon trajectories, weak labels identify candidate rates of 2.6% overall and 17.5% on stripe-clone; these are not root-cause prevalence estimates. A 120-trajectory human audit reports 76.3% contract precision and 71.4% executable-probe synthesis. Across four service/API-clone tasks and 32 runs per method, CBC achieves 31.3% success (95% CI 18.0–48.6), an observed 21.9-percentage-point increase over vanilla, with 55.6% fewer pre-verification edits at 1.11× normalized token cost. The small end-to-end study supports preliminary within-family benefits; broader transfer and the stability of these gains remain unestablished.