Black Box (Powered by TiDB Zero)
Overview
Black Box is an indestructible audit log for AI Agents. It acts as a "Flight Data Recorder" that streams critical actions, errors, and reasoning chains to a persistent cloud database (TiDB Zero) in real-time.
Security & Provisioning
- 1. Bring Your Own Database (Recommended): Set
TIDB_* environment variables. - Auto-Provisioning (Fallback): If no credentials are found, this skill uses the TiDB Zero API to create a temporary database for logging. The connection string is cached in
~/.openclaw_black_box_dsn.
Why use this?
- * Crash Survival: Local logs vanish when containers crash. Cloud logs persist.
- Audit Trail: Prove exactly what your agent did and why (compliance).
- Debugging: Retrieve the last 100 actions leading up to a failure.
Prerequisites
- * TiDB Credentials: Standard MySQL connection parameters (
TIDB_HOST, TIDB_USER, etc.). - Network: Outbound access to TiDB Cloud (port 4000).
Usage
1. Log an Event
Record a critical action or error:
CODEBLOCK0
2. Read Logs
Retrieve the last N logs (default: 10):
CODEBLOCK1
Schema
This skill creates a table
agent_logs with columns:
timestamp,
level,
message,
metadata (JSON).
黑盒(由TiDB Zero驱动)
概述
黑盒是AI智能体不可摧毁的审计日志。它充当飞行数据记录器,将关键操作、错误和推理链实时流式传输到持久化云数据库(TiDB Zero)。
安全与配置
- 1. 自带数据库(推荐): 设置TIDB*环境变量。
- 自动配置(备用方案): 若未找到凭据,此技能将使用TiDB Zero API创建临时数据库用于日志记录。连接字符串将缓存在~/.openclawblackboxdsn中。
为何使用此功能?
- * 崩溃生存: 容器崩溃时本地日志消失,云端日志持久保存。
- 审计追踪: 精确证明智能体的操作及原因(合规性)。
- 调试: 检索导致故障的最后100个操作。
前提条件
- * TiDB凭据: 标准MySQL连接参数(TIDBHOST、TIDBUSER等)。
- 网络: 对TiDB Cloud的出站访问(端口4000)。
使用方法
1. 记录事件
记录关键操作或错误:
bash
python {baseDir}/run.py --action log --level ERROR --message 系统即将崩溃:检测到内存泄漏
2. 读取日志
检索最后N条日志(默认:10条):
bash
python {baseDir}/run.py --action read --limit 20
数据模式
此技能创建名为agent_logs的表,包含以下列:timestamp(时间戳)、level(级别)、message(消息)、metadata(元数据,JSON格式)。