The Token Miser: How tontinton/maki Built a 60 FPS Coding Agent in Rust

While standard AI tools burn tokens reading entire codebases, this native terminal UI uses AST parsing and local sandboxing to give LLMs exactly what they need.

7 min read • View on GitHub • More from tontinton

A sleek metallic falcon navigating through a crowded sky of slow, tethered hot air balloons. This visualizes the contrast between Maki's lightweight native binary and heavy web-based, Electron-wrapper AI agents.
Maki navigates the codebase with the precision of a native Rust binary, contrasting sharply with the bloated hot air balloons of Electron-based AI agents.
Key Takeaways

The GUI Tax on AI Agents

Modern AI coding agents suffer from a fundamental architectural mismatch. They attempt to run text-based LLM interactions inside heavyweight browser engines and Node.js daemons. This results in bloated, memory-hungry applications that struggle to maintain responsiveness when dealing with massive codebases. The GUI tax is steep, and developers pay it in lost RAM and sluggish performance.

Maki flips this model entirely. Built as a native Rust terminal application, it utilizes the ratatui framework for UI rendering and the lightweight smol async runtime. The result is an agent that operates at a consistent 60 FPS with a near-zero memory footprint. It delivers the power of a modern AI assistant without the overhead of an Electron wrapper.

FeatureMaki (tontinton/maki)Standard AI Agent
Core EngineNative Rust (Compiled)Node.js / Electron
UI Frameworkratatui (Terminal)HTML/CSS/DOM
Context Strategytree-sitter SkeletonsFull File Reading
Command SecurityAST Pre-parsingBlind execution with confirmation

The Token Miser Pipeline

The true cost of an AI agent is measured in context tokens. Traditional agents blindly dump entire 2,000-line files into the LLM's context window just to locate a single function. This approach is computationally expensive and quickly exhausts context limits, leading to "Context Inflation."

Maki acts as a strict token miser through its maki-code-index tool. Instead of reading full files natively, it leverages tree-sitter to map the codebase into a structural skeleton. The LLM receives only function names and line numbers. When the LLM needs specific logic, it uses the read tool to fetch only the required line ranges. This pipeline ensures the context window remains pristine and focused.

Maki uses tree-sitter to index code structure, sending only necessary code snippets to the LLM context window.

Sandboxing the Search

Perhaps the most brilliant technical trick in Maki's repository is the code_execution meta-tool. When an LLM needs to perform heavy data processing, such as searching through hundreds of files, Maki refuses to let it do the work within the context window.

Instead, Maki instructs the LLM to write a Python script. This script is then executed locally via the monty sandbox. The sandbox performs the heavy lifting—running glob and grep commands across the file system—and returns only the filtered results back to the LLM. This offloading strategy drastically reduces network overhead and preserves precious tokens.

A close-up of an industrial prospector's pan filtering rocks. Large rocks are caught in the mesh, representing boilerplate code, while a few specks of gold dust fall into a vial, representing the exact line numbers returned by the python sandbox.
The local Python sandbox acts as a fine sieve, filtering out massive amounts of file data and returning only the pure, necessary logic to the LLM.

Parsing Intent, Not Just Text

Security in AI agents is often an afterthought, typically handled by simple confirmation prompts before executing bash commands. This leaves developers vulnerable to the classic rm -rf disaster if an LLM hallucinates a destructive command.

Maki disarms the AI through its permissions.rs security model. It utilizes tree-sitter-bash to parse incoming commands into an Abstract Syntax Tree. By analyzing the AST, Maki determines the true intent of the command, neutralizing destructive operations before they ever reach the shell.

A split composition showing a blindfolded figure swinging a sledgehammer at a wall on the left, and a focused locksmith picking a complex glass lock on the right. This visualizes Maki's precise AST parsing versus blind bash execution.
Maki parses bash commands with the precision of a locksmith, rejecting the blind, sledgehammer approach of standard AI agents.

Breaking the Doom Loop

Autonomous agents often fall into "Doom Loops," repeatedly calling the same failing tool in a desperate attempt to force an outcome. Maki implements a RecentCalls state tracker to monitor tool usage.

When Maki detects an LLM caught in a loop—such as calling a tool with identical input three times—it forcefully intercepts the execution and returns an error. This breaks the cycle and forces the LLM to adopt a new strategy, ensuring the agent remains truly autonomous.

if self.recent_calls.is_looping(&tool_call) {
    return Err(ToolError::DoomLoopDetected("Forcing strategy change.".to_string()));
}

The Bootstrap Paradox

Maki's extreme optimization is not merely theoretical. The project's scale and highly modular workspace are a testament to its effectiveness. The most compelling proof of Maki's capability is its own creation.

The agent was so successful at managing complex codebases and conserving tokens that it was able to write the vast majority of its own source code, creating a fascinating bootstrap paradox in the world of AI tooling.