Repository navigation
@tanstack/ai-compaction@0.2.0
Minor Changes
-
#1729
51f72fb- A text adapter can now have an optionalcompact(options)method. It sends the history to the provider's own compaction endpoint, and resolves to the history for the next calls. The options areTextCompactOptions:messages,model,signal,wrapFetch, andsystemPrompts.The OpenAI Responses adapters implement
compactwithPOST /responses/compact. The request sends the system prompts asinstructions. It sends no tools, because the endpoint does not take them. The encryptedcompactionitem goes back to the same model as it is on later requests. A compact result with no compaction item throws.withCompactionhas a newnativeoption. Pass the adapter of thechat()call. When the adapter hascompact, it runs in place ofstrategy. Whencompactfails,strategyruns, andonCompactandcompaction:endedget the failure inerror. After a 404, 405, or 501, that adapter and model use the strategy for the rest of the process. After any other failure, the next compaction triescompactagain. Without the option, nothing changes.