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 Swiftide

Swiftide is a Rust library for streaming indexing pipelines, retrieval, agents and typed task graphs. We compared release v0.34.0, 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 Swiftide

The README quickstart has one tool (README). It sets no persona; the builder takes one with .system_prompt(..), as the examples show (tasks.rs).

use anyhow::Result;
use swiftide::{
    agents,
    chat_completion::{ToolOutput, errors::ToolError},
    traits::AgentContext,
};

#[swiftide::tool(
    description = "Looks up a Swiftide concept",
    param(name = "concept", description = "Concept to explain")
)]
async fn explain_concept(
    _context: &dyn AgentContext,
    concept: &str,
) -> Result<ToolOutput, ToolError> {
    let explanation = match concept {
        "tasks" => "Tasks compose typed nodes into explicit workflows.",
        "agents" => "Agents run LLM completions, tools, hooks, and stop conditions.",
        "pipelines" => "Pipelines stream data through indexing and retrieval steps.",
        _ => "Swiftide composes agents, task graphs, tools, and RAG pipelines.",
    };

    Ok(explanation.into())
}

#[tokio::main]
async fn main() -> Result<()> {
    let openai = swiftide::integrations::openai::OpenAI::builder()
        .default_prompt_model("gpt-4o-mini")
        .build()?;

    agents::Agent::builder()
        .llm(&openai)
        .tools([explain_concept()])
        .on_new_message(|_, message| {
            println!("{message}");
            Box::pin(async { Ok(()) })
        })
        .limit(8)
        .build()?
        .query("Explain Swiftide tasks and agents in one paragraph.")
        .await?;

    Ok(())
}

To continue an agent in a new process, you store its message history and rebuild the agent from it (agents_resume.rs):

#![allow(unused)]
fn main() {
// ANCHOR: history
// Let's store the messages in a database, retrieve them back, and start a new agent
let stored_history = serde_json::to_string(&first_agent.history().await?)?;
let retrieved_history: Vec<_> = serde_json::from_str(&stored_history)?;

let restored_context = DefaultContext::default()
    .with_existing_messages(retrieved_history)
    .await?
    .to_owned();
}

That keeps the conversation, not a run in flight: nothing records a tool call that was running when the process died. Task graphs can pause and resume, but only inside the same process; we found no serialization of task state. There is no spend cap; .limit(8) above caps the agent's loops, and usage is reported as metrics (usage_metrics.rs).

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

Swiftide 0.34.0Troupekit 0.4
DurabilityStore and reload the message history yourself; task graphs resume in the same process onlyCheckpoint 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; a loop limit and usage metricsUSD per call, per run and per period, when you set them; checked before each call
Tracingtracing spans and a Langfuse layer (README)Own tracer, JSONL and an HTML viewer
EvalsExports a Ragas dataset for retrieval; scoring happens in Ragas (ragas.rs)Evals on the persona, checked on every run
Offline and on-deviceOllama; fastembed runs embeddings and reranking in process, not a chat 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 Swiftide is better

Indexing. Its streaming pipelines chunk code with tree-sitter and write to Qdrant, Redis, LanceDB, PgVector, DuckDB and Redb (README), and it ships MCP toolboxes and per-tool approval with ApprovalRequired today. Troupekit has no external vector store until 2.0, and pauses for a person at a workflow's human node rather than per tool.

Where troupekit is different

With Storage::sqlite checkpoints, a killed run continues in a new process from its last step without code of yours, and a USD cap you set is checked before every model call. The chat model itself can run on the device.