Skip to main content

Step-level semantic fault isolation for multi-step LLM pipelines. CASCADE analysis. Framework-agnostic.

Project description

chain-probe

Step-level semantic fault isolation for multi-step LLM pipelines.

Your 4-step LLM pipeline failed. Which step caused it? Existing tools (Langfuse, Arize, Promptfoo) trace metadata or evaluate final output — none do step-level semantic fault isolation. chain-probe does.

pip install chain-probe

Quick Start

from chain_probe import Pipeline

pipeline = Pipeline("my_rag_pipeline")

@pipeline.probe()
def retrieve(query):
    return search_documents(query)

@pipeline.probe(
    validator=lambda inp, out: (0.9, "ok") if not hallucinated(out) else (0.1, "hallucinated"),
    threshold=0.5,
)
def generate(docs):
    return call_llm(docs)

@pipeline.probe()
def format(answer):
    return format_response(answer)

result = pipeline.cascade(initial_input="What is our refund policy?")

print(result.summary())
# Pipeline: my_rag_pipeline
# Verdict: FAILED
# Steps: 3 total, 1 failed
# Root cause: step 1 (generate)
#
#   ✓ [0] retrieve: pass
#   ✗ [1] generate: fail [root_cause] score=0.10
#       reason: hallucinated
#   ✓ [2] format: pass

CASCADE Fault Analysis

The key innovation: when multiple steps fail, chain-probe distinguishes root cause from inherited failure.

  • ROOT_CAUSE — This step introduced the failure
  • INHERITED — This step failed because it received bad input from an upstream failure
  • INDEPENDENT — This step failed for its own reasons, unrelated to upstream failures
result = pipeline.cascade(initial_input="test")

for step in result.steps:
    if step.verdict != "pass":
        print(f"Step {step.step_name}: {step.fault_type.value}")
        # "retrieve: root_cause"
        # "generate: inherited"
        # "format: inherited"

Features

  • @probe decorator — Zero-config step registration
  • CASCADE analysis — Automatic root cause vs inherited fault classification
  • Validators — Per-step semantic validation with score + reason
  • Framework-agnostic — Works with LangChain, LlamaIndex, raw API calls, anything
  • Zero dependencies — Pure Python, nothing to install
  • SQLite history — Track cascade results over time
  • CI gate — Exit code 0/1 for pipeline health

Convenience API

from chain_probe import run_cascade

result = run_cascade(
    steps=[retrieve, generate, format, deliver],
    initial_input="user query",
    pipeline_name="rag_v2",
)

if not result.passed:
    print(f"Root cause: {result.root_cause.step_name}")

Store & History

from chain_probe import ProbeStore

store = ProbeStore("pipeline_runs.db")
store.save(result)

history = store.get_history("my_pipeline", limit=10)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chain_probe-0.1.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chain_probe-0.1.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file chain_probe-0.1.0.tar.gz.

File metadata

  • Download URL: chain_probe-0.1.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for chain_probe-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dd6fb9ccee87783322063bc9119635ac17152cf35ee3c630a198d037fefbf660
MD5 0f34fc7ed83d1d8e4d06525ad9d241b3
BLAKE2b-256 dfb4b52f2424500323acff13a7d983b9f7f543313a50a62342a74d5445b5c866

See more details on using hashes here.

File details

Details for the file chain_probe-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: chain_probe-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for chain_probe-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f57062cd9b730827b77e4cdcc31e98157b2579a2262dd3373adc1545bf59971
MD5 587c7d81697b3e79685ba337abcd1b2a
BLAKE2b-256 2b4144f70b61de45e964c0ed008abdbf1889ef6445efc7a5b0dec0044779a499

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page