Skip to main content

Deterministic run ledger for AI agents

Project description

AgentLedger Core

Deterministic Run Ledger for AI Agents

Record. Inspect. Replay. Diff.

AgentLedger Core provides an append-only execution ledger with hash chain integrity for AI agent runs.

Features

  • Append-only Event Ledger - Immutable record of agent execution
  • Hash Chain Integrity - SHA-256 hash chain for tamper detection
  • Deterministic Replay - Replay runs from recorded outputs
  • Run Inspection - Timeline and failure analysis
  • Run Diff - Compare runs to identify divergences

What AgentLedger Core is NOT

AgentLedger Core defines a minimal execution ledger format.

It does NOT define:

  • Agent cognition
  • Planning systems
  • Memory architectures
  • Orchestration frameworks
  • LLM adapters
  • Deployment systems

Installation

pip install agentledger-core

Quick Start

from agentledger import (
    LocalLedger,
    EventFactory,
    ReplayEngine,
    RunInspector,
    RunStatus,
)

# Create ledger and run
ledger = LocalLedger("./runs")
ledger.create_run("run_001")

# Record events
factory = EventFactory(run_id="run_001", agent_id="my_agent")
ledger.append(factory.run_start())  # goal is optional
ledger.append(factory.tool_call("search", {"query": "example"}))
ledger.append(factory.tool_result(output={"results": ["a", "b"]}))
ledger.append(factory.run_end(status=RunStatus.COMPLETED))

# Verify determinism
engine = ReplayEngine(ledger)
result = engine.verify_determinism("run_001")
print(f"Hash chain valid: {result['hash_chain_valid']}")
print(f"Deterministic: {result['deterministic']}")

# Inspect the run
inspector = RunInspector()
events = [e.model_dump() for e in ledger.get_events("run_001")]
report = inspector.inspect(events, "run_001")
print(f"Events: {len(report.timeline)}")
print(f"Duration: {report.duration_seconds}s")

Core Event Types

The v0.1 standard defines 9 canonical event types:

Category Events
Run lifecycle run.start, run.end
Step lifecycle step.start, step.end
Tool execution tool.call, tool.result
Decision decision
State state.patch
Error error

Custom extension events are supported but not part of the compliance set.

Storage Layout

runs/
  run_{id}/
    run.json          # Run manifest
    ledger/
      events.jsonl    # Append-only event log
    blobs/            # Optional blob storage

API Reference

LocalLedger

ledger = LocalLedger("./runs")

ledger.create_run(run_id)           # Initialize new run
ledger.append(event)                # Append event
ledger.get_events(run_id)           # Iterate events
ledger.get_run_metadata(run_id)     # Get run manifest
ledger.store_blob(run_id, data)     # Store large data

EventFactory

factory = EventFactory(run_id, agent_id)

factory.run_start()                 # Run start (all fields optional)
factory.run_end(status)             # Run end
factory.step_start(step_id)         # Step start
factory.step_end(step_id)           # Step end
factory.tool_call(tool, input)      # Tool invocation
factory.tool_result(output)         # Tool response
factory.decision(decision_type)     # Decision point
factory.state_patch(*patches)       # Optional state mutation
factory.error(type, message)        # Error event

ReplayEngine

engine = ReplayEngine(ledger)

engine.replay(run_id)               # Full replay
engine.step(run_id)                 # Step-by-step iterator
engine.get_state_at(run_id, seq)    # State at sequence
engine.verify_determinism(run_id)   # Hash chain verification
engine.compare(run_a, run_b)        # Compare two runs

RunInspector / RunDiffer

inspector = RunInspector()
report = inspector.inspect(events, run_id)

from agentledger import diff_runs
diff = diff_runs(events_a, events_b, "run_a", "run_b")

Standard

AgentLedger Core v0.1 defines the minimal execution ledger standard for AI agents.

This package is the reference implementation of the standard. See SPEC.md for the full specification.

CLI Usage

# Inspect a run
agent inspect run_001

# Replay a run
agent replay run_001

# Diff two runs
agent diff run_a run_b

License

MIT License

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

agentledger_core-0.1.0.tar.gz (35.0 kB view details)

Uploaded Source

Built Distribution

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

agentledger_core-0.1.0-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agentledger_core-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bea8730227e11da1450eb8323d0d738c56f717d35a4d2c906d814587920bb8c4
MD5 cbbbc36e7444b474a9eed7bad688685e
BLAKE2b-256 7f7c598c604b3282b191c51f82e75df4ef24433715f3826a23dbc702cbb2c581

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for agentledger_core-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b15512509b254cec56404866d709637d972be4b7cdf1ca4ad1a5c66741982337
MD5 4924d54c45c2614e5bcf2706af4a416a
BLAKE2b-256 f81cef2073eeea72aeab57c3e8bc8b25211a1f85382f2e6ec5a2cc004a622a8b

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