360 Secure SkillHub
360 安全技能中心

Speculative Exec

基于关键词与正则做意图分类和加权打分,预测下一步动作并在后台并行预加载相关资源,供代理实际需要时从缓存交付。以 Python 脚本提供命令行入口,支持传入消息、会话历史、自定义工作流训练与缓存状态查询,输出预测动作、置信度、预加载列表和预估节省时间。

分类:自动化
chen6896qqwee
chen6896qqwee
热度 13.80
最近更新 2026-07-10 09:47:50

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add chen6896qqwee/speculative-exec
兼容性
通用兼容
联网要求
联网要求未确认
数据出网
数据出网未确认
Metadata
name
speculative-exec
description
Speculative execution engine — predict and pre-load context the agent is likely to need next. Distilled from Claude Code speculation module.
metadata
{"openclaw":{"requires":{"bins":["python3"]}}}

Speculative Exec

Distilled from Claude Code speculation module. Predicts the next likely action and pre-loads the needed context in parallel with LLM response generation. Reduces perceived latency by 30-60% for common workflows.

When to use

  • User asks to "analyze" something → pre-load data sources
  • User asks to "read" a file → pre-load the file content
  • User asks to "search" → pre-load search index
  • User asks to "compare" → pre-load both items
  • User asks to "write" a report → pre-load template
  • Any repetitive workflow where the next step is predictable

How it works

  1. Pattern Recognition — Match user intent against known workflow patterns
  2. Context Prediction — Predict what files/data/tools will be needed
  3. Pre-load Queue — Start loading predicted resources in background
  4. Cache Delivery — When the agent actually needs the resource, serve from cache

Usage

# Start speculative pre-load based on user message
python3 {baseDir}/speculator.py --message "帮我分析这个股票"

# Predict next actions from conversation history
python3 {baseDir}/speculator.py --history conversation.json

# Train on custom workflow patterns
python3 {baseDir}/speculator.py --train workflows.json

# Check cache status
python3 {baseDir}/speculator.py --status

Output

{
  "prediction": "read_stock_data",
  "confidence": 0.92,
  "preloaded": ["stock_price", "financial_report", "news"],
  "estimated_save_ms": 1200
}

Built-in workflow patterns

Intent Pattern Predicted Next Action Pre-loads
分析/analyze Read data source Data files, reports
对比/compare Read both items Item A, Item B
搜索/search Search index Index files
写/write Template + context Templates, examples
修改/edit Read target file Target file
安装/install Read docs Documentation
测试/test Read test files Test files, fixtures
部署/deploy Read config Config files

Algorithm reference

Based on Claude Code speculation module:

  • Intent classification via keyword + regex patterns
  • Weighted prediction scoring
  • Parallel pre-load with timeout
  • Cache invalidation on context change
  • Confidence threshold gating (default: 0.7)