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

anchor-chain is a statically typed Rust framework for chaining prompts and model calls. We compared release v0.4.2 from 2024-05-13, checked on 2026-11-28. The repository has had no push since 2024-06-23 and has 6 stars.

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

anchor-chain has no agent loop and no tool calling, so the agent cannot be built. The closest real example is a prompt-and-model chain (ollama.rs):

use std::collections::HashMap;

use anchor_chain::models::ollama::Ollama;
use anchor_chain::{ChainBuilder, Prompt};

#[tokio::main]
async fn main() {
    let ollama = Ollama::new_with_defaults("llama3");
    let chain = ChainBuilder::new()
        .link(Prompt::new("{{ input }}"))
        .link(ollama)
        .build();

    let output = chain
        .process(HashMap::from([(
            "input".to_string(),
            "Write a hello world program in Rust".to_string(),
        )]))
        .await
        .expect("Error processing chain");
    println!("{}", output);
}

We found no checkpoint, resume or spend cap; max_tokens sets generation length only.

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

anchor-chain 0.4.2Troupekit 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 foundUSD per call, per run and per period, when you set them; checked before each call
TracingAn optional tracing feature with spans on chain nodes and model calls (Cargo.toml)Own tracer, JSONL and an HTML viewer
EvalsNone foundEvals on the persona, checked on every run
Offline and on-deviceAn Ollama client (ollama.rs); no in-process modelllama.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 anchor-chain is better

The links between chain steps are checked at compile time, and it ships OpenSearch indexing and retrieval (opensearch_retriever.rs). Troupekit has no OpenSearch support.

Where troupekit is different

It is an agent framework, maintained, with tools, durable runs and money caps. anchor-chain was one of the projects weighed when troupekit started, and its small size and age were part of the reason to build a new one.