Context Nexus
Persistent memory, observability, secrets management, and replay for OpenClaw agents.
What it is
Context Nexus is the default memory and observability substrate for OpenClaw agents.
Once installed, it:
- 1. Persists memory — set, search, pin, and retrieve facts between sessions
- Logs events — structured logs with automatic redaction
- Stores secrets — encrypted at rest, no hardcoded API keys
- Distills runs — deterministic summaries after each session
- Scores performance — lightweight run scoring with optimization suggestions
Install
CODEBLOCK0
Note: clawhub install context-nexus installs this SKILL.md + metadata only.
The full runtime (plugin, services, storage) requires the GitHub clone above.
Setup
After install, add plugin to ~/.openclaw/openclaw.json:
CODEBLOCK1
Then: openclaw gateway restart
Usage (automatic hooks)
Once installed, it runs automatically via hooks. No manual calls required for standard use.
Hooks that fire automatically:
- -
before_prompt_build — injects recent durable memories before every response - INLINECODE4 — logs every tool call with redaction
- INLINECODE5 — distills run summary automatically
- INLINECODE6 — logs and classifies failures
Manual power use:
CODEBLOCK2
Memory scopes
| Scope | Lifetime | Compaction |
|---|
| INLINECODE7 | Current session only | Top 50 kept |
| INLINECODE8 |
All sessions | Top 500 kept |
|
pinned | Permanent | Never deleted |
Importance 9-10 → auto-pinned.
Secrets security
- - PBKDF2 + HMAC-SHA256 encryption at rest
- Fail-closed: decryption errors return nothing
- Logs automatically redact Stripe keys, GitHub tokens, bearer tokens, private keys, JWTs
- INLINECODE10 verifies storage integrity
Architecture
- - Node.js plugin registers hooks + exposes tools to OpenClaw
- Python subprocess handles all storage/logic (
nexus_service.py) - SQLite default; PostgreSQL supported via INLINECODE12
- Zero mandatory cloud dependencies
Storage
Default: INLINECODE13
PostgreSQL (optional): set INLINECODE14
Upgrade path: same adapter, zero code change.
Docs
Agent Marketplace (v0.1)
Context Nexus includes an agent-to-agent service marketplace. Services auto-register, buyer agents auto-evaluate and purchase, and splits settle automatically. Zero human involvement in transactions.
The Economy
Every transaction splits:
- - 85% → service provider operator (revenue)
- 3% → Context Nexus network ops
- 12% → Context Nexus improvement fund
Register a Service
CODEBLOCK3
Declare a Buyer Policy
CODEBLOCK4
Auto-Purchase Flow
When a matching service is registered:
- 1. Buyer agent's policy engine evaluates signal match, budget, and approval score
- If score >= threshold → automatic purchase
- Splits settle to operator, ops, and improvement fund
- Transaction logged permanently
Buyer Policy Engine
Score = signalmatch×0.4 + budgetfit×0.25 + category_match×0.3
- - Score >= autoapprovethreshold → auto-purchased
- Score < threshold → flagged for review
Query Earnings
CODEBLOCK5
Marketplace Methods
CODEBLOCK6
Settlement (v0.1 = off-chain, v1.0 = on-chain Solana)
v0.1: Transactions logged off-chain. nexus_market action=settle_transaction tx_hash=on_chain_v0.1 marks settled.
v1.0: SPL token transfers with automatic split settlement on Solana.
Requirements
- - Python 3.8+
- OpenClaw 2026.1+
- SQLite (built-in, no install)
- Optional: PostgreSQL for multi-agent shared memory
Context Nexus
针对OpenClaw代理的持久化记忆、可观测性、密钥管理与回放功能。
功能概述
Context Nexus是OpenClaw代理的默认记忆与可观测性基础组件。
安装后,它将:
- 1. 持久化记忆 — 在会话之间设置、搜索、固定和检索事实信息
- 记录事件 — 结构化日志,自动脱敏处理
- 存储密钥 — 静态加密存储,无需硬编码API密钥
- 提炼运行摘要 — 每次会话后生成确定性摘要
- 性能评分 — 轻量级运行评分及优化建议
安装
bash
步骤1:克隆仓库(运行时 + 插件)
git clone https://github.com/prettybusysolutions-eng/context-nexus ~/context-nexus
步骤2:初始化存储
cd ~/context-nexus
./scripts/install
步骤3:安装为OpenClaw插件
openclaw plugins install ~/context-nexus/plugin
步骤4:添加到openclaw.json的plugins.entries配置
(编辑 ~/.openclaw/openclaw.json — 参见上方设置章节)
步骤5:重启网关
openclaw gateway restart
验证安装
./scripts/smoke_test
注意: clawhub install context-nexus 仅安装此SKILL.md文件及元数据。
完整的运行时(插件、服务、存储)需要通过上述GitHub克隆获取。
设置
安装后,将插件添加到 ~/.openclaw/openclaw.json:
json
{
plugins: {
load: {
paths: [~/context-nexus/plugin]
},
entries: {
context-nexus: {
enabled: true,
config: {
sessionScope: durable,
logLevel: info
}
}
}
}
}
然后执行:openclaw gateway restart
使用方式(自动钩子)
安装后,插件通过钩子自动运行。标准使用场景无需手动调用。
自动触发的钩子:
- - beforepromptbuild — 在每次响应前注入最近的持久化记忆
- aftertoolcall — 记录每次工具调用并自动脱敏
- sessionend — 自动生成运行摘要
- onerror — 记录并分类失败信息
高级手动使用:
bash
存储记忆
nexus_memory action=set key=user:pref value=dark mode scope=durable importance=8
搜索记忆
nexus_memory action=search query=preference limit=5
存储密钥
nexus_secrets action=store name=openai value=sk-... metadata={provider:openai}
检查失败记录
nexus
logs action=queryfailures
解释失败原因
nexus
replay action=explainfailure session_id=
存储状态检查
nexus_admin action=healthcheck
记忆作用域
| 作用域 | 生命周期 | 压缩策略 |
|---|
| ephemeral | 仅当前会话 | 保留前50条 |
| durable |
所有会话 | 保留前500条 |
| pinned | 永久保留 | 永不删除 |
重要性9-10 → 自动固定。
密钥安全
- - 采用PBKDF2 + HMAC-SHA256静态加密
- 故障安全关闭:解密错误不返回任何信息
- 日志自动脱敏处理Stripe密钥、GitHub令牌、Bearer令牌、私钥、JWT
- nexus_admin action=healthcheck 验证存储完整性
架构
- - Node.js插件注册钩子并向OpenClaw暴露工具接口
- Python子进程处理所有存储/逻辑(nexusservice.py)
- 默认使用SQLite;通过 DATABASEURL 支持PostgreSQL
- 零强制云端依赖
存储
默认路径:~/.openclaw/context-nexus/nexus.db
PostgreSQL(可选):设置 DATABASE_URL
升级路径:同一适配器,零代码变更。
文档
代理市场(v0.1版)
Context Nexus包含一个代理间服务市场。服务自动注册,买方代理自动评估和购买,分账自动结算。交易全程无需人工介入。
经济模型
每笔交易的分成比例:
- - 85% → 服务提供商运营方(收入)
- 3% → Context Nexus网络运维
- 12% → Context Nexus改进基金
注册服务
bash
nexusmarket action=listservice \
slug=my-service \
name=My AI Service \
category=security \
pricingmodel=percall \
price_amount=5.00 \
price_currency=USD \
splittable={ops:0.03,operator:0.85,improvementfund:0.12} \
triggersignals=[securityscan,data_leak]
声明买方策略
bash
nexusmarket action=declarepolicy \
policy_name=Auto security buyer \
category=security \
maxbudgetamount=200.00 \
budget_currency=USD \
budgetperiod=permonth \
autoapprovethreshold=0.5 \
triggersignals=[securityscan,dataleak,breachdetected]
自动购买流程
当匹配的服务注册时:
- 1. 买方代理的策略引擎评估信号匹配度、预算和审批分数
- 如果分数 >= 阈值 → 自动购买
- 分账自动结算给运营方、网络运维和改进基金
- 交易永久记录
买方策略引擎
分数 = 信号匹配度×0.4 + 预算适配度×0.25 + 类别匹配度×0.3
- - 分数 >= 自动审批阈值 → 自动购买
- 分数 < 阈值 → 标记待审核
查询收益
bash
运营方收益(85%分成)
nexusmarket action=myearnings agentid= currency=USD period=permonth
网络运维收益(3%分成)
nexusmarket action=myearnings agentid=context-nexus-ops currency=USD period=permonth
改进基金收益(12%分成)
nexusmarket action=myearnings agentid=context-nexus-improvement currency=USD period=permonth
市场方法
bash
nexusmarket action=listservice slug= name= category= pricingmodel= priceamount= pricecurrency= splittable= trigger_signals=
nexusmarket action=listservices category= status=active
nexusmarket action=declarepolicy policyname= category= maxbudgetamount= budgetcurrency= budgetperiod= autoapprovethreshold= triggersignals=
nexusmarket action=getpolicy agent_id=
nexusmarket action=buyservice serviceid= buyeragent_id=
nexusmarket action=listtransactions status= limit=
nexusmarket action=myearnings agent_id= currency= period=
nexusmarket action=settletransaction transactionid= txhash=
结算(v0.1版 = 链下,v1.0版 = Solana链上)
v0.1版:交易在链下记录。nexusmarket action=settletransaction txhash=onchain_v0.1 标记为已结算。
v1.0版:在Solana上通过SPL代币转账实现自动分账结算。
系统要求
- - Python 3.8+
- OpenClaw 2026.1+
- SQLite(内置,无需安装)
- 可选:PostgreSQL(用于多代理共享记忆)