Skip to main content

AgentTrace

AI agent forensics & incident response — reconstruct, verify, and report on LLM/agent security incidents.

Local-first · standards-aligned · zero runtime dependencies · defensive DFIR.

AgentTrace is an open-source digital forensics and incident response (DFIR) tool for AI agents and LLM applications. It ingests already-recorded evidence (OpenTelemetry GenAI spans, MCP server logs, vector-store retrieval logs, OAuth records, egress logs, Halo-record hash-chains), verifies its integrity and chain of custody, reconstructs the causal attack chain, detects known attack patterns mapped to MITRE ATLAS, and produces a regulator/court-ready report aligned with EU AI Act Article 12.

Keywords: AI agent forensics · LLM incident response · prompt-injection investigation · agentic AI security · MITRE ATLAS · chain of custody · OpenTelemetry GenAI · MCP · EU AI Act · DFIR.

What it does

  • 🔌 Ingests 7 evidence sources into one normalized schema (OTel GenAI, MCP, vector store, OAuth, egress, Halo-record, generic JSONL).
  • 🔒 Verifies integrity & chain of custody — hash chains, gap/witness detection, HMAC-signed manifests, a tamper-evident custody ledger.
  • 🕸️ Reconstructs the causal attack chain across fragmented logs (timeline + provenance graph).
  • 🎯 Detects 6 attack patterns (prompt injection via retrieval, exfiltration via tool chaining, OAuth/credential theft, sub-agent hijack, memory poisoning, tool-permission escalation) — each mapped to MITRE ATLAS and linked to exact evidence.
  • 🧭 Builds kill-chain narratives + risk scores.
  • 📄 Reports in JSON, Markdown, and self-contained offline HTML (with an SVG causal-graph), plus EU AI Act Article 12 coverage.
  • 📦 Portable signed case bundles for air-gapped transfer.
  • 🚫 No AI/ML in the detection path — deterministic and fully explainable.

It is the investigation layer that sits downstream of recorders (OpenTelemetry GenAI, Halo-record, MCP logs). Recording is largely solved; automated reconstruction of what actually happened across 6–7 fragmented log sources is not. That is the gap AgentTrace fills.

⚠️ Authorized use only

AgentTrace is a defensive forensic tool. Use it only on evidence you are legally authorized to investigate (your own agent deployments, or incidents you are properly engaged to investigate). It is not an attack, exploitation, or surveillance tool, has no capability to access remote systems or accounts, and runs fully offline.

Why it exists

  • The attack vector in AI-agent incidents is natural language — a malicious prompt looks identical to a legitimate one in every log. The sequence is the evidence, not any single event.
  • Evidence is scattered across LLM invocation logs, tool traces, MCP server logs, vector-store retrieval logs, OAuth records, and egress logs.
  • Volume defeats manual review (a documented 2026 incident: ~17,600 agent actions in 5 days; the operator called manual reconstruction "impractical").

Pipeline

ingest → normalize (UFE) → verify (integrity + chain of custody)
       → correlate (timeline + causal graph) → detect (attack patterns)
       → report (JSON + Markdown, EU AI Act Art.12 coverage)
  • Unified Forensic Event (UFE): every source is normalized to one schema.
  • Integrity: verifies Halo-record hash chains, detects sequence/time gaps, and supports out-of-band witness anchors — distinguishing "nothing was edited" from "nothing is missing".
  • Correlation: builds a causal graph with PROV-O-style edges (parent_of, followed_by, used_data, derived_from).
  • Detection (explainable, evidence-linked):
    1. prompt injection via retrieved content,
    2. exfiltration via tool-call chaining (monotonic-offset paging),
    3. OAuth / credential-theft chains with anomalous operational velocity.
  • Reporting: chain-of-custody attestation + EU AI Act Article 12 coverage.

Install

pip install -e .          # from the project root
# or run without installing:
python3 -m agenttrace.cli --help

Requires Python ≥ 3.10. No third-party runtime dependencies.

Quickstart

Generate a synthetic incident dataset and run the full pipeline:

python3 -m tests.synthetic synthetic_data      # writes sample evidence files
agenttrace report synthetic_data/*.json synthetic_data/*.jsonl \
    --signing-key "my-case-key" \
    --title "Synthetic AI Agent Incident" \
    --md-out report.md --json-out report.json --html-out report.html

The --html-out report is fully self-contained and offline (inline SVG causal-graph visualization, no external CDN or network access).

Deterministic by design (no AI/ML in the detection path)

AgentTrace uses only deterministic heuristics and rule-based correlation — no LLM or ML model participates in reaching a finding. This is intentional for a forensic tool: every finding links back to the exact underlying events, there is no hallucination or automation-bias risk, and it runs air-gapped with zero dependencies. Any future AI assistance would be confined to an optional natural-language summary layer on top of the deterministic core, and would never decide a detection.

Other subcommands:

agenttrace ingest      <files...>   # normalize evidence to UFE (JSON)
agenttrace verify      <files...>   # integrity + chain of custody + manifest
agenttrace reconstruct <files...>   # timeline + causal graph
agenttrace detect      <files...>   # attack-pattern findings

Force a specific collector with --collector otel_genai|halo_record|jsonl_llm.

Supported evidence sources

Collector Source format
otel_genai OpenTelemetry GenAI spans (gen_ai.*)
halo_record Halo-record hash-chained audit logs (JSONL)
mcp Model Context Protocol server logs (JSONL)
vector_store RAG vector-store retrieval logs (JSONL)
oauth OAuth grant / token issuance & use (JSONL)
egress Egress network logs (JSONL)
jsonl_llm Generic JSONL LLM/tool logs (permissive)

New sources are added by subclassing Collector (see agenttrace/collectors/).

Tests

python3 -m unittest discover -s tests -v

All tests use synthetic data only; no real systems or data are involved.

Project layout

agenttrace/
  model.py         # UFE schema, evidence bundle, redaction
  custody.py       # tamper-evident chain-of-custody ledger
  collectors/      # pluggable ingestion (otel/halo/mcp/vector/oauth/egress/jsonl)
  integrity.py     # hash-chain verify, gap detection, signed manifest
  correlate.py     # timeline + causal graph
  detect.py        # attack-pattern detectors + MITRE ATLAS mapping
  analyze.py       # kill-chain narratives + risk scoring
  bundle.py        # portable signed .tar case bundles
  report.py        # JSON / Markdown / HTML reporting
  cli.py           # command-line interface
tests/             # synthetic dataset generator + test suite
DESIGN.md          # architecture & threat model

Contributing & security

Support

AgentTrace is free and open source. If you find it useful and would like to support development, donations are welcome — entirely at your own discretion.

  • TRON (TRX / USDT–TRC20): TYqSCXX8Vu7MXcTXsPPgiKxb4uRHLKTPcC

⚠️ Send only on the TRON (TRC-20) network. Always verify the address character-for-character before sending. Cryptocurrency transactions are irreversible; donate at your own risk. Donations are voluntary and non-refundable.

License

Apache-2.0. See LICENSE.

Metadata

Release files for agentdfir 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 agentdfir 0.1.0
File Size Uploaded Provenance
agentdfir-0.1.0.tar.gz 51.4 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 109.2 kB

Release files / agentdfir-0.1.0.tar.gz

Download URL agentdfir-0.1.0.tar.gz
Size 51.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1bb75cd2ead604df0ed2b546a586759ce6f8f59bf8557f6968dcea05eaba22ec
BLAKE2b-256 checksum
How to use checksums
275e05f999f37b8933fe6f4920043b1f65a4e307aa9cbe4cb82670127eb95bf8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

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

Download URL agentdfir-0.1.0-py3-none-any.whl
Size 57.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c1ea4b369303e6f57784a34410e40b9020c818ded11dc633c831588fb19e5f6
BLAKE2b-256 checksum
How to use checksums
3b794ebc503cf679c027352a373dc4c91e13b81683cae4cc2396728e84eb71ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for agentdfir 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.

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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