Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Troupekit and Rig

Rig is the most-starred Rust framework for LLM apps that we compared, with 9,308 stars on 2026-11-28, and it was troupekit's starting point: the app troupekit grew out of began on Rig, and troupekit's provider layer follows the design of Rig 0.47. We compared the rig-core library at v0.47.1, checked on 2026-11-28. The repository also ships rig, a terminal coding agent built on the library; where a feature exists only in that agent, we say so.

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 Rig

Rig's examples have no agent with exactly one tool. The shortest with a persona and tools is agent_with_tools, which registers two calculator tools; its agent part (main.rs):

#[tokio::main]
async fn main() -> Result<()> {
    let agent = AgentBuilder::new(OpenAI::from_env()?.completion(openai::GPT_4O))
        .preamble(
            "You are a calculator here to help the user perform arithmetic operations. \
             You must use the provided tools before answering.",
        )
        .dynamic_tools(runtime_tools()?)
        .max_tokens(1024)
        .default_max_turns(2)
        .build();

    let response = agent.prompt("Calculate 2 - 5.").await?.output();
    println!("{response}");

    Ok(())
}

For a kill and resume, Rig's AgentRun is a "Serializable, sans-I/O state machine" (run/mod.rs). The library writes nothing to disk; you serialize the run where you choose and continue it with Agent::resume. From the durable approval example (main.rs), without the comment above it:

#![allow(unused)]
fn main() {
std::fs::write(&state_path, serde_json::to_vec_pretty(&run)?)?;
println!("\nšŸ’¾ run suspended to {}", state_path.display());

// ----- imagine the process exits here and resumes later -----

let mut resumed: AgentRun = serde_json::from_slice(&std::fs::read(&state_path)?)?;
}

The library has no built-in spend cap; an example shows how to write a token cap as a hook (run_budget.rs). The rig coding agent has a BudgetPlugin that caps a session in USD or tokens (agent.md).

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

Rig 0.47.1Troupekit 0.4
DurabilityA serializable AgentRun and Agent::resume; you store the state. The rig coding agent resumes sessions after a crash on its own (agent.md)The framework writes a checkpoint after every step, once checkpoints use Storage::sqlite; the default in-memory store is lost when the process exits
Spend limitsLibrary: a token-cap hook you write. Coding agent: BudgetPlugin in USD or tokensUSD per call, per run and per period, when you set them; checked before each call, in the library
Tracingtracing spans following the OpenTelemetry GenAI conventions (README)Own tracer with no third-party dependencies, JSONL and an HTML viewer
EvalsNone found; rig-typesafeai is experimental typed judgmentsEvals on the persona, checked on every run
Offline and on-deviceCandle in process through rig-candle (README), and Ollama and llama.cpp-server providersllama.cpp in process, Ollama, and a route policy that picks device or cloud per call
MobileNone found; browser WASM is supported instead (README)Builds for iOS and Android in CI; Swift and Kotlin bindings since 0.4, built from source
Single binaryYes, it is a Rust libraryYes, it is a Rust library

Where Rig is better

Breadth and maturity. Rig "puts over 20 model providers and a dozen vector stores behind one interface" (README), has MCP tools, record and replay with rig-cassette, builds for browser WASM, and has a much larger community. Troupekit has none of those four yet.

Where troupekit is different

Persistence and the money cap are the framework's job, not yours: once you set Storage::sqlite checkpoints, every step is checkpointed for you, and every call is checked against the USD limits you set. Agents can be persona TOML files as well as code, graph workflows are built in, and a route policy can move each call between the device and the cloud.