OpenClaw运行时优化系统 — 系级级安装,所有Agent统一受益
Runtime Optimizer(运行时优化)
text
Agent A ←┐
Agent B ←┼── OpenClaw运行时(统一优化) ← context-optimizer
Agent C ←┘
所有Agent间接受益,但不需要单独配置。
bash
# 微压缩测试
python3 scripts/microcompact.py --test
# 自动压缩测试
python3 scripts/auto_compactor.py --test
# 流式执行器测试
python3 scripts/streaming_executor.py --test
# Token预算测试
python3 scripts/token_budget.py --test
# 工具延迟加载测试
python3 scripts/tool_defer.py --test
# 处理消息文件
python3 scripts/microcompact.py messages.json
python3 scripts/auto_compactor.py messages.json
python3 scripts/streaming_executor.py tools.json
python3 scripts/token_budget.py status
python3 scripts/tool_defer.py --search "飞书"
python
from scripts.microcompact import MicroCompactor
from scripts.auto_compactor import AutoCompactor
from scripts.streaming_executor import StreamingToolExecutor
# 微压缩
compactor = MicroCompactor()
result = compactor.compact(messages)
print(f"节省 {result.savings_percent:.1f}% token")
# 自动压缩
auto = AutoCompactor(context_window=200_000)
if auto.should_compact(current_tokens):
result = auto.compact(messages)
messages = result.messages
# 流式执行
executor = StreamingToolExecutor(max_concurrent=5)
for tool in tool_calls:
await executor.add_tool(tool)
results = await executor.wait_all()
参数默认值说明similarity_threshold0.85消息相似度阈值min_message_length100最小合并长度context_window200_000上下文窗口大小safety_margin0.8压缩触发比例max_concurrent5最大并行工具数timeout_seconds30.0工具执行超时
MIT License