PyPI version Python versions License: BSL 1.1 CI

SourceryKit is the Python SDK for Provably. It provides verifiable guardrails for AI agents by automatically recording outbound HTTP calls, enforcing endpoint policies, and checking your agent's claims against a source of truth—all before any request leaves your process.

⚠️ IMPORTANT: Upgrading from a previous version? See the Migration Guides.

Features

  • Verifiable guardrails — checks your agent's claims against recorded ground truth, so a hallucinated value is caught before it ships.
  • Automatic HTTP interception — records every outbound call (httpx, aiohttp, requests) with no changes to your agent code.
  • Endpoint allow-listing — blocks requests to untrusted destinations at the source.
  • Deterministic verdicts — every run resolves to PASS, CAUGHT, or ERROR against cryptographically anchored records.
  • Framework-agnostic — drops into OpenAI Agents SDK, LangChain, Claude Agent SDK, CrewAI, and LangGraph.

Under the hood, these are the pieces doing the work:

  • HTTP Interceptor: Patches your HTTP libraries to watch and log outbound calls, blocking untrusted requests on the spot.
  • Trusted Endpoints: A database allow-list of approved destinations for your agent.
  • Intercepts Table: An append-only DB table that logs every request and response for auditing.
  • SourceryKitAgentResponse: A Pydantic model used as the structured response_format for your agent. Enforces a typed response contract with a claimed_values list of extracted values.
  • Handoff Payload: A clean data bundle containing the claims your agent is making about its external actions.
  • Evaluator: Compares the handoff payload against records in the Provably backend to give you a clear verdict.
  • Provably Backend: The source of truth that turns your local intercepts into anchored verification proofs.

Quickstart

Requires Python 3.12+.

pip install sourcerykit
sourcerykit init          # one-time setup: account, database, credentials

Prefer installing from source?

git clone [email protected]:ProvablyAI/sourcerykit.git
pip install -e ./sourcerykit

Give your agent SourceryKitAgentResponse as its output type, run it inside an intercept context, then check the verdict before you trust its claims:

import uuid
import httpx
import sourcerykit
from agents import Agent, Runner
from sourcerykit import SourceryKitAgentResponse

async def run_verifiable_agent():
    # 1. Fire up the system
    await sourcerykit.bootstrap_system()

    # 2. Tell the registry which URL is allowed
    await sourcerykit.insert_trusted_endpoint(url="https://api.example.com/data")

    # 3. Make a network call inside an intercept context
    async with sourcerykit.async_intercept_context(agent_id="demo-agent", action_name="get_data"):
        async with httpx.AsyncClient() as client:
            response = await client.get(
                "https://api.example.com/data",
                params={"query": "example_parameter"}
            )
            response.raise_for_status()

    # 4. Run agent with SourceryKitAgentResponse as the output format
    #    (e.g., output_type=... for OpenAI, response_format=... for LangChain, output_format=... for Claude).
    #    The output is a structured response containing `claimed_values`.
    prompt = "You are a helpful assistant."
    agent = Agent(
        name="demo-agent",
        instructions=prompt,
        tools=[...],
        model="model-name",
        output_type=SourceryKitAgentResponse,
    )
    result = await Runner.run(agent, prompt)
    final_output: SourceryKitAgentResponse = result.final_output

    # 5. Build the handoff payload from the agent's structured output
    payload_data = {
        "answer": final_output.answer,
        "claims": [
            {
                "action_name": "get_data",
                "claimed_value": final_output.claimed_values,
                "verification_mode": "field_extraction",
            }
        ],
    }

    payload = await sourcerykit.build_handoff_payload(
        payload_data,
        run_id=uuid.uuid4(),
        prompt=prompt,
        intercept_agent_id="demo-agent",
    )

    # 6. Ask the evaluator for a verdict
    result = await sourcerykit.evaluate_handoff(payload=payload)
    print(f"Evaluation Outcome: {result.get('outcome')}") # PASS, CAUGHT, or ERROR

Configuration

To get things running, SourceryKit must be configured with your project variables. The interactive CLI handles account provisioning, organization workspace initialization, database validation, and persists credentials globally (OS application folder) and locally (project .env).

sourcerykit init

The wizard will guide you through:

  • Account Setup & Authorization: Create a new account or log into an existing one, and select your organization workspace.
  • API Key Generation: Automatically fetch your SDK API-KEY from your account profile.
  • Database Handshake: Enter your database details, test the connection, and ensure it's accessible.
  • Save Config: Automatically write your credentials and tokens straight to a local .env file.

⚠️ IMPORTANT: The wizard only configures SOURCERYKIT_* variables. It does not handle third-party LLM provider infrastructure keys, which must still be exported separately.

Manual configuration (fallback)

Already have credentials, or need to bypass the wizard (CI, containers, debugging)? Environment variables override the stored config:

export PROVABLY_API_KEY="..."
export SOURCERYKIT_ORG_ID="..."
export SOURCERYKIT_POSTGRES_URL="postgresql://user:password@host:5432/db"

For a full list of CLI commands, check out the CLI Documentation file, or simply run:

sourcerykit --help

For a full list of environment variables, see .env.example.

More Docs

Want to dig into the details? Check out our documentation and specific guides:

Technical Guides

Contributing

We welcome fixes, features, and doc updates! Check out CONTRIBUTING.md to see how to run tests and open up a pull request.

License

This project is licensed under the Business Source License 1.1.

  • Copyright © 2026 Provably Technologies LTD
  • You may not offer the Software as a commercial hosted service without purchasing a commercial license from Provably Technologies Ltd.
  • On 2029-05-07, the license will automatically convert to GPL-3.0-or-later.

See the LICENSE file for full terms and details.