Tokfold
Reversibly compresses LLM agent context such as tool outputs, JSON, and logs to significantly reduce token cost.
Tokfold is an embeddable Rust engine designed to reversibly compress context for Large Language Model (LLM) agents, including tool outputs, JSON structures, and logs. It functions as a deterministic, sans-io library that transforms bulky context into a denser representation for the model to read, while simultaneously generating a recovery archive that can reconstruct the original data on demand. The compression guarantees semantic identity—meaning the reconstructed document is equal as a value tree to the original—rather than byte-for-byte identity, ensuring data integrity for downstream processing. This approach focuses on optimizing for latency and fidelity risk, providing a robust solution for cost-effective and reliable LLM agent operations.