LLM ROUTING

How OpenRouter middle-out transforms reshape a prompt

In this article
THE QUICK TAKE

Context compression makes an oversized prompt fit by removing or truncating material; the application must decide whether losing that material is acceptable.

A long conversation can exceed a model’s available context even when its latest question is small. OpenRouter’s Message Transforms documentation describes a context-compression plugin that removes or truncates middle material. This is a fitting mechanism, not a guarantee that the model receives a faithful semantic summary of everything that was removed.

Use the current plugin contract

The current documentation enables the feature through the plugins array with the context-compression identifier. An older discussion of “middle-out” may describe the basic removal idea without matching the current request syntax. Build the actual request from the current official schema. For a hypothetical archive-summary app, keep its compression configuration explicit so a later maintainer can explain why some earlier messages were not available to the model.

Understand what middle removal changes

The plugin reduces the prompt by removing or truncating material from its middle until it fits the selected context. Keeping the beginning and end can preserve broad setup and the latest request, but an important correction may sit between them. In the archive example, a middle message could revoke an earlier assumption. Losing that correction can change the answer even though the request now satisfies the token limit.

Keep dependent tool records coherent

A tool result depends on the call that requested it, and later conclusions may depend on that observation. A generic middle-removal strategy should not replace application-aware history management for workflows that require exact relationships. Preserve the necessary call, result and accepted decision together according to the chosen API contract. For an audit-style archive answer, a compact evidence bundle may be more appropriate than arbitrary conversation truncation.

Decide when exact recall is required

An informal conversation recap may tolerate lost detail, while a question about a specific contractual change may not. Choose behavior according to the product’s task. If exact evidence is necessary, retrieve the relevant source or shorten unrelated context deliberately. The application can also report that the available context is insufficient. A request that fits is useful only when its remaining content can still support the intended conclusion.

Evaluate information loss explicitly

Create a representative long conversation with an important middle correction and compare the answer with and without application-controlled evidence selection. This is a hypothetical evaluation design, not a performance claim about OpenRouter. Inspect whether the final result still cites and follows the accepted facts. The test should assess the task’s information requirements rather than merely confirming that the oversized request stopped returning a context-length error.

Documentation and further study

Related engineering guides: Fetching the OpenRouter model catalog before deployment; Tool calling through OpenRouter: the model proposes, your app executes.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles