The Assistant Turn and Prefilling

Assistant

Part of: Chat Roles & Messages

Ask a model to return JSON and it often opens with "Sure! Here is the JSON you requested:" before the actual data, useless for a parser. There's a quiet trick that fixes this in one line: you write the beginning of the assistant's reply yourself, and the model continues from there. It's called prefilling , and it works precisely because the assistant turn is just another message you control. What it is The model's reply is an assistant message : same shape as everything else: a role of assistant and some content. From the message-array lessons you know you append it back to continue the chat. The new idea here is that you don't have to leave that assistant content empty. You can prefill it: put the opening text yourself as the last message, and the model picks up exactly where you stopped. Because generation is "continue the transcript," a half-finished assistant message is a strong hint. Start it with { and the model is almost forced to produce JSON next. How it works A normal request ends on a user message and the model writes the whole assistant turn. To prefill, you add a partial assistant message at the end and let the model finish it: The model's continuation is appended to y

Challenge: Prefill Reassembler