Content-addressed semantics for multi-agent coordination. When the hash is the word.
Project description
Sema: When the Hash Is the Word
Content-addressed semantics for multi-agent coordination.
Sema is a semantic commons that content-addresses meaning itself: the definition is the identifier. By deriving identifiers from the cryptographic hash of a pattern's definition, any divergence in meaning produces a distinct hash, guaranteeing that misaligned agents halt rather than fail silently.
Note: Sema is experimental research. Run it in a sandboxed environment. See Safety.
Web: semahash.org · Discord: Join
Install
MCP Server (recommended)
Add to any MCP client (Claude Code, Cursor, VS Code, Windsurf, Claude Desktop):
{
"mcpServers": {
"sema": {
"command": "uvx",
"args": ["--from", "semahash[mcp]", "sema", "mcp"]
}
}
}
Or via Claude Code CLI:
claude mcp add sema -- uvx --from "semahash[mcp]" sema mcp
This uses uv to download, install, and run sema in an isolated environment on first invocation, then caches it for subsequent calls.
Claude Code plugin (MCP server + skill)
Sema also ships as a Claude Code plugin — MCP server plus a skill that teaches the agent the search/resolve/mint/handshake workflow:
# One-time: add the Emergent Wisdom marketplace
claude plugin marketplace add emergent-wisdom/marketplace
# Install the plugin
claude plugin install sema
This gives you the MCP server and the sema-usage skill (auto-loaded), which teaches when to search vs mint, how to embed handles in text, and how to verify meaning at boundaries. The skill is a Claude Code convenience — the MCP server works with any client.
For local development:
claude --plugin-dir /path/to/sema
Permanent install (pip)
pip install "semahash[mcp]"
For CLI-only use (no MCP server):
pip install semahash
Quick Start
Use with AI Agents (MCP)
Already covered above via the JSON config or pip install path. For development against this repo:
git clone https://github.com/emergent-wisdom/sema.git
pip install -e "./sema[mcp]"
Your agent now has access to sema_search, sema_lookup, sema_handshake, and 9 more tools. Any MCP-compatible client works — Sema exposes a standard stdio server.
Verify it works — ask your agent: "Search sema for coordination patterns and handshake on StateLock"
Sema exposes a standard MCP stdio server — any MCP-compatible client works, including OpenClaw (openclaw mcp set sema '{"command":"uvx","args":["--from","semahash[mcp]","sema","mcp"]}').
Use via CLI
# Search the vocabulary
sema search "coordination"
# Look up a specific pattern
sema resolve StateLock
# Print a pattern's full definition
sema show StateLock
# Browse the graph structure
sema skeleton
# Start local API + web frontend (binds to 127.0.0.1 by default)
sema serve
Bring Your Own Vocabulary
Build a private registry from scratch — no PR or maintainer in the loop:
sema init ./mylib.db
export SEMA_DB_PATH=$(pwd)/mylib.db
sema apply --add path/to/MyPattern.json
sema search "..."
Subsequent sema commands (including sema mcp) read from your private
registry. See CONTRIBUTING.md for the canonical
contribution path and docs/specification/versioning.md for the
refinement and supersession policy.
Use in Python
from sema.core.actions import sema_handshake
import json
# Look up the canonical hash
result = json.loads(sema_handshake("StateLock"))
print(result["canonical_stub"]) # b91b
# Verify alignment
result = json.loads(sema_handshake("StateLock#5602"))
print(result["verdict"]) # PROCEED
Try the Protocol (No API Keys Needed)
python experiments/demos/local_handshake.py
See the handshake in action: matching hashes PROCEED, mismatched hashes HALT, unknown patterns HALT. Takes 2 seconds.
How It Works
word = hash(canonical(definition))
Take any concept (a coordination protocol, a reasoning pattern, a trust mechanism), express it in canonical form, hash it. That hash IS the word. Change one byte in the definition, get a different word.
Agent A: "Let's use StateLock#5602"
Agent B: sema_handshake("StateLock#5602")
-> PROCEED (hashes match) or HALT (drift detected)
This is the Anti-Postel principle: same bytes = PROCEED, different bytes = HALT. No ambiguity, no silent failures.
The Vocabulary
427 default patterns across 4 layers (additional patterns with a higher risk surface are kept in a separate DB — see Safety):
- Physics — Immutable substrate (locks, entropy, causality)
- Mind — Hybrid cognition (reasoning, inference, strategy)
- Society — Multi-agent coordination (economics, governance, protocols)
- Infrastructure — Operational constraints (data structures, verification)
Each pattern is an executable specification containing machine-verifiable contracts, invariants, failure modes, and typed dependencies.
MCP Tools
When running as an MCP server (sema mcp), these tools are available:
| Tool | Description |
|---|---|
sema_search |
Search patterns by name, description, or meaning |
sema_lookup |
Get a pattern by its reference (e.g., StateLock#5602) |
sema_resolve |
Get a pattern with dependencies expanded |
sema_handshake |
Fail-closed semantic verification between agents |
sema_mint |
Create a new pattern (validate, hash, add to vocabulary) |
sema_propose_context |
Compute a context digest for a multi-agent definition set (drift detection) |
sema_verify_context |
Verify a context proposal from another agent |
sema_tree |
Browse vocabulary by layer and category |
sema_validate |
Validate a pattern JSON for correctness |
sema_stats |
Vocabulary statistics |
sema_graph_skeleton |
Ultra-minimal graph overview (~150 tokens) |
sema_reset_session |
Clear session cache so searches return full results again |
Web Frontend
pip install "semahash[api]"
sema serve
# Open http://localhost:3000
Interactive 3D graph visualization, pattern browser, and search. Built with React + Three.js.
Experiments
The experiments/ directory contains a controlled multi-agent design challenge comparing three conditions:
| Condition | Sema | Turns | Outcome |
|---|---|---|---|
| A: Natural language only | No | 4 | Design rejected |
| B: Sema vocabulary | Yes | 11 | SAD Engine approved |
| C: Sema + protocol | Yes | 25 | SAD Engine with exhaustive vetting |
Agents with Sema patterns produced physics-grounded designs that survived adversarial scrutiny. Agents without Sema produced shallow designs that failed safety review.
To reproduce:
cd experiments/sema_design_challenge
export GOOGLE_API_KEY=your_key
./reproduce.sh
See experiments/sema_design_challenge/README.md for details.
Key Properties
- Zero semantic collisions across the full vocabulary
- 16.9x average token compression via content-addressed stubs
- Fail-closed architecture — mismatches halt, never fail silently
- Mean embedding similarity of 0.21 — high structural distinctness
Using with understanding-graph
Sema gives your agents shared semantic memory — a vocabulary of cognitive patterns with content-addressed identity. Understanding Graph gives them shared episodic memory — the actual thinking trail behind a decision. They compose:
claude mcp add sema -- uvx --from "semahash[mcp]" sema mcp
claude mcp add ug -- npx -y understanding-graph mcp
With both installed, an agent can:
- Anchor an understanding-graph decision node in a sema pattern hash (e.g.
StateLock#5602) so the meaning of the primitive can never drift. - Use
graph_semantic_searchto find all past graph nodes that reference a given sema pattern — hash-stable history, not keyword matching. - Call
sema_handshakebefore writing a decision that depends on a shared concept; if it returnsHALT, the agent writes atensionnode instead and stops, preventing silent divergence.
Full walkthrough: docs/guides/understanding-graph.md
Repository Structure
sema/
├── src/sema/ Core library (hashing, validation, MCP server, API)
├── data/ Vocabulary (427 default + 26 higher-risk pattern cards + taxonomy databases)
├── docs/ Documentation (philosophy, schema spec, CLI reference)
├── paper/ Academic paper (sema.tex)
├── web/ Web frontend (React + Three.js graph visualization)
├── experiments/
│ ├── orchestrator/ Multi-agent engine (bundled for experiment reproduction)
│ ├── sema_design_challenge/ Main experiment (3 conditions, 5 runs, full traces)
│ └── demos/ Standalone demos (local handshake, Babel Test)
└── pyproject.toml Package config (extras: [mcp], [api], [full])
Contributing
Want to add patterns, improve existing ones, or host the frontend locally? See CONTRIBUTING.md.
Citing
@misc{westerberg2026sema,
title = {Sema: When the Hash Is the Word},
author = {Westerberg, Henrik},
year = {2026},
month = apr,
publisher = {Zenodo},
doi = {10.5281/zenodo.19548971},
url = {https://doi.org/10.5281/zenodo.19548971}
}
See CITATION.cff for the machine-readable version (GitHub
renders a "Cite this repository" button from it).
Safety
Sema is an experimental research project. It has not been tested in production environments. We recommend running it in a sandboxed environment.
Some patterns are marked with a caution field in their metadata to flag them as potentially risky. The absence of a caution flag does not imply safety — many patterns carry no identifier regarding their safety status. Agents connecting via MCP are informed that referencing a pattern is not authorization to perform the actions it describes.
The long-term goal is cryptographically enforced safety constraints for agent-to-agent communication, but further research is required to achieve this.
License
Sema is dual-licensed:
- Code (everything in
src/,web/,experiments/,scripts/, and the package config) — MIT. Self-host it, fork it, build commercial products on top of it. - Content (the pattern vocabulary in
data/, the documentation indocs/, the academic paper inpaper/, and the prose displayed on semahash.org) — CC BY 4.0. Reuse the patterns and prose anywhere, for any purpose including commercial, as long as you attribute Henrik Westerberg.
For academic citation, see CITATION.cff. GitHub renders this
as a "Cite this repository" button on the project page that generates APA and
BibTeX automatically.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file semahash-0.2.1.tar.gz.
File metadata
- Download URL: semahash-0.2.1.tar.gz
- Upload date:
- Size: 5.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad775651ea07af8e16b579b521d7639f04d0a018070e61beb10b09a81ef70b60
|
|
| MD5 |
b1669b1b5f056ec710ffd0fd649e0293
|
|
| BLAKE2b-256 |
f09cb987c7e82bbc7aff3311a54e8a416d5c0536631d1469abb8dd38eebbbc37
|
Provenance
The following attestation bundles were made for semahash-0.2.1.tar.gz:
Publisher:
publish.yml on emergent-wisdom/sema
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
semahash-0.2.1.tar.gz -
Subject digest:
ad775651ea07af8e16b579b521d7639f04d0a018070e61beb10b09a81ef70b60 - Sigstore transparency entry: 1339194590
- Sigstore integration time:
-
Permalink:
emergent-wisdom/sema@13d15e08a4da13a94a2314c89607be8f54e6b70f -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/emergent-wisdom
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@13d15e08a4da13a94a2314c89607be8f54e6b70f -
Trigger Event:
release
-
Statement type:
File details
Details for the file semahash-0.2.1-py3-none-any.whl.
File metadata
- Download URL: semahash-0.2.1-py3-none-any.whl
- Upload date:
- Size: 4.8 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
988a95cee95fa45bccaa1b22243f9799a13cc55850e9e6097afab49d9af36aad
|
|
| MD5 |
545250f21b7ea53f4c9f6d09b8d7cf71
|
|
| BLAKE2b-256 |
62a6700cd3c3618a548130d3fdf212789ab3bfaac4a9b265daea4e593468a038
|
Provenance
The following attestation bundles were made for semahash-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on emergent-wisdom/sema
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
semahash-0.2.1-py3-none-any.whl -
Subject digest:
988a95cee95fa45bccaa1b22243f9799a13cc55850e9e6097afab49d9af36aad - Sigstore transparency entry: 1339194619
- Sigstore integration time:
-
Permalink:
emergent-wisdom/sema@13d15e08a4da13a94a2314c89607be8f54e6b70f -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/emergent-wisdom
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@13d15e08a4da13a94a2314c89607be8f54e6b70f -
Trigger Event:
release
-
Statement type: