Skip to main content

Sufficiency Engine logo

Sufficiency Engine

CI Documentation PyPI Downloads Python 3.12 | 3.13 | 3.14 | 3.15 Coverage 100% Typed License: Apache 2.0

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.

Sufficiency Engine architecture

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.

Downloads

Total downloads Downloads this week Downloads this month Downloads this year

Downloads by year Top download countries

The counts are fetched live from the ClickHouse public PyPI dataset each time the badges load. The dataset refreshes daily and badge images are cached for up to an hour. Weeks start on Monday (UTC). Daily, monthly, version, and country charts are on the ClickPy dashboard.

Examples

Complete programs in examples/:

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.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sufficiency-engine 1.0.2
File Size Uploaded Provenance Actions
sufficiency_engine-1.0.2.tar.gz 991.7 kB Without provenance Details for sufficiency_engine-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sufficiency-engine 1.0.2
File Interpreter ABI Platform Actions
sufficiency_engine-1.0.2-py3-none-any.whl Python 3 none any Details for sufficiency_engine-1.0.2-py3-none-any.whl

Total release size: 1.0 MB

Release files / sufficiency_engine-1.0.2.tar.gz

Download URL sufficiency_engine-1.0.2.tar.gz
Size 991.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8be56dcd7be127e004d5402942c640057a39de6c17b1ee4e9c31b4ab9c6fc53b
BLAKE2b-256 checksum
How to use checksums
b076b1490ff73e23bdb59909713c22f964d0d9ab550205b394f336066e4159a9
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.2-py3-none-any.whl

Download URL sufficiency_engine-1.0.2-py3-none-any.whl
Size 48.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1003f4f8393470fa47a8808da5817a041b030892865ff4d0e376aaf51da4369f
BLAKE2b-256 checksum
How to use checksums
c8c14ec48f803fcde93cd2d77cfede41974008f1d4519443959015497c699b4c
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.2

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page