DRIFT adds automatic token compression for multi-language code
DRIFT now includes a token compression feature that automatically shrinks code before it enters the model context. It works across programming languages, not only structured formats like JSON. Code pulled from memory, scraped from documentation, or inserted from workspace context goes through a language-aware minification step first.
For Python, it removes docstrings, inline comments, repeated spaces, and blank lines. For JavaScript and CSS, it removes single-line and multi-line comments, then reduces spaces and line breaks while keeping the code structure intact. For HTML, it removes developer comments and cuts extra spacing between tags while keeping the DOM structure.
In a mixed Python, JavaScript, and HTML test, 433 characters were reduced to 240 characters, a 44.57% reduction.
Key points
- DRIFT compresses code automatically before sending it into the model context.
- It supports Python, JavaScript, CSS, and HTML.
- It removes comments, docstrings, extra spacing, and unnecessary line breaks.
- A mixed-language example shrank from 433 characters to 240 characters, a 44.57% reduction.
- This can help AI agents fit more code into API limits and reduce token cost.
Quick term guide
- compression
- A process that shortens older chat details so the AI can keep working in a long session.
- model context
- The information an AI model reads before producing an answer.
- programming language
- A set of rules people use to tell computers what to do.
- documentation
- Written notes that explain how a task or process is done.
- JavaScript
- A programming language often used to add interactive features to websites.
- DOM structure
- The tree-like layout of elements that make up an HTML webpage.
- API limits
- Rules that limit how many times an app or service can be used in a set time.
- token cost
- The money or usage spent when sending text to an AI model and getting text back.