Skip to main content

Checkpointing and recovery protocol for AI agents

Project description

AgentStateProtocol

Checkpointing and recovery protocol for AI agents.

AgentStateProtocol lets an agent save state at each reasoning step, branch into alternatives, and roll back safely after failures.

Install

pip install agentstateprotocol

Quick Start

from agentstateprotocol import AgentStateProtocol

agent = AgentStateProtocol("my-agent")

agent.checkpoint(
    state={"task": "summarize quarterly report", "stage": "parsed"},
    metadata={"confidence": 0.91},
    description="Initial parse",
    logic_step="parse_input",
)

agent.checkpoint(
    state={"task": "summarize quarterly report", "stage": "drafted"},
    metadata={"confidence": 0.86},
    description="Draft generated",
    logic_step="draft_summary",
)

# Roll back one step if needed
agent.rollback()

Core Operations

  • agent.checkpoint(...): save a state snapshot
  • agent.rollback(...): restore a previous checkpoint
  • agent.branch(name): start an alternate reasoning path
  • agent.switch_branch(name): move between branches
  • agent.merge(source_branch): merge branch outcomes
  • agent.history(): inspect checkpoint timeline
  • agent.visualize_tree(): show decision tree

Decorators

from agentstateprotocol.decorators import agentstateprotocol_step

@agentstateprotocol_step("analyze")
def analyze(state):
    return {"result": "ok", **state}

Storage

from agentstateprotocol.storage import FileSystemStorage, SQLiteStorage

file_storage = FileSystemStorage(".agentstateprotocol")
sqlite_storage = SQLiteStorage(".agentstateprotocol/agentstateprotocol.db")

CLI

agentstateprotocol demo
agentstateprotocol log
agentstateprotocol tree
agentstateprotocol branches
agentstateprotocol diff <checkpoint_a> <checkpoint_b>
agentstateprotocol metrics

Project

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

agentstateprotocol-0.1.0.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

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

agentstateprotocol-0.1.0-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agentstateprotocol-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0b93f2d6ac8f88da26ffbd6d8be6e837ad8cb6c4b4c6966c3f3be40ec25c9721
MD5 00219a68a0d6d842bba3f6b2b3427a29
BLAKE2b-256 5b77aea42505dc09434b7537f91d94339b45e04ce0e0bce4362251069f5c78bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for agentstateprotocol-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 65421cac9a847a2f2a556a86b5243fe0a4da7e87e755aa72939be562711b9bef
MD5 269ffe9b608fd718275d83f2739cc5dc
BLAKE2b-256 6e7cc4ef17d71f98f7f42288741c15e537c4e77b57213d19e49d784cb20fa12c

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