On-device models
A hosted model needs the network, costs money per token and sees your text. A small local model is free and private, and much weaker. Most frameworks make you pick one per agent, or run a model server such as Ollama next to your program. Troupekit runs the model inside your process and lets one agent use both.
What you get
- llama.cpp in process. With the
llamafeature,LlamaModel::loadopens a GGUF file andLocalChatmakes it the agent's model client. There is no server to start and no port to open. Local models and routing shows the code. - A checked model cache. The local catalog names each model by URL and SHA-256. A download is checked against its hash before it gets its final name, so a half-finished or tampered file is never loaded. In 0.4 the catalog has one row,
smollm2-135m-instruct-q2k; you can also pass any GGUF file by path. - A route policy per call. Give an agent a cloud
.model(..)and a.local(..), and a TOML route policy picks the target for each call, from the network state, a daily cloud budget, the battery and the device's heat. - Private agents.
.private(true)keeps an agent's model requests on the device, fallback included, andbuildrefuses a private agent that could leak text another way, such as through a cloud embedder or a judge eval on a cloud model. The rule is also one of the Bend proofs. - Kill and resume on the device. With
Storage::sqlitecheckpoints, a local model call that is killed halfway resumes from its checkpoint, the same as a cloud call (guide).
What it does not do
- A 135M-parameter model is good for short, simple tasks, and it is weak at tool calls. The end-to-end test of a local tool call runs on a larger test model, Qwen3 0.6B.
.private(true)also refuses network tools atbuild:web_fetch,web_search, HTTP tools, hosted tools and tools that reportuses_network. A tool you write counts as local unless itsToolimpl returnstruefromuses_network; a#[tool]fn always counts as local.- The on-device model adapters live in the Swift and Kotlin bindings, so a Rust program cannot use them: Apple Foundation Models on iOS, and on Android a LiteRT-LM model file that your app supplies.
Proof
End-to-end tests on a real GGUF model: local_agent_answers_offline, private_agent_stays_on_device_without_a_key, route_falls_back_to_local_when_offline, local_knowledge_agent_answers and catalog_model_downloads_and_answers.