Quarkus LangChain4j can shrink prompts without deleting chat history
An experimental extension separates stored history from what the model sees; a Quarkus replay illustrates the trade-off between recall and latency.
Quarkus LangChain4j 2.0 adds an experimental context-compaction extension that leaves the conversation intact in the application’s chat memory store while sending a smaller version to the model. In its November 30 engineering write-up, the Quarkus project uses a simulated outage to show why that distinction matters: once a sliding window dropped the opening turn, an assistant confidently gave advice that contradicted the operator’s original instructions.
What changed
The extension separates the stored conversation from the view sent with each model request. A compaction strategy can replace old tool results with short placeholders or summarize earlier turns without writing those changes back to the store. The default pipeline combines several strategies, starting with cheaper operations. The extension applies to AI services using default chat memory; teams set the context-window size for their model rather than relying on the extension’s 16,000-token assumption.
What the replay showed
Quarkus tested one fictional incident conversation: 81 messages, nine recall questions and three repeats per question, with a reduced context budget to trigger compaction repeatedly. The default pipeline averaged 7.5 correct answers out of nine and sent 53% fewer prompt tokens across the conversation than the full-history baseline, which scored nine out of nine. Tool-output pruning alone averaged seven correct answers with 49% fewer prompt tokens and about zero measured compaction time in that test. The pipeline’s slowest compaction added 5.2 seconds to one request. These are results from a single replay, not a production latency or recall forecast.
What to test before adopting it
For teams building assistants that make frequent tool calls, the practical comparison is whether pruning old tool output is enough before adding a synchronous summarizer. Replay a representative conversation and check whether early constraints and decisions survive, how many prompt tokens are sent, and how long the slowest compaction takes. Keep authorization rules outside the conversation: preserving the original messages for audit does not guarantee the model sees them on a given turn, and the Quarkus write-up explicitly warns that its summary wrapper is not a security boundary.
sources
comments · 0