Fit a prompt that is too long for the model by cutting its middle — the context compression plugin.
When a prompt is longer than the model's context window, the request fails. The context compression plugin makes it fit instead: it removes or shortens messages from the middle of the prompt until the prompt fits, keeping the beginning and the end. Models pay the least attention to the middle of a long sequence, so it is the part to lose.
Use it where perfect recall is not required — a long chat, an agent's running log.
{
"model": "anthropic/claude-haiku-4.5",
"messages": [],
"plugins": [{ "id": "context-compression" }]
}The plugin also handles a count of messages above what a model accepts, not only a length.
On a model endpoint with a context of 8 192 tokens or less, compression is on by default. Turn it off with:
{ "plugins": [{ "id": "context-compression", "enabled": false }] }It is skipped for picture models that answer only with pictures, so the reference pictures of an edit are kept whole.
A plugin runs once on every request that names it. The request is billed in DA on the model's own bill, as its usage.cost shows.