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 LangChain

LangChain is the most widely used Python framework for LLM apps, with 150,118 stars on 2026-11-28. Its agents run on LangGraph. We compared langchain at 1.5.2, checked on 2026-11-28. Its docs live in a separate repository with no release tags, so docs links point at its commit ba020fb from 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

From the quickstart (quickstart.mdx):

from langchain.agents import create_agent

def get_weather(city: str) -> str:
    """Get weather for a given city."""
    return f"It's always sunny in {city}!"

agent = create_agent(
    model="openai:gpt-6.1-sol",
    tools=[get_weather],
    system_prompt="You are a helpful assistant",
)

result = agent.invoke(
    {"messages": [{"role": "user", "content": "What's the weather in San Francisco?"}]}
)
print(result["messages"][-1].content_blocks)

For a kill and resume you pass a persistent checkpointer from a separately installed saver package and run with a thread_id; LangGraph then resumes the run. From the short-term memory page, with its highlight markers removed (short-term-memory.mdx):

from langchain.agents import create_agent
from langgraph.checkpoint.postgres import PostgresSaver

def get_user_info() -> str:
    """Look up information about the current user."""
    return "No user profile on file."

DB_URI = "postgresql://postgres:postgres@localhost:5432/postgres?sslmode=disable"
with PostgresSaver.from_conn_string(DB_URI) as checkpointer:
    checkpointer.setup() # auto create tables in PostgreSQL
    agent = create_agent(
        "gpt-6.1-sol",
        tools=[get_user_info],
        checkpointer=checkpointer,
    )

There is no cap in money or tokens. ModelCallLimitMiddleware limits model calls per thread or run, "to prevent infinite loops or excessive costs" (built-in.mdx), and token usage is reported by a callback, not enforced (models.mdx).

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 1.5.2Troupekit 0.4
DurabilityLangGraph checkpoints through a saver package and a thread_idCheckpoint after every step, built in, once checkpoints use Storage::sqlite; the default in-memory store is lost when the process exits
Spend limitsModel-call and tool-call count limitsUSD per call, per run and per period, when you set them; checked before each call
TracingLangSmith (observability.mdx), which needs an accountOwn tracer, JSONL and an HTML viewer
EvalsThe separate agentevals package, and LangSmith (evals.mdx)Evals on the persona, checked on every run
Offline and on-devicelangchain-ollama, and ChatLlamaCpp in langchain-community (llamacpp.py)llama.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 binaryNeeds Python 3.11 or newer (pyproject.toml)Compiles into your program

Where LangChain is better

Ecosystem. Its docs have more than 100 Python provider pages and 38 chat-model pages at this commit, a ready middleware set for human review, PII, summarization, fallback and call limits, MCP tools, and LangSmith for hosted tracing and evals. Troupekit's ecosystem is small and new.

Where troupekit is different

Durability and a money cap are part of the agent rather than extra packages and middleware, tracing needs no account, and the whole thing compiles into one program that can also run on a phone.