Accept the longest prefix where a draft sequence agrees with the target model, then emit the target token at the first mismatch.
Required APIdef speculative_accept(draft, target):
return {'accepted': ..., 'emitted': ...}BehaviorThink through the mechanism first if you want the extra reasoning step. It never blocks the editor.
speculative_accept([1, 2], [1, 2, 3])a correct draft skips target work
speculative_accept([9, 2], [1, 2, 3])the target remains authoritative
2 hidden edge tests run after the visible contract passes.
Run Tests to see the contract verdicts here.