Troupekit and langchain-rust
langchain-rust brings LangChain's chains, agents, memory and vector stores to Rust. We compared release v8.0.0 from 2026-11-03, checked on 2026-11-28.
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 langchain-rust
The agent example has one tool (agent.rs). A persona goes in the builder's prefix (builder.rs), which no example sets.
use std::sync::Arc;
use langchain_rust::{
agent::{AgentExecutor, ConversationalAgentBuilder},
chain::{options::ChainCallOptions, Chain},
llm::openai::{OpenAI, OpenAIModel},
memory::SimpleMemory,
prompt_args,
tools::CommandExecutor,
};
#[tokio::main]
async fn main() {
let llm = OpenAI::default().with_model(OpenAIModel::Gpt4Turbo);
let memory = SimpleMemory::new();
let command_executor = CommandExecutor::default();
let agent = ConversationalAgentBuilder::new()
.tools(&[Arc::new(command_executor)])
.options(ChainCallOptions::new().with_max_tokens(1000))
.build(llm)
.unwrap();
let executor = AgentExecutor::from_agent(agent).with_memory(memory.into());
let input_variables = prompt_args! {
"input" => "What is the name of the current dir",
};
match executor.invoke(input_variables).await {
Ok(result) => {
println!("Result: {:?}", result);
}
Err(e) => panic!("Error invoking LLMChain: {:?}", e),
}
}
Chat history can live in SQLite or Postgres (sql_history.rs), but a run is not checkpointed, so a killed run starts over. At this release nothing stops a run on cost: token usage is summed into the output (executor.rs) and the executor caps iterations at 10 by default. A token-usage hook, with_usage_limit, is on the main branch (executor.rs) and not yet released.
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
| langchain-rust 8.0.0 | Troupekit 0.4 | |
|---|---|---|
| Durability | Chat history in SQLite or Postgres; no run checkpoints | Checkpoint 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 limits | None released; an iteration cap. A token hook is on main | USD per call, per run and per period, when you set them; checked before each call |
| Tracing | tracing spans for model and tool calls (observability.rs) | Own tracer, JSONL and an HTML viewer |
| Evals | None found | Evals on the persona, checked on every run |
| Offline and on-device | Ollama (Cargo.toml); no in-process chat model | llama.cpp in process, Ollama, and a route policy 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 langchain-rust is better
Ready-made integrations. Its examples cover Qdrant, pgvector, Milvus, Pinecone, Chroma, Weaviate, OpenSearch, SurrealDB, Redis, MongoDB, MariaDB and sqlite-vec (examples), with many providers and document loaders. Troupekit keeps its index in SQLite and adds server vector stores in 2.0.
Where troupekit is different
With Storage::sqlite checkpoints a killed run continues from its last step, a cap in money you set is checked before each call, and the model can run in the same process. Graph workflows are built in, where langchain-rust has sequential and router chains.