Code as Carrier: Context-Efficient Multi-Turn Instruction Following
Abstract
Large language models often fail to preserve instructions across multi-turn conversations, especially when users update constraints without restating them. We present Code as Carrier (CoCa), a programmatic framework for conversation management that dynamically detects topic shifts, identifies user intents, and incrementally updates an executable program that maintains and enforces the topic thread's active constraints. This allows CoCa to reapply constraints through execution rather than recovering them from an ever-growing dialogue history. CoCa provides the largest gains when direct prompting struggles to retain prior constraints: on a short, single-topic benchmark, it improves turn-wise retention by to for weaker models while leaving an already-stable model nearly unchanged. For longer multi-topic dialogues, it can reduce the turn-level failure rate from to . Finally, by updating programs in place, CoCa maintains approximately constant per-turn context and uses fewer context tokens over direct baselines.
Then back it, or bet against it.
Related papers
Open the market on this paper to see 7 more related papers.