- Auto Compaction -> compact the message list at runtime.
- Subconscious Cache -> Maintain both the prefix and the suffix around the pruned messages.
How It Works
To hit the subconscious cache, the cached tokens and new inputs need to satisfy two criteria:- The cached chain can be precisely split into three sections
A, B, C - Section
Bis pruned. - The new input chain can be precisely split into three sections
A, C, D, such thatAandCmatch the prefixAand suffixCin the cache andlen(C) > threshold. We usually setthreshold = 8tokens to avoid matching the suffix of chat templates.
Manually Triggering Subconscious Cache
Subconscious API enables auto-compaction by default. Under the auto-compaction mode, developers can send any message list to the LLM API and the inference system will detect prunable messages. Message pruning in the auto compaction mode will automatically hit the subconscious cache. If you want to manually hit subconscious by controlling the context by yourself instead of auto-compaction, simply disable auto compaction in the chat kwards. Thechat_template_kwargs extension is accepted on both the Completions and Messages endpoints.
When to Turn Off Auto Compaction
If you turn off auto compaction, you need to manually construct inputs that can hit the subconscious cache. Just make sure you only prune one continuous token sequence from the message list. If there is no context pruning, the new input will simply hit prefix cache. If more than one chunks are pruned, we cannot find suffix tokens satisfying the subconscious rules. Use Auto Compaction for:- Programming tasks, where assistant-tool-user messages keeps growing in a message list
- Browser automation, where dead end exploration is easily pruned
- Workflow automation, where stale tool calls pile up quickly
- Multi-turn conversation, where rigid context pruning rule cannot handle arbitrary user inputs
- ReACT multi-modal reasoning: Subconscious cache works perfectly when you only keep latest turns / images in the message list
- Other applications where you need to carefully control context engineering.