Decision systems you can check. You describe what to compute with plain Python functions and checks; a model — an LLM, your own classifier or a small local one — proposes where judgement is needed; solvi's checks decide. Every answer comes with a confidence, a reason you can check (the rule's inputs, a formula over computed facts, or a quote with character offsets in the source) and a hash-chained trace that can be re-executed later to confirm the answer or pinpoint the step that was altered. When something cannot be computed or checked, solvi abstains or hands the case to a person instead of guessing; a failed hard check always overrides any model's confidence.
solvi 1.0 has two levels. Ready systems you configure: solvi.build (decisions from labelled examples, with a promise on the errors), solvi.Agent (acting in an environment), solvi.Guard (an agent's tool calls) and solvi.Knowledge (what they know, and from whom). Building blocks in solvi.core, which the ready systems are made of, each replaceable by a part of your own. What works but has no measured gain yet is kept apart in solvi.experimental.
pip install solvi # core: rules, checks, learned answer heads, build / Agent / Guard (numpy, scipy, pydantic) pip install "solvi[model]" # + torch, transformers: ModernBERT field extractors for documents and the decider pip install "solvi[onnx]" # + onnxruntime, tokenizers: the decider (solvi.models.decider) on CPU without torch pip install "solvi[serve]" # + fastapi, uvicorn: `solvi serve app.py:system` — the questions over HTTP (also --mcp) pip install "solvi[mcp]" # + the official MCP SDK for solvi serve --mcp (without it, a built-in stdio server) pip install "solvi[duckdb]" # + duckdb: stored decisions in a DuckDB file (solvi.core.store.DuckDBStorage); [postgres] for PostgreSQL pip install "solvi[lora]" # + torch, transformers, peft: solvi.experimental.lora.adapt_lora, a LoRA adapter per question (experimental) Requires Python 3.11+ (tested on 3.11–3.14). Coming from 0.9: see below.
Give the question, labelled examples and the promise — and a slow path if you have one. solvi.build fits System 1, calibrates its guarantee and who answers what it hands over on examples it did not see, stores every decision, and says what it chose:
import solvi from solvi.models import llm s = solvi.build(question, examples, catalog=cat, max_risk=0.02, # examples: [(state, correct answer)] slow=llm(URL, "openai/gpt-oss-120b"), price=(0.037, 0.17), storage="decisions.jsonl") res = s.ask(state) # res.answer, res.by ("s1", "s2" or "human"), res.reasons, res.cost print(s.explain()) # System 1, its signal and promise, who answers each slice, what is not covered On four tasks of the stand (Banking77, Abt-Buy, CUAD, RAGTruth) the defaults matched or beat the hand-written setups with every promise kept on eval, in a quarter to half of the code — closer to the promised level than the hand-written ones, and the slow path was rarely given anything (guide, examples/24_one_entry_point.py).
km = solvi.Knowledge("knowledge.jsonl", vocabulary={"here": lambda s, a: s["here"], "wood": lambda s, a: s["wood"]}) km.goal("table", done=lambda s: s["table"]) # an agenda goal: done is code agent = solvi.Agent(env, knowledge=km) # env: reset(seed), actions(state), step(action) → Outcome agent.run(seed=7, steps=150) # explore; the same world again needs fewer slow decisions agent.replay() # every decision re-checked from what it was given solvi.Knowledge keeps what a system learned and from whom: facts with their sources (never the system's own answers), goals and gates, an action model learned from outcomes; a retraction takes back everything derived from the item. solvi.Agent acts on it: System 1 where the knowledge predicts the action works, a search where it does not, gates and predicted refusals as hard checks — protection by default, justified risk (RiskBudget) as an option. In the toy crafting world of examples/25_environment_agent.py the first run takes 61 steps, all decided by System 2, and the same world met again 12 steps, 11 of them by System 1. Growth was shown in environments met again, not on decision streams or a support agent with tools; justified risk lowers the cost of protection without promising parity (docs/agent.md). solvi.build(..., knowledge=km) and solvi.Guard(..., knowledge=km) read the same knowledge.
The agent proposes {"name": tool, "arguments": {...}}; solvi.Guard checks it — the tool is in the catalog, the arguments validate against its types, the values that must come from the conversation are quoted there (and not only from a tool output that says "ignore previous instructions"), your policies (limits, roles, allow-lists) are ordinary hard checks, and an optional decider asks "did the user ask for this?" under act_guard and perturb — then allows it (solvi runs the function), denies it with the reasons, or escalates it to a person. Every decision is a stored, replayable trace; any framework's tool calls go through guard.check / guard.call (guide, examples/19_agent_guard.py). On τ-bench retail no call it let through was refused by the environment, at a cost in solved tasks (the τ-bench row of the task table).
Types declare questions; a model proposes; checks decide. The fields of a pydantic model are the questions, their types the kinds (one option, several, an ordered score, yes/no); a decider answers them about a text or a JSON / pydantic state with probabilities, a calibrated confidence and act / escalate, and hard checks, constraints and rules still decide. The decider is whichever model you have:
import os from typing import Literal from pydantic import BaseModel, Field from solvi import Catalog, Scale, System from solvi.models import llm class Triage(BaseModel): team: Literal["billing", "technical", "shipping"] = Field(description="Which team should handle this ticket?") urgency: Scale[Literal["low", "medium", "high", "critical"]] = Field(description="How urgent is it?") angry: bool = Field(description="Is the customer angry?") topics: list[Literal["refund", "delay", "bug"]] = Field(description="What does the ticket mention?") model = llm("https://api.openai.com/v1", "gpt-4o-mini", api_key=os.environ["OPENAI_API_KEY"]) # offline: model = solvi.models.decider("solvi-base") — the same questions, the same checks cat = Catalog() questions = model.questions(cat, Triage, text_fact="ticket", min_confidence=0.6) @cat.check(hard=True, then={"urgency": "critical"}) # a legal threat is critical, whatever the model says def no_legal_threat(ticket) -> bool: return "lawyer" not in str(ticket).lower() questions[1].requires.append("no_legal_threat") res = System(cat, questions).ask({"ticket": {"subject": "Charged twice", "body": "Refund my double payment!", "customer": {"tier": "pro"}}}) print({q: (r.answer, r.status) for q, r in res.results.items()}) print(res.audit("team")) # the probabilities, the model's fingerprint, what escalated and why A state is read as key paths (customer.tier: pro); an unsure or escalated answer abstains with the reason (system.stats["model_escalated"], ["low_confidence"]). examples/15_typed_decisions.py runs the whole story with a stand-in model, without network. Whatever the model, read what it was measured on before relying on it, and calibrate it on your own labelled stream (part.act_guard, under Building blocks): checks, constraints and escalation are what make the answers safe to act on, not the model alone. The checkpoint contract of a local decider is in docs/decide_format.md; a local checkpoint answers one question per forward pass with the published checkpoints, several with DecideModel.load(..., multi_question=True).
Every answer is a value and a confidence, and the types also declare answer primitives: Maybe[T] ("not stated" — solvi.Unknown — is a real answer, unlike an abstention), Span[float] (an exact piece of the text, parsed), Rank[...] (the top k, in order), Estimate[0, 7, 14] (a number with an interval), and evidence quotes on any answer (Claim(value, evidence=[...]), Question(require_evidence=True)) — each checked in the text, from rules or a model (guide, examples/16_primitives.py).
The ready systems are assembled from these; you can use them directly, and put a part of your own at every extension point (a store, a slow path, a strategist, a head, a decider, an action model, ...). docs/building_blocks.md has one reference per protocol, with a conformance check for each.
from datetime import date from solvi import Answer, Catalog, Question, System cat = Catalog() @cat.fn # argument names = facts it reads; function name = fact it sets def days_requested(start, end): return (end - start).days + 1 @cat.fn def remaining_after(balance, days_requested): return balance - days_requested @cat.check(hard=True, then={"approve": "reject"}) # if this check is False, "approve" is forced to "reject" def enough_balance(remaining_after): return remaining_after >= 0 @cat.check def enough_notice(start, today, days_requested): return days_requested = 14 @cat.rule("approve") def approve(enough_notice): return "approve" if enough_notice else "needs_manager" system = System(cat, [Question("approve", "Approve the leave?", Answer.choice(["approve", "needs_manager", "reject"]), requires=["enough_balance"])]) res = system.ask({"start": date(2026, 10, 19), "end": date(2026, 10, 23), "today": date(2026, 9, 25), "balance": 14}) print(res["approve"].answer, res["approve"].confidence, res["approve"].why) print(res.state_text()) print(res.trace.replay(system)) Output:
approve 1.0 enough_notice = True days_requested = 5 remaining_after = 9 enough_balance = True enough_notice = True {'ok': True, 'steps': 5, 'mismatches': [], 'models': [], 'answers': 'same', 'catalog': 'same'} With "balance": 3 the hard check fails and the answer is reject with status == "forced", whatever the rule says. solvi.show.show(res, cat) prints answers, the planned flow, the computed state and the replay result in one go.
Grounded decisions. Fuzzy proposes, deterministic decides, everything is in the trace. Each fact and answer records its provenance — given, computed, quoted, decided (a model's choice among options, with probabilities) or learned — and model-backed steps record the model's id and fingerprint, so a replay can tell when the model changed since a decision. A model's quote that is not literally the text at its offsets, or a choice outside its options, is rejected and counted (system.stats); a fallback producer runs or the question abstains. print(res.audit()) shows what each answer rests on, which safeguards fired, and how much of its support is deterministic. A decision without models and one with models are the same system (examples/12_grounded_audit.py).
A System under a guarantee is fast, cheap and knows when it is unsure: that is System 1. An LLM, a re-ask loop or a search is slow and costs money per input: System 2. solvi.build and solvi.Agent put them in one system; underneath:
The default strategist needs the inputs of every producer of a fact. solvi.core.plan.cost.CostStrategist() plans around producers whose inputs are never given, and with producers="equivalent" picks the cheapest verified plan by declared cost= (an exact 0/1 program; hard checks that govern a question always stay in the plan). No model is involved; the plan is one hashed record in the trace and replay re-verifies it.
from solvi.core.plan.cost import CostStrategist system = System(cat, questions, strategist=CostStrategist(producers="equivalent")) See docs/strategist.md and examples/17_cost_strategist.py.
With solvi[model], fields are found by a fine-tuned ModernBERT extractor. The extracted value is always a span of the document, so every answer built on it can be cited.
from solvi.core.extract import LongSpanExtractor ex = LongSpanExtractor.load("solvi-ai/extract-base") # a field is a description; long texts in 1024-token windows ex.fit([(text, "the total amount paid", (start, end)), ...], epochs=3) # a few dozen labeled documents of your task ex.save("my-extractor") cat.extract(ex.field("total", "the total amount paid")) # doc -> Quote(text, start, end, confidence), or no answer cat.extract(ex.field("date", "the date of the purchase")) @cat.fn def amount(total): # extracted values are strings; parse them in ordinary functions return float(total.replace(",", "")) LongSpanExtractor reads the whole text in overlapping windows and supports "no answer" with a per-field threshold (ex.tune_threshold(name, held_out)). What the published solvi-ai/extract-base does without labels of your task, from its model card (held-out fields and data sets, one seed): CORD receipt fields it was never trained on, 46.5% and 67.9%; five never-trained CUAD clause types, 73.1%; Kleister-NDA and SROIE, never seen, 2–95% by field (addresses 2%). With per-field thresholds from 40 labeled contracts it reached 85.5% on CUAD; fine-tuned on 25–100 SROIE receipts, 86–89%. So describing a field is a start, not a finished extractor: label 25–100 documents and fine-tune. The receipt numbers below are a LongSpanExtractor too: solvi-ai/extract-receipts is extract-base fine-tuned on CORD and loads with LongSpanExtractor.load("solvi-ai/extract-receipts") (its card says so; examples/07_receipts_model.py uses it). See docs/guide.md.
Pieces that work and are tested but have not yet shown a measured gain. Importing one warns (ExperimentalWarning), a decision that used one records it, and each one graduates or is removed by 1.2; solvi.experimental.STATUS and docs/experimental.md say what each is missing.
Every 0.9 import path still works in 1.0.x: it imports the same module and warns (SolviDeprecationWarning) with the path to use; 1.1 removes the old paths. solvi migrate PATH rewrites your code (imports and dotted paths in strings, in .py and .md files); solvi migrate PATH --check only reports. Stored decisions, calibration files and fingerprints do not change. The full table and what was removed: CHANGELOG.md.
solvi init triage --with-model && cd triage # a typed catalog, passing cases.json, README, CI workflow solvi test . && solvi check catalog.py:system # regression cases and the catalog lint (what CI runs) solvi ask catalog.py:system example.json --audit # one decision and what it rests on (--json, --report html) solvi models pull solvi-ai/solvi-base # a local decider for offline use; `solvi models` lists, `check` measures solvi calibrate catalog.py:system route labels.csv --risk 0.1 # act_guard → route.calib.json, loaded by the catalog solvi hook install # (experimental) Claude Code's edits checked against .claude/solvi-rules.toml solvi migrate src/ --check # code still on the 0.9 import paths (without --check: rewrite it) Every command is in the guide.
Every number in this README comes from a script in benchmarks/ or from a published model card. Field extraction: the extract-receipts card reports 97.3% on typed questions over CORD receipts (100 test receipts) with ECE 0.011 and 98.6% of questions answered at ≥ 99% precision, and the extract-base card its zero-shot and few-label numbers; the decision models' cards (solvi-base, solvi-large) theirs. On the gallery, the rules, quotes and checks are the answer: every answer is backed by a quote at stated offsets, a computed fact, or the system abstains. Details: docs/benchmarks.md.
Real tasks on public data, each with a baseline that does not use solvi and one solution with solvi, chosen on dev and scored on a held-out split (benchmarks/tasks/, solvi 0.8.0, gpt-oss-120b where an LLM is used):
solvi does not make a model more accurate: on RAGTruth, BIRD, τ-bench and NAB it did not beat the baseline. What it added is the promise on what is answered alone, consistency across items, a search where a model guessed, and a stored, replayable record of every decision. German Credit (rules and an audit of a rule change) decides exactly as plain code does and adds the audit. Every number, its caveats and the cost of a run: benchmarks/tasks/README.md.
We gave the same inputs and written rules to solvi and to four LLMs: Grok 4.7, gpt-oss-120b, Qwen3-235B-2507 and DeepSeek-V3.2. The sets were the gallery, generated refund and 3-way-match cases built to trip models up, and Banking77 message routing. Strong reasoning LLMs followed short written rules as accurately as solvi. solvi was not more accurate there. What differs is everything around accuracy:
Inside solvi, no LLM broke a hard check, and wrong answers given without a person stayed within the promised 10%. On free text the LLMs win: 0.925-0.972 on bank messages against 0.675 for solvi-large. A hosted decision model, Jev by TypeSafe, read bank messages almost as well as the best LLM (0.964) but scored 0.819 on refunds with 53 limit violations; inside solvi it broke no hard check either. An open one that reasons first, Jeeves by PostHog, came closer on the rules (0.863 on refunds, 0.912 on 3-way match) but still broke hard checks when asked directly. Full tables, caveats and a reproducible runner with every raw answer: docs/vs_llm.md, benchmarks/vs_llm/.
One ask without a model (benchmarks/ask_speed.py: planning, running the parts and hashing the trace; Python 3.10, Intel i7-12700H shared with other jobs, medians of three runs of 15 passes):
A large input costs its hashing: every given value is written as canonical JSON and hashed once per ask (about 0.25 µs per float). The slowest gallery entry checks its texts for instruction-like sentences (perturb), which takes most of its time. Saving each response to a store adds its own cost (the whole response is written as JSON).
Strategist on random layered catalogs (benchmarks/strategist_scale.py, one CPU core; solvi 0.7.1 with the changes since, Python 3.10, Intel i7-12700H, medians of two runs). The parts are trivial arithmetic: running all of them ("run all") costs less than one ask, so the saving shows only when parts are slow (services, models), as in the insurance desk below.
Insurance claim desk with six slow services of 100-300 ms (examples/09_strategy_at_scale.py):
A rule-only decision on a small catalog takes well under a millisecond (benchmarks/ask_speed.py); on documents the extractor dominates.
gallery/ — fifteen decision tasks across directions (support triage, email routing, content guard, security alerts, AI-agent audit, release rollout, KYC/AML, clinical screening, credit with adverse-action reasons, procurement 3-way match, double-charge refunds, predictive maintenance), each with scenarios, a runner and a side-by-side against an answer-only model. Three are helpers for coding agents: a pre-edit rule check (allow / block / escalate a file write), review triage (quick review only when seven risk questions are a confident "no", with a stated bound on risky changes that slip through) and a skill picker with an honest "none".
Run them from a clone: python examples/01_leave_request.py.
A paper is in preparation. Until then, please cite the repository:




