Skip to main content

CaseTrace

CI PyPI Python License

A flight recorder for multi-agent AI systems. CaseTrace reads a multi-agent execution trace, builds a deterministic map of agent handoffs and tool dependencies, prunes unreferenced noise, and then asks a structured judge: which agent, at which step, and what kind of error caused this run to fail? It can also answer NO_FAULT on healthy runs and ABSTAIN when the evidence is insufficient.

Status: v0.1.0 (MVP). This release ships the deterministic graph/pruning core, a generic JSONL adapter, a structure-first judge, an all_at_once baseline, metrics, and the offline CLI. Benchmark numbers on Who&When and Who&When Pro are not part of v0.1.0 — see Scope. The project framing is engineering and evaluation quality, not research novelty.

For the plain-language overview see project_overview.md. For the frozen evaluation contract see casetrace_attribution_protocol.md.

Install

Python 3.11+ is required. Install from PyPI:

python -m pip install casetrace

With an optional model provider:

python -m pip install "casetrace[gemini]"
python -m pip install "casetrace[openai]"
python -m pip install "casetrace[anthropic]"

Using uv:

uv tool install casetrace
uv tool install "casetrace[gemini]"

Exact token counting (instead of the built-in estimate) is optional:

python -m pip install "casetrace[tokens]"

Quickstart

The offline demo uses the deterministic stub judge, so it needs no API key and no network:

casetrace demo                 # faulted sample: prints the graph + verdict
casetrace demo --trace clean   # healthy sample: prints NO_FAULT

Run it on your own trace:

casetrace graph path/to/trace.jsonl
casetrace analyze path/to/trace.jsonl --mode structure_first --provider stub

Against a real model:

export GOOGLE_API_KEY="..."
casetrace analyze path/to/trace.jsonl --provider gemini --model gemini-2.5-flash

Append a protocol-shaped JSONL log for later reporting:

casetrace analyze path/to/trace.jsonl --out results/runs.jsonl

From a source clone:

uv sync
uv run casetrace demo
uv run pytest

How it works

trace JSONL ──▶ normalize ──▶ build handoff/tool graph ──▶ prune unreferenced payloads
                                                              │
                                                              ▼
                                                     structured judge ──▶ verdict
                                                                           (agent, step,
                                                                            error_mode,
                                                                            evidence,
                                                                            confidence)
  1. Normalize the trace into a Trajectory with indexed Steps.
  2. Build a deterministic graph: consecutive-agent handoffs, tool-call → tool-result edges, and explicit references between steps.
  3. Prune tool outputs that no later step references, while preserving every step index, agent, status, and causal edge.
  4. Judge the pruned context (or the full context for the all_at_once baseline) and validate the response into a strict Verdict.

The graph and pruning steps never call a model, so casetrace graph is fully reproducible and free.

Trace format

The generic adapter accepts a single JSON object, a JSON array of objects, or JSONL with one object per line:

{
  "id": "trace-001",
  "dataset": "generic_jsonl",
  "steps": [
    {"index": 0, "agent": "planner", "kind": "plan", "content": "Fetch prices, then total."},
    {"index": 1, "agent": "tool_executor", "kind": "tool_call", "tool_name": "http_get"},
    {"index": 2, "agent": "tool_executor", "kind": "tool_result", "tool_name": "http_get", "tool_output": "{...}", "references": [1]},
    {"index": 3, "agent": "verifier", "kind": "verify", "content": "Checked the total.", "references": [2], "status": "error", "error_type": "invalid_tool_argument"}
  ],
  "final_output": "Total: 100 USD",
  "metadata": {"ground_truth": {"is_clean": false, "agent": "verifier", "step": 3, "error_mode": "invalid_tool_argument"}}
}

references is optional but is what lets the graph recover causal edges from a flat log. metadata.ground_truth is only read by the offline stub and by metric scoring; a real judge never sees it.

CLI reference

Command What it does
casetrace graph TRACE [--json] [--max-chars N] Print the handoff/tool graph and pruning savings. No LLM call.
casetrace analyze TRACE [--mode structure_first|all_at_once] [--provider stub|gemini|openai|anthropic] [--model ID] [--out FILE] [--json] Attribute one trace and optionally append a JSONL run log.
casetrace demo [--trace fault|clean] [--json] Run the bundled offline samples with the stub judge.
casetrace version Print the installed version.

--provider stub is the default and is deterministic. Real providers are experimental in v0.1.0 and are not exercised by CI.

Run log

--out appends one JSON line per run, matching section 5 of the frozen protocol (run_id, dataset, config, model, trace_*, ground_truth, prediction, metrics, systems_cost). Metrics include agent match, exact and within-1 step match, error-mode match, joint match, false alarm, and abstention.

Scope of v0.1.0

Included:

  • Deterministic handoff/tool-dependency graph and token-budgeted pruning.
  • Generic JSONL/JSON adapter.
  • structure_first judge and all_at_once baseline.
  • Offline stub judge, optional Gemini/OpenAI/Anthropic providers.
  • Metrics and protocol-shaped run logs.
  • graph, analyze, demo, version CLI commands.

Deferred to later releases:

  • Who&When v1 and Who&When Pro adapters and benchmark reproduction.
  • casetrace eval and casetrace report table generation.
  • Controlled fault-injected + clean evaluation suite.
  • Calibrated abstention and split-conformal ablation.
  • binary_search and step_by_step baselines.

Limitations

  • The stub judge is not a real judge. It reads an explicit error flag, then a clean-run marker, and otherwise abstains. It exists for offline demos and tests, never as an evaluation baseline.
  • Token counts are estimates (~4 characters/token) unless the optional [tokens] extra is installed. README and CLI output label them as token counts, not exact tokenizer totals, unless tiktoken is active.
  • No benchmark numbers in v0.1.0. Published Who&When/Pro results are planned; none are claimed here.
  • Real providers are experimental. They share one JSON-parsing path and are not run in CI because that would require live keys and network access.
  • No calibrated abstention yet. ABSTAIN is a valid verdict but its confidence threshold is not calibrated on a dev split in this release.
  • Best-effort generic adapter only; framework-specific adapters (OpenTelemetry, LangGraph) are planned.

Prior art

CaseTrace is an applied engineering and evaluation toolkit, not a novel method. It builds on and must credit: Who&When, Who&When Pro, FALAT, FAMAS, TraceElephant, Aegis, AgenTracer, AgentDebugX, and conformal agent error attribution work.

Development

uv sync
uv run ruff check .
uv run mypy src
uv run pytest
uv run casetrace demo
uv run casetrace graph examples/sample_fault_trace.jsonl

CI runs lint, strict type checking, a dependency audit, tests, and an offline smoke test on Python 3.11 and 3.13. Releases are published to PyPI from a protected environment using PyPI Trusted Publishing with PEP 740 attestations; no token is stored in the repository.

License

Apache-2.0. See LICENSE.

Metadata

Release files for casetrace 0.1.0

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

Source distribution (sdist)

Source distribution for casetrace 0.1.0
File Size Uploaded Provenance Actions
casetrace-0.1.0.tar.gz 173.8 kB With provenance Details for casetrace-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for casetrace 0.1.0
File Interpreter ABI Platform Actions
casetrace-0.1.0-py3-none-any.whl Python 3 none any Details for casetrace-0.1.0-py3-none-any.whl

Total release size: 205.8 kB

Release files / casetrace-0.1.0.tar.gz

Download URL casetrace-0.1.0.tar.gz
Size 173.8 kB
Tags Source
SHA-256 checksum
How to use checksums
dd4cb06920b693393882dd36a0a5bf63db4c8b51302e77bcc784b7a720f43bfa
BLAKE2b-256 checksum
How to use checksums
4347496b1f717784219e6ea3752e969fb93bad3967b3bb018e627243cfdb6a80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.

Transparency log

Release files / casetrace-0.1.0-py3-none-any.whl

Download URL casetrace-0.1.0-py3-none-any.whl
Size 32.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
995eb3b93c09c63d8d8990959f5b3f15673638e9c8fcce7168d008ef45ad5465
BLAKE2b-256 checksum
How to use checksums
bd50a9074f9dfad74c52f905e195046816c70008f1a7af729b03fb035ee6d755
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.

Transparency log

Security for casetrace 0.1.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for casetrace-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.

Transparency log

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