Sufficiency Engine
Decide whether a task has enough information to proceed, before your agent starts work.
Sufficiency Engine finds the requirements a task depends on, asks only the questions that matter, and records every readiness decision with AGXAI provenance. It works with any model through one callback, and with LangGraph or any other framework.
Why Sufficiency Engine
A user asks an agent to deploy a service but names no platform. Today the usual outcomes fall short:
- The agent guesses. It picks a platform, and the mistake surfaces only after the work is done.
- The agent asks too much. A string of loosely related questions, some already answered in the task, wears the user down.
- The model decides alone. Whether a task is ready rests on a model's judgment, with no rule an engineer can test.
- Nobody can say why. When a task proceeds on missing information, there is no record of what was known and what was decided.
How Sufficiency Engine addresses each one:
| Problem | What Sufficiency Engine does |
|---|---|
| Agents guess | Blocks the task until every required piece of information is supplied, answered, or covered by an approved assumption |
| Too many questions | Asks only for blocking information, combines and deduplicates questions, and never repeats a declined one |
| The model decides alone | The model proposes requirements; deterministic Python policy decides what blocks |
| No record of why | Records the evidence and every readiness decision through AGXAI; a failed audit is a failed assessment |
Sufficiency Engine decides readiness only. Your application keeps the model, the conversation, the workflow, and the task itself.
Highlights
- Evidence, not guesses. A requirement counts as available only when the model quotes the task or an accepted answer for it. Unsupported quotes are rejected.
- Only the questions that matter. Zero questions is a valid outcome. Answers are validated against typed constraints, and an invalid answer gets a targeted follow-up.
- Audited with AGXAI. Every terminal outcome records evidence, decisions, and their links, without the raw task or answer text.
- Recoverable by design. Session claims, revisions, and fencing protect concurrent use. An interrupted interaction or audit resumes without rediscovery or replayed side effects.
- Provider- and framework-neutral. Any model, sync or async, through one callback. LangGraph and OpenTelemetry are optional extras; storage and embeddings plug in through abstract base classes.
- Bounded and typed. Input sizes, requirement counts, dependency edges, questions, and iterations are limited by default. The package ships type hints and is tested on Python 3.12 to 3.15.
Installation
pip install sufficiency-engine # core
pip install "sufficiency-engine[langgraph]" # with the LangGraph integration
Or with uv: uv add sufficiency-engine. The core
depends only on AGXAI, Pydantic, and RapidFuzz; it does not install a model
provider.
Optional extras:
| Extra | Adds |
|---|---|
langgraph |
build_assessment_graph, a task-entry node with interrupts and checkpointed resumes |
observability |
OpenTelemetryObserver and AGXAI's OpenTelemetry support |
To call a hosted model, install its client yourself, for example pip install openai; see
OpenAI-compatible models.
Quickstart
A deployment task names no platform. The engine asks one question, reassesses with the answer, and returns an audited result. The model callback is deterministic so the example runs offline; in your application it calls your own model:
import asyncio
import json
from sufficiency_engine import AnswerSubmission, InteractionResponse, SufficiencyEngine
async def model_call(messages):
# Replace with your own model, e.g. `return await chat_model.ainvoke(messages)`.
prior = json.loads(messages[-1]["content"])["prior"]
answered = bool(prior and prior[0]["answers"] == ["Linux"])
return {
"requirements": [
{
"key": "platform",
"description": "Deployment platform",
"classification": "mandatory",
"status": "available" if answered else "unresolved",
"evidence_quote": "Linux" if answered else None,
"necessity": "must_ask",
"reason": "The deployment steps depend on the platform.",
"question": "Which platform should the service be deployed on?",
"answer_type": "string",
}
]
}
async def ask_user(payload):
question = payload.questions[0]
print("Question:", question.text)
return InteractionResponse(
answers=(
AnswerSubmission(
question_id=question.id,
values={question.requirement_ids[0]: "Linux"},
),
)
)
async def main():
engine = SufficiencyEngine(model_call=model_call, interrupt_call=ask_user)
result = await engine.execute(input="Deploy the billing service.")
print("Status:", result.status.value)
print("Sufficient:", result.sufficient)
print("Clarification rounds:", result.iteration_count)
for requirement in result.requirements:
print(f" {requirement.key}: {requirement.status.value}, blocking={requirement.blocking}")
print("Audited decisions:", len(result.provenance.decision_ids))
if __name__ == "__main__":
asyncio.run(main())
Output:
Question: Which platform should the service be deployed on?
Status: sufficient
Sufficient: True
Clarification rounds: 1
platform: available, blocking=False
Audited decisions: 2
Run it with uv run python examples/quickstart.py. The
quickstart guide explains each step.
LangGraph
Add readiness as the entry node of your graph. Questions become LangGraph interrupts, and answers resume from the checkpoint:
from sufficiency_engine.integrations.langgraph import build_assessment_graph
builder.add_node("readiness", build_assessment_graph(engine))
See the LangGraph integration.
Your own storage
Sessions and AGXAI records are kept in memory by default. For recovery across
processes, implement PersistenceABC and SemanticArchiveABC for your
database, and check them with the extension skill's contract checker. See
Use durable storage.
Benchmarks
Library overhead with a deterministic local model and in-memory AGXAI, so model and network time are excluded:
| Scenario | p50 ms | p95 ms |
|---|---|---|
| Audited assessment of a complete task | 16.77 | 21.52 |
| Readiness policy, 256 requirements and 2,012 dependency edges | 10.58 | 15.77 |
| Lexical deduplication of 64 questions | 37.88 | 50.05 |
Measured on one machine; see Benchmarks for the method, duplicate-detection quality, and how to reproduce.
Examples
Complete programs in examples/:
- Quickstart
- Standalone
- Supervisor and workers
- Observability
- BGE-M3 duplicates
- PostgreSQL recovery
- OpenAI-compatible models
Documentation
Two Agent Skills teach coding agents such as
Claude Code, Codex, Cursor, and GitHub Copilot to use Sufficiency Engine
correctly. sufficiency-engine adds readiness checks to your application,
and sufficiency-engine-extend implements durable storage and embedding
models:
npx skills add smuniharish/sufficiency-engine
Sufficiency Engine is stable and follows semantic versioning: only a major release changes the public API incompatibly, and stored sessions are versioned. See Compatibility and the changelog.
Contributing
Contributions are welcome. See CONTRIBUTING.md for the development setup and checks, and SECURITY.md to report a vulnerability.
License
Apache License 2.0. See LICENSE.
Metadata
Release files for sufficiency-engine 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sufficiency_engine-1.0.1.tar.gz | 982.7 kB | Without provenance | Details for sufficiency_engine-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sufficiency_engine-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for sufficiency_engine-1.0.1-py3-none-any.whl |
Total release size: 1.0 MB
Release files / sufficiency_engine-1.0.1.tar.gz
| Download URL | sufficiency_engine-1.0.1.tar.gz |
|---|---|
| Size | 982.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e986d03c89f9df72eddb9de0c3e33c8226e1184fe671231931eb5a189bab0ba7
|
|
BLAKE2b-256 checksum How to use checksums |
ef7640e694e7dfccc05f70956feed1ccd65b628e56290dafc2cc2c5d001abd4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / sufficiency_engine-1.0.1-py3-none-any.whl
| Download URL | sufficiency_engine-1.0.1-py3-none-any.whl |
|---|---|
| Size | 46.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
104f10d5c9c9ce67630e36401f7cfdae0dbf48c3df2bee1b6be26f795786c2e3
|
|
BLAKE2b-256 checksum How to use checksums |
a6792cbdbd1c3b5ce43afb21c938388dc01cf736da113d17394dc0506ba6e336
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for sufficiency-engine 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.