Troupekit and PydanticAI
PydanticAI is the agent framework from the Pydantic team, for Python. We compared release v2.77.0, checked on 2026-11-28. Of the Python frameworks we looked at, it comes closest to troupekit on durability and spend limits, so this page is mostly about how the two get there.
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 PydanticAI
The shortest agent with instructions and one tool in its docs (web.md); the model name is a placeholder their docs build fills in:
from pydantic_ai import Agent
agent = Agent('{{ openai:medium }}', instructions='You are a helpful assistant.')
@agent.tool_plain
def get_weather(city: str) -> str:
return f'The weather in {city} is sunny'
app = agent.to_web()
For a run that survives a kill, PydanticAI hands the run to a durable execution engine. With DBOS, which runs in process and checkpoints into SQLite or Postgres (dbos.md):
from dbos import DBOS, DBOSConfig
from pydantic_ai import Agent
from pydantic_ai.durable_exec.dbos import DBOSDurability
dbos_config: DBOSConfig = {
'name': 'pydantic_dbos_agent',
'system_database_url': 'sqlite:///dbostest.sqlite', # (1)!
}
DBOS(config=dbos_config)
agent = Agent(
'{{ openai:medium }}',
instructions="You're an expert in geography.",
name='geography', # (2)!
capabilities=[DBOSDurability()], # (3)!
)
@DBOS.workflow() # (4)!
async def answer(question: str) -> str:
result = await agent.run(question)
return result.output
The cap is UsageLimits, which has a cost_limit in USD next to token, request and tool-call limits (usage.py).
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
| PydanticAI 2.77.0 | Troupekit 0.4 | |
|---|---|---|
| Durability | Through an engine: Temporal, DBOS, Prefect, Restate and five more (overview.md). DBOS runs in process on SQLite; plain function tools run again on recovery unless wrapped as DBOS steps (dbos.md) | Built in, opt-in with Storage::sqlite: a checkpoint after every step; tools get an idempotency key for replays |
| Spend limits | USD and tokens. Limits are checked after a response has arrived and been billed, so the response that crosses one is kept (agent.md) | USD only, when you set it; checked before each call on an estimate that counts the full max_tokens of output but only approximates input as a quarter of the request's JSON bytes, so a call the estimate says would cross the cap is not made |
| Tracing | OpenTelemetry, with Logfire as an option (logfire.md) | Built-in tracer, JSONL and an HTML viewer |
| Evals | Pydantic Evals, which grades outputs and trajectories (evals.md) | Evals on the persona, checked on every run; an eval harness is planned for 0.7 |
| Offline and on-device | Ollama and other servers (ollama.md); no in-process model, the Outlines integration was removed (migration.md) | llama.cpp in process, Ollama, and a route policy per call |
| Mobile | No iOS or Android docs found | Builds for iOS and Android in CI; Swift and Kotlin bindings since 0.4, built from source |
| Single binary | Needs Python 3.11 or newer (pyproject.toml) | Compiles into your program |
Where PydanticAI is better
It runs durably on nine engines, including Temporal for teams that already operate it, and it has MCP tools, per-tool approval with requires_approval=True and typed structured output today (deferred-tools.md). Its USD cap means money limits are not something only troupekit has.
Where troupekit is different
Durability needs no engine: the checkpoint store is part of the framework. The spend check runs before the call, not after the response is billed. And the model can run inside the same process, in a core that builds for iOS and Android.