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 llm-chain

llm-chain was one of the first Rust crates for prompt chains and agents, with llama.cpp bindings. Its last release on crates.io is 0.13.0 from 2023-11-15, which has no git tag, so we read the main branch at 5d26adf, whose manifest reads 0.13.0. Checked on 2026-11-28. The repository has had no push since 2024-10-31.

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 llm-chain

The one built-in agent is self-ask with search, with one tool and a fixed prompt, so there is no persona to set (self_ask_with_search.rs):

use llm_chain::{
    agents::self_ask_with_search::{Agent, EarlyStoppingConfig},
    executor,
    tools::tools::BingSearch,
};

#[tokio::main(flavor = "current_thread")]
async fn main() {
    let executor = executor!().unwrap();
    let bing_api_key = std::env::var("BING_API_KEY").unwrap();
    let search_tool = BingSearch::new(bing_api_key);
    let agent = Agent::new(
        executor,
        search_tool,
        EarlyStoppingConfig {
            max_iterations: Some(10),
            max_time_elapsed_seconds: Some(30.0),
        },
    );
    let (res, intermediate_steps) = agent
        .run("What is the capital of the birthplace of Levy Mwanawasa?")
        .await
        .unwrap();
    println!(
        "Are followup questions needed here: {}",
        agent.build_agent_scratchpad(&intermediate_steps)
    );
    println!(
        "Agent final answer: {}",
        res.return_values.get("output").unwrap()
    );
}

EarlyStoppingConfig caps iterations and seconds. We found no cap in money or tokens beyond a per-request MaxTokens, and no checkpoint or resume.

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

llm-chain 0.13.0Troupekit 0.4
DurabilityNone foundCheckpoint after every step and resume by run id in a new process, once checkpoints use Storage::sqlite; the default in-memory store is lost when the process exits
Spend limitsNone; iteration and time capsUSD per call, per run and per period, when you set them; checked before each call
TracingNone foundOwn tracer, JSONL and an HTML viewer
EvalsNone foundEvals on the persona, checked on every run
Offline and on-devicellama.cpp bindings, the rustformers llm backend and Gemma in process (llama-sys), all from 2024 or earlier; no Ollamallama.cpp in process, Ollama, and a route policy per call
MobileNone foundBuilds 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 llm-chain is better

Recognition and several local back ends in one workspace: 1,601 stars and three in-process model crates. It is no longer maintained, so for new work that is history more than an advantage.

Where troupekit is different

It is maintained, and it has durable runs, money caps, tracing and evals, with a current llama.cpp.