senno
senno — Italian for wits, judgment, good sense. In Orlando Furioso, when Orlando loses his senno, it is found stored in a jar on the Moon. Yours lives in this crate. And il senno di poi — hindsight — is exactly what an agent engine should give you about every response it produced.
Wits for your backend: a provider-agnostic LLM client and streaming tool-calling agent engine for Rust services — Vertex AI first (Gemini and Claude on Vertex), with built-in conversation history compaction and an axum-ready SSE adapter.
Extracted from arche, where it powered production agents; arche ≥ 5.0 depends on senno being your LLM layer instead of shipping its own.
Features
| Feature flag | What you get |
|---|---|
| (default) | Canonical LLM types, LlmProvider trait, one_shot, the full agent engine + compaction. No HTTP client in the tree. |
vertex |
VertexClient: Gemini + Anthropic (Claude) on Vertex AI. API-key auth (Gemini) or service-account auth (both), token caching, streaming SSE parsing, Gemini thinking-model thoughtSignature handling. |
axum |
agent::to_sse_event — map agent events straight into axum::response::sse. |
Quick start
One-shot prompt (Gemini via API key)
use ;
use ;
// Auth resolved from VERTEX_API_KEY / GEMINI_API_KEY env.
let client = get_vertex_client.await?;
let resp = one_shot
.await?;
println!;
Claude on Vertex (service account)
use ;
let client = get_vertex_client
.await?;
Typed output via tool calling
use ;
let tool = new.with_parameters;
let req = one_shot.with_tools;
let verdict: Verdict = one_shot.await?.parse?;
A streaming agent with compaction
use ;
let engine = get_agent_engine
.with_default_summarizer;
// In an axum handler (feature = "axum"):
// let stream = engine.run(&flow, &mut session, &user_message);
// Sse::new(stream.map(|e| e.map(senno::agent::to_sse_event)))
Implement senno::agent::AgentFlow to define your system prompt, tool
definitions, and tool execution. The engine handles the streaming loop, tool
rounds, session state, and — when history exceeds your configured limit —
compacts older turns into an LLM-written summary at a safe message boundary
(tool-call/result pairs are never split; on compactor failure it degrades to
plain truncation).
Errors
Everything returns senno::Error — a small enum (Provider, BadResponse,
Config, Tool, Internal) with is_retryable() for transient upstream
failures. Convert at your application boundary, e.g.:
Vertex auth resolution
| Method | Models | Configuration |
|---|---|---|
| API key | Gemini only | VertexConfig::with_api_key(...) or VERTEX_API_KEY / GEMINI_API_KEY env |
| Service account | Gemini + Anthropic | with_service_account_key(ServiceAccountKey) or with_service_account_key_path(...), plus VERTEX_PROJECT_ID (+ optional VERTEX_REGION, default asia-south1) |
senno does not auto-resolve GOOGLE_APPLICATION_CREDENTIALS; pass the key
explicitly. TokenSource::metadata is available for GCE/Cloud Run
metadata-server auth if you wire it yourself.
Toolchain
Pinned via rust-toolchain.toml (Rust 1.97.0, edition 2024).
License
MIT