Skip to content

Building a Chain of Presence

A Chain of Presence (CoP) is an agent’s personal history — a tamper-evident record of everything it has done across all contexts. This guide walks through building one from scratch.

import synpareia
# Create an identity for your agent
profile = synpareia.generate()
# Start a Chain of Presence
cop = synpareia.create_chain(profile)

Every meaningful action becomes a block in the chain:

# Agent sends a message
msg = synpareia.create_block(profile, "message", "Starting analysis of dataset X")
cop.append(msg)
# Agent makes a decision
decision = synpareia.create_block(
profile, "thought",
"Dataset shows anomaly in sector 7. Recommending deeper investigation.",
metadata={"confidence": 0.87}
)
cop.append(decision)
# Agent calls a tool
tool_call = synpareia.create_block(
profile, "tool_call",
'{"tool": "search", "query": "sector 7 historical data"}',
)
cop.append(tool_call)

The CoP should capture actions that matter for accountability and verifiability:

ActionBlock typeWhy record it
Messages sentmessageProves what was communicated
Reasoning stepsthoughtAudit trail for decisions
Tool callsCustom typeProves what tools were used and when
Data receivedmessage or customProves what information was available
Commitments madecommitmentProves independent evaluation (commit-reveal)
Interactions with other agentsanchorLinks to shared conversation histories

You don’t need to record everything. Focus on actions that someone might later want to verify.

For agents that run across multiple sessions, use SQLite storage:

from synpareia.chain.storage.sqlite import SQLiteStore
store = SQLiteStore("my_agent_cop.db")
cop = synpareia.create_chain(profile, store=store)
# Blocks persist across process restarts

At any point, verify the chain’s integrity:

valid, errors = cop.verify()
if valid:
print(f"Chain intact: {cop.length} blocks verified")
else:
for error in errors:
print(f"Problem: {error}")

Export the chain for independent verification:

# Full export — includes all content
export = synpareia.export_chain(cop)
# Privacy-preserving export — includes hashes but not content
export = synpareia.export_chain(cop, include_content=False)

The exported JSON is self-contained. A verifier doesn’t need access to synpareia or any external service:

# Anyone can do this
valid, errors = synpareia.verify_export(export)

When your agent participates in a multi-agent interaction, anchor your CoP to the shared sphere chain:

# After participating in a conversation
anchor, pos = synpareia.create_anchor_block(
profile, cop,
target_chain_id=conversation_sphere.id,
target_sequence=conversation_sphere.length,
target_block_hash=conversation_sphere.head.position_hash,
anchor_type="bridge",
)

This creates a verifiable link: “my agent participated in this conversation, and at this point the conversation’s state was X.”

Built by Sam Hyland · Canberra, Australia