TL;DR
Imagine if a carpenter had to stop and read the entire instruction manual for their drill every single time they wanted to put a screw in a wall. That is essentially how today's on-device AI agents use tools—wasting massive amounts of battery and time re-reading API manuals as text prompts. EngramState fixes this by compiling tool manuals offline into tiny, loadable "muscle memories" (recurrent states), slashing on-device wait times by nearly 30× without sacrificing accuracy.
What Problem Does This Paper Address?
When you ask a smartphone AI agent to "send the latest report to my advisor," it needs to translate your words into a structured API call (like send_email(...)). Typically, systems use a retrieve-then-prompt approach: search a database for the top few relevant tools, paste their manuals (names, descriptions, argument rules, edge cases) into the prompt alongside your query, and let the LLM read the whole thing.
Here is the catch: user queries average around 22 tokens, while pasting just four tool manuals adds ~864 tokens—nearly 40× larger than what you actually said! On a resource-constrained smartphone, reading all that repetitive text ("prefilling") dominates latency and drains memory. Standard Transformer KV-caching doesn't help much here either, because KV caches depend on exact token order; since retrieved tools appear in dynamic combinations for every new query, you can't arbitrarily mix and match cached prefixes. Tool knowledge is treated as transient text rather than reusable memory.
Methods
To turn tool manuals into plug-and-play memories, the authors move away from standard Transformers and build on stateful sequence models—specifically RWKV-7 (with Mamba also supported). Unlike Transformers, whose memory grows with every word, RWKV compresses everything it reads into a fixed-size recurrent hidden state.
EngramState introduces four clever components to make state-loading work in practice:
- Retention-Aware State Splitting (Offline): Fixed-size states aren't magic infinite hard drives; stuff too much text in, and the model starts forgetting. Instead of cramming a whole manual into one state, EngramState splits each tool into two snapshots: a Base State (Tool Name, Description, Argument Schema) for fast first-pass execution, and a Corrective State (Formatting rules, Failure modes, Hard cases) kept on standby.
- Channel-Wise Compression (Offline): Storing two raw states per tool adds up (~24.76 MiB/tool). Because numerical outliers consistently pop up in the exact same state channels regardless of the text, simple 4-bit per-channel quantization shrinks state storage by 8× with virtually zero accuracy loss.
- Same-Backbone State Retriever (Online): Rather than shipping a separate, bulky embedding model (like BGE) on the phone just to pick tools, EngramState passes the user query through the frozen RWKV backbone, grabs features from its top 8 internal layers, and runs them through tiny MLP projection heads (just 1.08M parameters!) to find the best tool state.
- Feedback-Driven State Routing (Online): Once a Base State is loaded, the LLM processes only your 22-token query. A lightweight rule-based validator checks the generated API call against the schema. If there's a parameter error, a router swaps in that tool's Corrective State and retries; if it picked the wrong tool, it routes to the next candidate's state.
Datasets
- DroidCall: The primary benchmark used for LoRA fine-tuning and evaluation, focusing on realistic Android intent/function invocation ranging from simple single calls to tricky argument formatting.
- Berkeley Function Calling Leaderboard (BFCL): Used for additional validation (detailed in the paper's appendix) to test broader generalization. No new datasets were introduced.
Key Insights and Ideas
- Less is more for recurrent states: Stuffing all four retrieved tool specs into one "Compound State" tanks exact accuracy from 78% down to 36%. Even putting one entire tool manual into a single state degrades performance once edge-case rules dilute the core schema. Splitting knowledge into Base and Corrective states turns a hardware limitation into an algorithmic advantage.
- Your executor is already a great retriever: You don't need a 400+ MiB standalone encoder to retrieve tools. The execution model's own internal recurrent states already organize tool-discriminative features cleanly enough to match dedicated retrievers using 99% less storage.
- Retrying is cheap when prompts are tiny: Usually, retrying failed LLM generations on a phone is painfully slow. Because EngramState only feeds the 22-token user query on each attempt, even a worst-case 4-retry loop finishes faster (8.2s) than a single standard prompt-based attempt (9.0s).
Key Results
Tested live on a Samsung Galaxy S25 Ultra using an RWKV-7 1.5B backbone:
- Massive Speedups: Under Top-4 retrieval, prompt length drops by 97.8% (985 tokens $\rightarrow$ 22 tokens). Time-to-first-token (TTFT) plummets from 7.301s to 0.259s (~28× faster), easily beating Transformer baselines like Qwen2.5-1.5B (6.016s) and Gemma-4-E2B (11.960s).
- Lower Memory, Equal or Better Accuracy: Peak RAM (PSS) drops by over 220 MiB (1793 MiB $\rightarrow$ 1566 MiB), while exact accuracy holds steady (78.5% vs. 78.0%) and Soft Accuracy improves from 86.5% to 89.6%.
- Tiny Footprint: 4-bit compressed states take just 3.10 MiB per tool (compile time: 0.28s per tool offline). Meanwhile, the custom state retriever hits 94.0% Top-1 and 99.5% Top-4 retrieval accuracy while taking up just 4.14 MiB—compared to 417.64 MiB for BGE-base.
Limitations and Future Work
- Backbone Lock-In: Precompiled states are tightly coupled to the exact weights of the model that created them. While adding or editing individual tools is effortless, updating or fine-tuning the base LLM requires recompiling the entire state repository offline.
- Architecture Constraints: The method relies on fixed-size recurrent state architectures (like RWKV or Mamba) and cannot be directly dropped into standard autoregressive Transformers.
- Retriever Bottleneck: Moving from oracle tool selection (78.5% accuracy) to the learned state retriever (74.0% accuracy) shows that end-to-end execution is still noticeably sensitive to initial retrieval mistakes. (Broader future directions are not explicitly discussed in the main text.)
Summary updated