Setup Vs Agent Firm

Firm is an inter-session memory layer for AI agents that enhances their capabilities and communication.

<div align="center">

🧠 Firm Ecosystem

The inter-session memory layer for AI agents.

Your AI agents forget everything between sessions. Firm fixes that.

PyPI β€” firm-cli PyPI β€” mcp-openclaw CI Docker License: MIT Python 3.11+ MCP 2025-11-25

</div>

Why Firm?

ProblemHow Firm solves it
AI agents forget everything between sessions4-layer Hebbian memory that learns, consolidates, and prunes automatically
Setting up multi-agent teams takes daysfirm init generates a production-ready agent firm in seconds
No standard for agent-to-agent communicationA2A Protocol RC v1.0 + MCP 2025-11-25 β€” 138 tools out of the box
Memory solutions are cloud-only, vendor-locked100% local, MIT licensed, SQLite-backed β€” runs on your laptop
No security auditing for AI agent configs47 security checks across 10 audit modules (CRITICAL β†’ MEDIUM)

vs. the competition

FeatureFirmmem0ZepLangGraph
Inter-session memoryβœ… 4-layer Hebbianβœ… vector onlyβœ… vector + graph❌ checkpoints only
Local-first (no cloud)βœ… SQLite❌ cloud SDK❌ cloud CEβœ…
MCP nativeβœ… 138 tools❌❌❌
A2A Protocolβœ… v1.0 RC❌❌❌
Multi-agent factoryβœ… 15 sectors❌❌partial
Security audit toolsβœ… 47 checks❌❌❌
Open sourceβœ… MITpartialCE onlyβœ… Apache-2.0
Vendor lock-innoneAPI keyAPI keynone

Quick-start (2 minutes)

pip install firm-cli[full]

# Generate a fintech startup with 4 agent departments
firm init --sector fintech --size startup --output ./my-firm
cd my-firm

# Start both MCP servers (138 tools + Hebbian memory)
firm start

Note: firm-cli[full] installs mcp-openclaw-extensions and memory-os-ai automatically. If you only installed firm-cli, running firm start will prompt you to install the missing packages.

Then add to your VS Code settings.json:

{
  "mcp.servers": {
    "firm": {
      "url": "http://127.0.0.1:8012/mcp"
    }
  }
}

That's it. Your agents now have persistent memory, security auditing, and inter-agent communication.

Docker (one command)

docker compose up -d
# MCP server on :8012, Memory server on :8765

Full install (with memory backend)

pip install firm-cli[full]     # includes mcp-openclaw + memory-os-ai
firm init --sector saas --size enterprise --output ./my-firm
firm start --memory             # starts memory server alongside MCP
firm memory dashboard           # view learned patterns

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Your IDE (VS Code / Cursor / Windsurf / Claude Code)        β”‚
β”‚   └─► firm-cli  ──────────────────────────────────────────────
β”‚         β”‚  firm init    β†’ generate agent firms               β”‚
β”‚         β”‚  firm start   β†’ launch MCP + memory servers        β”‚
β”‚         β”‚  firm memory  β†’ inspect learned patterns           β”‚
β”‚         β”‚  firm config  β†’ manage settings                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚
   β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  mcp-openclaw           β”‚    β”‚  Memory-os-ai            β”‚
   β”‚  (MCP server :8012)     │◄──►│  (Hebbian memory :8765)  β”‚
   β”‚  138 tools / 29 modules β”‚    β”‚  4-layer CLAUDE.md       β”‚
   β”‚  A2A + security + audit β”‚    β”‚  cosine similarity       β”‚
   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚  PII stripping           β”‚
          β”‚                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
   β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  OpenClaw Gateway       β”‚    ws://127.0.0.1:18789
   β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
   β”‚  β”‚  Agent Pyramid    β”‚   β”‚    15 sectors Γ— 3 sizes
   β”‚  β”‚  (firm init)      β”‚   β”‚    up to 18 departments
   β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚
   β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚  ClawHub (34 skills)    β”‚    clawhub.ai
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Table of contents

  1. Why Firm?
  2. Quick-start
  3. Architecture
  4. Hebbian Memory β€” how it works
  5. Factory β€” generate firms
  6. MCP Tools (138)
  7. Security Audit
  8. SDKs & Integrations
  9. Memory Backends
  10. REST API
  11. Benchmarks
  12. Deploy
  13. Skills (ClawHub)
  14. SOUL Personas
  15. CI/CD
  16. Configuration
  17. Contributing

Hebbian Memory β€” how it works

Memory-os-ai is also available as a standalone package β€” you don't need the full Firm ecosystem. See Memory-os-ai for standalone installation.

Firm implements a 4-layer adaptive memory inspired by neuroscience's Hebbian learning ("neurons that fire together wire together"):

Layer 4: Meta Instructions      ← rarely changes, highest authority
Layer 3: Episodic Index         ← session summaries, auto-decayed
Layer 2: Consolidated Patterns  ← learned rules, Hebbian-weighted
Layer 1: Core Identity          ← immutable project DNA

Weight formula: new_weight = old_weight + lr Γ— activation - decay Γ— (1 - activation)

  • Harvest: collects JSONL session logs, strips PII, extracts co-activation patterns
  • Consolidation: frequently co-activated patterns get promoted to Layer 2 as rules
  • Decay: unused patterns gradually lose weight and get pruned
  • Drift detection: cosine similarity against baseline catches unintended memory divergence
firm memory dashboard    # rich table of learned patterns + weights
firm memory analyze      # co-activation analysis

Factory β€” generate firms

firm init --help

Options:
  --sector    generic|legal|medtech|ecommerce|fintech|saas|
              manufacturing|education|realestate|logistics|
              media|automotive|energy|hr|consulting
  --stack     typescript|python|rust|go|java|dotnet|fullstack
  --size      startup (4 depts) | scaleup (8) | enterprise (18)
  --output    Output directory (default: ./firm-output)
  --lang      en|fr
  --dry-run   Print what would be written, write nothing
  --force     Overwrite existing output directory

Examples

Three complete real-world setups in examples/:


MCP Tools (138)

138 tools across 29 modules, organized by category:

CategoryCountKey capabilities
Security & Audit47SQL injection, sandbox, secrets lifecycle, prototype pollution, HSTS, rate limiting
Hebbian Memory8Harvest, weight update, analyze, drift check, PII stripping, layer validation
A2A Bridge8Agent cards, task lifecycle, cancel, SSE subscribe, push CRUD, JWS signing
Platform & Ecosystem16Secrets v2, routing, voice, trust, firewall, RAG, cost analytics, token budget
Spec Compliance18MCP 2025-11-25 elicitation, tasks, resources, audio, prompt injection, OAuth/OIDC
Infrastructure16VS Code bridge, fleet management, delivery pipeline (GitHub/Jira/Linear/Slack)
Config & Migration17Runtime audit, gateway hardening, config migration, observability, i18n
Specialized8Agent orchestration (DAG), n8n bridge, browser audit, skill loader

Full reference: mcp-openclaw README


Security Audit

47 security checks across 3 severity levels:

SeverityCountExamples
CRITICAL9SQL injection, sandbox off, hardcoded secrets, plugin auth bypass, exec plan mutation
HIGH19Gateway auth, race conditions, Node.js CVEs, shell env sanitization, webhook HMAC
MEDIUM19Disk budget, DM allowlist, OTEL redaction, RPC rate limiting, log redaction

SDKs & Integrations

Use Firm from any language or framework β€” no MCP protocol knowledge required.

Python SDK

pip install firm-sdk              # sync client (zero deps)
pip install firm-sdk[async]       # async client (aiohttp)
from firm_sdk import FirmClient

client = FirmClient()             # defaults to localhost:8012
result = client.memory_status()
print(result.data)

TypeScript SDK

npm install firm-sdk
import { FirmClient } from 'firm-sdk';
const client = new FirmClient();
const status = await client.memoryStatus();

LangChain & LlamaIndex

# LangChain β€” use Firm memory as a retriever
from integrations.langchain_adapter import FirmMemoryRetriever, FirmToolkit
retriever = FirmMemoryRetriever()
toolkit = FirmToolkit()  # wraps 138 tools as LangChain StructuredTools

# LlamaIndex β€” load memory as Documents
from integrations.llamaindex_adapter import FirmReader, FirmToolSpec
reader = FirmReader()
docs = reader.load_data()

Full SDK reference: sdks/python/ Β· sdks/typescript/ Β· integrations/


Memory Backends

Pluggable storage backends via integrations.memory_backends:

BackendInstallUse case
SQLite (default)Built-inLocal dev, single machine
Redispip install redisDistributed, multi-process
PostgreSQL + pgvectorpip install psycopg2-binaryProduction, vector similarity search
from integrations.memory_backends import get_backend

backend = get_backend("sqlite", path="./memory.db")
backend.store("rule-1", {"weight": 0.85, "text": "Always run tests"})
results = backend.search("tests", limit=5)

REST API

HTTP wrapper for the most common MCP tools β€” no MCP protocol knowledge needed:

python -m integrations.rest_api         # Start on :8080
curl http://localhost:8080/api/v1       # List all endpoints
curl http://localhost:8080/api/v1/memory/status
curl -X POST http://localhost:8080/api/v1/security/scan

12 endpoints covering security, memory, fleet, A2A, delivery, and compliance. CORS enabled. See integrations/rest_api.py.


Benchmarks

Reproducible performance suite for memory operations and tool dispatch:

python -m benchmarks.run               # Pretty-printed table
python -m benchmarks.run --json         # Machine-readable JSON
BenchmarkTypical (p50)Description
layer2_parsing~0.03 msParse 50 weighted rules from CLAUDE.md
hebbian_weight_update~0.02 msSingle Hebbian weight formula computation
pii_regex_scan~1.3 ms8 PII patterns across 10 KB of text
cosine_search_1k_768d~29 ms1000 Γ— 768-dim cosine similarity search
pydantic_validation<0.01 msValidate a typical tool input model
tool_registry_lookup<0.01 msLookup tool from 138-tool registry

See benchmarks/ for the full suite.


Deploy

MethodCommandBest for
pippip install firm-cli && firm startLocal dev
Docker Composedocker compose up -dSingle machine production
Helmhelm install firm deploy/helm/firm-ecosystemKubernetes
CodespaceClick "Open in Codespace"One-click evaluation

Grafana dashboard included: deploy/grafana/ (targets Prometheus /metrics).

Full deployment guide: deploy/README.md


Skills (ClawHub) β€” 34 skills

skills/
β”œβ”€β”€ firm-orchestration/           # A2A pyramid handoff protocol
β”œβ”€β”€ firm-legal-pack/              # Legal/compliance sector bundle
β”œβ”€β”€ firm-medtech-pack/            # MedTech/pharma (FDA/CE/ISO 13485)
β”œβ”€β”€ firm-ecommerce-pack/          # E-commerce/D2C/marketplace
β”œβ”€β”€ firm-fintech-pack/            # Fintech/neobank/AML/KYC
β”œβ”€β”€ firm-saas-pack/               # SaaS/PLG
β”œβ”€β”€ firm-delivery-export/         # Deliverables pipeline skill
β”œβ”€β”€ firm-security-audit/          # 5-step security audit sequence
β”œβ”€β”€ firm-acp-bridge/              # ACP persistence + cron + locking
β”œβ”€β”€ firm-hebbian-memory/          # Adaptive Hebbian memory system
β”œβ”€β”€ firm-a2a-bridge/              # A2A Protocol RC v1.0 bridge (8 tools)
β”œβ”€β”€ firm-spec-compliance-pack/    # MCP 2025-11-25 spec compliance (7 tools)
β”œβ”€β”€ firm-prompt-security-pack/    # Prompt injection detection (2 tools)
β”œβ”€β”€ firm-gateway-hardening-pack/  # Gateway auth + credentials (5 tools)
β”œβ”€β”€ firm-fleet-manager-pack/      # Fleet multi-instances Gateway (6 tools)
β”œβ”€β”€ firm-runtime-audit-pack/      # Runtime & config audit (7 tools)
β”œβ”€β”€ firm-advanced-security-pack/  # Advanced security (8 tools)
β”œβ”€β”€ firm-config-migration-pack/   # Config migration (5 tools)
β”œβ”€β”€ firm-reliability-pack/        # Reliability + ADR (4 tools)
β”œβ”€β”€ firm-observability-pack/      # JSONLβ†’SQLite traces + CI (2 tools)
β”œβ”€β”€ firm-memory-audit-pack/       # pgvector + knowledge graph (2 tools)
β”œβ”€β”€ firm-agent-orchestration-pack/ # DAG task execution (2 tools)
β”œβ”€β”€ firm-i18n-audit-pack/         # Locale scanning (1 tool)
β”œβ”€β”€ firm-n8n-bridge-pack/         # n8n workflow bridge (2 tools)
β”œβ”€β”€ firm-browser-audit-pack/      # Browser automation audit (1 tool)
β”œβ”€β”€ firm-platform-audit-pack/     # Platform alignment 2026.2 (8 tools)
β”œβ”€β”€ firm-ecosystem-audit-pack/    # Ecosystem differentiation (7 tools)
β”œβ”€β”€ firm-auth-compliance-pack/    # OAuth/OIDC + compliance (8 tools)
β”œβ”€β”€ firm-vs-bridge-pack/          # VS Code context sync (4 tools)
└── firm-skill-loader-pack/       # Lazy SKILL.md loading (2 tools)

Install all skills at once:

# After firm generation
bash ./my-firm/scripts/install-skills.sh

# Or manually via ClawHub CLI
clawhub install firm-orchestration firm-saas-pack firm-delivery-export firm-security-audit firm-acp-bridge

Each SKILL.md file is directly publishable to ClawHub with the standard YAML frontmatter.


SOUL personas

Publishable to onlycrabs.ai registry.

souls/
β”œβ”€β”€ firm-ceo/                # Alexandra Meridian β€” strategic orchestrator
β”œβ”€β”€ firm-cfo/                # Marcus Venn β€” financial architecture
β”œβ”€β”€ firm-cto/                # Soren Hales β€” technical excellence
β”œβ”€β”€ firm-legal-analyst/      # InΓ©s Clavero β€” regulatory radar
β”œβ”€β”€ firm-hr-director/        # Camille Osei β€” people systems
β”œβ”€β”€ firm-market-research/    # Γ‰lise Montblanc β€” competitive intelligence
β”œβ”€β”€ firm-legal-status/       # Thibault Desvaux β€” legal status advisory
β”œβ”€β”€ firm-location/           # Gabrielle LefΓ¨vre β€” location strategy
└── firm-suppliers/          # Marc-Antoine Roussel β€” procurement

Each SOUL.md contains: identity, core values, communication style, decision framework, pyramid behaviour, constraints, and sample interactions.


CI/CD

WorkflowTriggerDescription
ci.ymlPR + push to mainLint + test both packages (Python 3.11/3.12/3.13)
publish-pypi.ymlTag v*Publish to PyPI (trusted publishing)
docker-ghcr.ymlTag v*Build + push Docker images to GHCR
openclaw-review.ymlPRAI-powered code review via OpenClaw Quality dept

Tests

# MCP extensions β€” 2583 tests (separate repo: mcp-openclaw)
git clone https://github.com/romainsantoli-web/mcp-openclaw
cd mcp-openclaw && pip install -r requirements-dev.txt
python -m pytest tests/ -v --cov=src --cov-fail-under=80

# firm-cli β€” 14 tests
cd firm-cli && pip install -e ".[dev]"
python -m pytest tests/ -v

# Benchmarks β€” 8 performance benchmarks
python -m benchmarks.run --json

# Integration tests (memory backends, SDKs)
python -m pytest tests/test_backends.py tests/test_sdk.py -v

Configuration

See the mcp-openclaw .env.example for the full list. Key variables:

MCP_EXT_HOST=127.0.0.1          # MCP server bind address
MCP_EXT_PORT=8012                # MCP server port
FIRM_GATEWAY_URL=ws://127.0.0.1:18789  # Firm Gateway
GITHUB_TOKEN=<token>             # For delivery pipeline

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

# Development setup
git clone https://github.com/romainsantoli-web/firm-ecosystem
cd firm-ecosystem
pip install -e "firm-cli[dev]"

# MCP extensions tests (separate repo)
git clone https://github.com/romainsantoli-web/mcp-openclaw
pip install -e "mcp-openclaw[dev]"
python -m pytest mcp-openclaw/tests/ firm-cli/tests/ -v

Security

  • Timing-safe auth (hmac.compare_digest), 2MB request cap, 120s tool timeout
  • SQL injection guard, session ID regex, path traversal blocking on all config inputs
  • Tokens masked in all logs (mask_secret() β€” last 4 chars only)
  • 47 automated security checks via MCP tools
  • See SECURITY.md for reporting vulnerabilities

License

MIT β€” see LICENSE