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.

主な機能

01Embeddable Rust Engine: Provided as a library (`tokfold-core`) for seamless integration into applications, with a command-line binary also available.
02Structure-Aware Processing: Specifically designed to compress structured content like JSON, tool outputs, and logs, preserving object key order, duplicate keys, and array element order.
03Reversible Compression: Guarantees semantic identity for reconstructed data, preserving value tree equality rather than byte-for-byte.
04Deterministic Output: Ensures byte-identical output for the same logical input across all runs, preventing silent cache misses for LLM prompt prefixes.
050 GitHub stars
06Sans-IO Core: Operates with zero network calls, zero telemetry, and no integrated ML model (by default), ensuring privacy and predictable performance.

ユースケース

01Reducing token costs for LLM agents by compressing their input context, such as extensive tool outputs or JSON payloads.
02Optimizing the performance and cost-efficiency of multi-turn agent loops by ensuring deterministic compression that leverages provider caching.
03Managing and storing historical LLM agent context efficiently through recovery archives, allowing on-demand reconstruction of original data.