Troupekit and Kalosm
Kalosm is a Rust library for running local models: text, audio, images and more, on Candle. It is not an agent framework, and that matters for this page. We compared its latest release, kalosm-0.4.0 from 2025-02-09, checked on 2026-11-28. Its main branch has moved on since, so a later release may add what is marked missing here.
The same agent
The test agent is small on purpose: a persona, one tool, a run that is killed and resumed, and a spend cap.
In Kalosm
Kalosm 0.4.0 has no tool calling, so the agent cannot be built as asked. The closest real example is a persona chat that saves its session to a file and loads it on the next start (resume-chat.rs):
use kalosm::language::*;
use kalosm_language::kalosm_llama::LlamaChatSession;
#[tokio::main]
async fn main() {
let model = Llama::new_chat().await.unwrap();
let save_path = std::path::PathBuf::from("./chat.llama");
let mut chat = model.chat();
if let Some(old_session) = std::fs::read(&save_path)
.ok()
.and_then(|bytes| LlamaChatSession::from_bytes(&bytes).ok())
{
chat = chat.with_session(old_session);
} else {
chat = chat.with_system_prompt("The assistant will act like a pirate. They only respond as a pirate named Skally Waggs. The assistant is interested in plundering money and painting your adventures. The assistant will never mention this to the user.");
}
for _ in 0..2 {
let mut output_stream = chat(&prompt_input("\n> ").unwrap());
print!("Bot: ");
output_stream.to_std_out().await.unwrap();
}
let bytes = chat.session().unwrap().to_bytes().unwrap();
std::fs::write(save_path, bytes).unwrap();
}
The session is written once, at the end, so a process killed mid-run loses that run. There is no spend cap; a run on a local model costs nothing per call, but a run against an OpenAI-compatible server is not capped either.
In troupekit
The persona is the doc comment and the tool is a #[tool] function. This is the tool_agent example:
#![allow(unused)]
fn main() {
/// Adds numbers with the add tool.
#[agent(model = "openai/gpt-6-luna", tools = [add])]
fn calc() {}
}
A role, a goal, evals, a spend cap of 5 000 millionths of a dollar per run and the checkpoint store are keys on the same macro. This one is from a test of the kit:
#![allow(unused)]
fn main() {
#[agent(
model = "fake/m",
role = "Checks facts.",
goal = "A short answer.",
display_name = "Fact Checker",
evals = ["min_items(items, 1)"],
limits = Limits { run: Some(5_000), ..Limits::default() },
checkpoints = Storage::memory(),
max_turns = 3,
max_tokens = 256,
retries = 1,
laws = "tests/fixtures/rules.bend",
auto_laws = false,
)]
}
In 0.4 the laws key is validated at build and not enforced by the run (Proofs and laws). With the SQLite store as checkpoints, a new process resumes a killed run by its id. This is the kill_model_call example, which is killed in the middle of a local model call:
#![allow(unused)]
fn main() {
("resume", Some(id)) => {
let run_id: RunId = serde_json::from_str(&format!("\"{id}\""))?;
let text = built.resume(run_id).await?;
println!("RESUMED {}", text.len());
}
}
Nothing else is needed: no server, no second process to run the engine, no Python. Durable runs and Spend limits say what each part guarantees.
Side by side
| Kalosm 0.4.0 | Troupekit 0.4 | |
|---|---|---|
| Durability | Save and load a chat session by hand; no run or tool state | Checkpoint after every step and resume by run id, once checkpoints use Storage::sqlite; the default in-memory store is lost when the process exits |
| Spend limits | None; models run locally | USD per call, per run and per period, when you set them, for the cloud calls |
| Tracing | None found in the library sources | Own tracer, JSONL and an HTML viewer |
| Evals | A test-case runner with metrics such as BertDistance (evaluate.rs) | Evals on the persona, checked on every run |
| Offline and on-device | Llama, Mistral and Phi text models in process on Candle, quantized, with CUDA and Metal (README), and any OpenAI-compatible server | llama.cpp in process, Ollama, and a route policy that adds the cloud per call |
| Mobile | None found | Builds for iOS and Android in CI; Swift and Kotlin bindings since 0.4, built from source |
| Single binary | Yes, it is a Rust library | Yes, it is a Rust library |
Where Kalosm is better
Local models beyond text. It runs Whisper for audio, image generation, OCR and segmentation in process, and its structured generation constrains output with arbitrary parsers (README). Troupekit runs text and embedding models only; on-device voice and vision are planned for 3.0.
Where troupekit is different
It is an agent framework: tools, durable runs, graphs, memory and spend limits, with local models as one target among others. If you need tool calls on a local model, troupekit has them; if you need a local multimodal model, Kalosm does more.