agent-checkpointing
Implement checkpointing for agent recovery, debugging, and replay. Use this skill when building recoverable agents, implementing replay, debugging agent failures, or creating resumable workflows. Activate when: agent checkpoint, agent recovery, resume agent, agent restart, workflow replay, agent debugging, failure recovery, state snapshot.
What this skill does
# Agent Checkpointing
**Save, restore, replay, and debug agent execution with checkpoints.**
## Why Checkpointing?
- **Recovery**: Resume from failure without losing progress
- **Debugging**: Replay exact execution path
- **Branching**: Try different paths from same checkpoint
- **Audit**: Complete history of agent decisions
- **Testing**: Reproduce specific scenarios
## Checkpoint Architecture
```
┌─────────────────────────────────────────────────────────────┐
│ Checkpoint Timeline │
│ │
│ CP-1 CP-2 CP-3 CP-4 │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ ┌───┐ ┌───┐ ┌───┐ ┌───┐ │
│ │ S │──────▶│ S │──────▶│ S │──────▶│ S │ │
│ └───┘ └───┘ └───┘ └───┘ │
│ State State State State │
│ + + + + │
│ Metadata Metadata Metadata Metadata │
│ │ │
│ │ Rewind here │
│ ▼ │
│ ┌───┐ │
│ │ S │──────▶ New Branch │
│ └───┘ │
│ │
└─────────────────────────────────────────────────────────────┘
```
## Basic Checkpointing
### Setup
```python
from langgraph.graph import StateGraph, END
from langgraph.checkpoint.sqlite import SqliteSaver
from langgraph.checkpoint.postgres import PostgresSaver
# Development: SQLite
checkpointer = SqliteSaver.from_conn_string("./checkpoints.db")
# Production: PostgreSQL
checkpointer = PostgresSaver.from_conn_string(
"postgresql://user:pass@host/db"
)
# Compile graph with checkpointer
app = workflow.compile(checkpointer=checkpointer)
```
### Automatic Checkpointing
```python
# Every node completion creates a checkpoint automatically
config = {"configurable": {"thread_id": "my-thread"}}
# Run agent
result = app.invoke({"input": "Process this"}, config)
# Checkpoints created at each step
```
### Inspecting Checkpoints
```python
# Get current state
current_state = app.get_state(config)
print(f"Current checkpoint: {current_state.config}")
print(f"State values: {current_state.values}")
print(f"Next node: {current_state.next}")
# Get full checkpoint history
for checkpoint in app.get_state_history(config):
print(f"""
Checkpoint ID: {checkpoint.config['configurable']['checkpoint_id']}
Created: {checkpoint.metadata.get('created_at')}
Node: {checkpoint.metadata.get('source')}
State: {checkpoint.values}
""")
```
## Recovery Patterns
### Resume After Failure
```python
async def run_with_recovery(
app,
input_state: dict,
thread_id: str,
max_retries: int = 3
) -> dict:
"""Run agent with automatic recovery on failure."""
config = {"configurable": {"thread_id": thread_id}}
for attempt in range(max_retries):
try:
# Check for existing state
existing = app.get_state(config)
if existing and existing.values and existing.next:
# Resume from checkpoint
logger.info(f"Resuming from checkpoint, attempt {attempt + 1}")
return await app.ainvoke(None, config)
else:
# Start fresh
logger.info(f"Starting fresh, attempt {attempt + 1}")
return await app.ainvoke(input_state, config)
except Exception as e:
logger.error(f"Attempt {attempt + 1} failed: {e}")
if attempt == max_retries - 1:
raise
# Wait before retry
await asyncio.sleep(2 ** attempt)
raise RuntimeError("Max retries exceeded")
```
### Manual Recovery
```python
def recover_from_checkpoint(
app,
thread_id: str,
checkpoint_id: str = None
) -> dict:
"""Manually recover from a specific checkpoint."""
if checkpoint_id:
# Resume from specific checkpoint
config = {
"configurable": {
"thread_id": thread_id,
"checkpoint_id": checkpoint_id
}
}
else:
# Resume from latest
config = {"configurable": {"thread_id": thread_id}}
# Get state at checkpoint
state = app.get_state(config)
logger.info(f"Recovering from: {state.config}")
logger.info(f"State: {state.values}")
logger.info(f"Next node: {state.next}")
# Continue execution
return app.invoke(None, config)
```
## Replay and Debugging
### Replay Execution
```python
def replay_execution(app, thread_id: str):
"""Replay entire execution history."""
config = {"configurable": {"thread_id": thread_id}}
# Get all checkpoints in order
history = list(app.get_state_history(config))
history.reverse() # Oldest first
print("=== Execution Replay ===\n")
for i, checkpoint in enumerate(history):
print(f"Step {i + 1}: {checkpoint.metadata.get('source', 'start')}")
print(f" Checkpoint: {checkpoint.config['configurable']['checkpoint_id']}")
print(f" State: {json.dumps(checkpoint.values, indent=4)}")
print()
```
### Branch from Checkpoint
```python
def branch_from_checkpoint(
app,
source_thread_id: str,
checkpoint_id: str,
new_thread_id: str,
modified_state: dict = None
) -> dict:
"""Create a new branch from an existing checkpoint."""
# Get state at checkpoint
source_config = {
"configurable": {
"thread_id": source_thread_id,
"checkpoint_id": checkpoint_id
}
}
state = app.get_state(source_config)
# Create new thread with same state
new_config = {"configurable": {"thread_id": new_thread_id}}
# Optionally modify state
if modified_state:
merged_state = {**state.values, **modified_state}
else:
merged_state = state.values
# Initialize new branch
app.update_state(new_config, merged_state)
logger.info(f"Created branch {new_thread_id} from {checkpoint_id}")
return app.get_state(new_config)
```
### Compare Branches
```python
def compare_branches(
app,
thread_id_a: str,
thread_id_b: str
) -> dict:
"""Compare final states of two branches."""
config_a = {"configurable": {"thread_id": thread_id_a}}
config_b = {"configurable": {"thread_id": thread_id_b}}
state_a = app.get_state(config_a)
state_b = app.get_state(config_b)
# Find differences
differences = {}
all_keys = set(state_a.values.keys()) | set(state_b.values.keys())
for key in all_keys:
val_a = state_a.values.get(key)
val_b = state_b.values.get(key)
if val_a != val_b:
differences[key] = {"branch_a": val_a, "branch_b": val_b}
return {
"branch_a": thread_id_a,
"branch_b": thread_id_b,
"differences": differences,
"identical": len(differences) == 0
}
```
## Checkpoint Management
### Cleanup Old Checkpoints
```python
from datetime import datetime, timedelta
async def cleanup_checkpoints(
checkpointer,
max_age_days: int = 30,
max_per_thread: int = 100
):
"""Clean up old checkpoints to save storage."""
# Age-based cleanup
cutoff = datetime.now() - timedelta(days=max_age_days)
if hasattr(checkpointer, 'conn'): # Postgres
await checkpointer.conn.execute("""
DELETE FROM checkpoints
WHERE created_at < $1
""", cutoff)
# Keep only latest N per thread
await checkpointer.conn.execute("""
DELETE FROM checkpoRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.