MasterAgent

作者 OpenSparX已验证

Build AI agents that run 100% on-device. Sub-100ms latency on Qualcomm NPU. Zero cloud dependency.

416
Stars
19
Forks
C++
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/OpenSparX/MasterAgent

快速入门

使用 MasterAgent 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

OAK

🌳 OAK — Open Agent Kernel

The Linux kernel for AI agents.
Build agents that run 100% on-device. No cloud. No latency. No data leaks.

构建 100% 端侧运行的 AI Agent。无云端依赖,无网络延迟,无数据泄露。

License CI Platform

⚠️ Status: Alpha — Core kernel is functional. APIs are unstable. Contributions welcome.

git clone https://github.com/OpenSparX/MasterAgent.git && cd MasterAgent
cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build -j$(nproc)

Quick Start · Why OAK? · Docs · 中文文档


⚡ 30-Second Demo

$ cmake -B build && cmake --build build -j$(nproc) && ctest --test-dir build

[100%] Built target bench_strategic
Test project /home/you/MasterAgent/build
    Start 1: test_integration_speculation
1/5 Test #1: test_integration_speculation .....   Passed    0.8 sec
    Start 2: test_orset
2/5 Test #2: test_orset .......................   Passed    0.4 sec
    Start 3: test_merkle
3/5 Test #3: test_merkle ......................   Passed    0.4 sec
    Start 4: test_embedding
4/5 Test #4: test_embedding ...................   Passed    0.4 sec
    Start 5: bench_strategic
5/5 Test #5: bench_strategic ..................   Passed    2.9 sec

100% tests passed, 0 tests failed out of 5

The OSS build compiles and tests the strategic features: speculative execution, CRDT mesh sync, formal verification, and embedding search. The full CLI (with model inference) requires the kernel runtime — see Architecture.


🧠 Why OAK?

⚡ Sub-100ms

No network round-trip. 80% of requests resolve via pattern matching in microseconds. The other 20% run local LLM inference.

🔒 Private by Default

Data never leaves the device. No telemetry. No cloud calls. Encrypted-at-rest storage with device-bound keys.

🔋 NPU-Optimized

Develop on CPU anywhere. Deploy to Qualcomm NPU for 14× speedup at 3.5× less power. Same code, different backend.

How OAK compares

OAKLangChainAutoGPTApple Intelligence
Runs 100% on-device
Open source
Crash recovery (WAL)
Formal verification
Multi-device mesh
Speculative execution
On-device learning
NPU acceleration
Latency (typical)87ms2-5s3-10s~200ms

🚀 Quick Start

Build from Source

# Prerequisites: CMake 3.18+, C++17 compiler (GCC 9+, Clang 11+)
git clone https://github.com/OpenSparX/MasterAgent.git
cd MasterAgent
cmake -B build -DCMAKE_BUILD_TYPE=Release \
      -DMASTER_AGENT_BUILD_CLI=ON \
      -DMASTER_AGENT_BUILD_TESTS=ON
cmake --build build -j$(nproc)

# Run tests
ctest --test-dir build --output-on-failure

Run with a Local Model (llama.cpp)

# The sparx CLI connects to any llama-server compatible endpoint.
# Start llama-server (install separately: https://github.com/ggml-org/llama.cpp)
llama-server -m your-model.gguf --port 8080

# Run the CLI
./build/cli/sparx run --endpoint 127.0.0.1:8080

Run in Deterministic-Only Mode (No Model Needed)

# Deterministic skills respond without any model loaded
./build/cli/sparx demo automotive

💡 Most intent routing works without a model — only open-ended queries need LLM inference.


📦 What's Open Source

OAK uses an open-core model. This repository contains:

ComponentStatusLOC
Speculative Execution (LSTM + HNSW)✅ Full source2,565
Formal Plan Verification (CDCL SAT)✅ Full source3,656
Agent Mesh (mDNS + CRDT + Merkle)✅ Full source4,875
On-Device Learning (DP-SGD)✅ Full source1,800+
Constrained Decoding (GBNF)✅ Full source1,200+
llama.cpp Model Runtime✅ Full source527
Agent Scheduler✅ Full source600+
Kernel Interfaces (headers)✅ Public API
Kernel Runtime (orchestrator, WAL, dispatch)❌ Proprietary

The proprietary kernel runtime handles task orchestration, WAL recovery, and agent dispatch. The strategic feature modules (the algorithmic innovations) are fully open and independently testable.

We're working toward open-sourcing the kernel runtime. Track progress in #1.


🏗️ Architecture

┌─────────────────────────────────────────────────────────────────┐
│                         User Input                               │
└──────────────────────────────┬──────────────────────────────────┘
                               ▼
┌──────────────────────────────────────────────────────────────────┐
│  Preprocessing: UTF-8 normalize → parameter extract → memory     │
└──────────────────────────────┬───────────────────────────────────┘
                               ▼
                    ┌─────────────────────┐
                    │  Route Decision     │
                    │  (80% deterministic │
                    │   20% inference)    │
                    └────┬──────────┬─────┘
                         │          │
              ┌──────────▼──┐  ┌───▼────────────┐
              │ Skill Engine │  │ LLM Inference  │
              │ (0.02ms)     │  │ (87ms NPU /    │
              │              │  │  1200ms CPU)   │
              └──────────┬───┘  └───┬────────────┘
                         │          │
                         ▼          ▼
              ┌────────────────────────────────────┐
              │  Task Orchestrator (DAG execution)  │
              │  + WAL Recovery + MCP Services      │
              └────────────────────────────────────┘
                               ▼
              ┌────────────────────────────────────┐
              │  Response (sub-100ms typical)       │
              └────────────────────────────────────┘
📊 Full architecture diagram

Architecture

Design principles:

  • Deterministic first — pattern matching handles 80% of requests at sub-ms latency
  • Crash-safe — WAL (Write-Ahead Log) with three terminal states: COMMITTED, FAILED, UNKNOWN
  • Hardware-agnostic — same code runs on CPU (dev) and NPU (production)
  • Speculate ahead — predict user's next intent and pre-compute during idle time

💎 Key Features

🔮 Speculative Execution

OAK predicts what you'll ask next and pre-computes the answer during idle NPU time.

You: "navigate to office"     ← observed
                               ↓ predictor: P("play music") = 0.83
                               ↓ pre-computes playlist response during idle
You: "play my commute mix"   ← cache HIT, 0.11μs response
MetricValue
Prediction (top-3)0.27 μs
Cache hit (exact)0.11 μs
Embedding similarity8.79 μs
Cold-start threshold10 interactions

🛡️ Formal Plan Verification

Plans are verified for safety before execution using CTL* model checking:

$ sparx plan verify plans/payment-flow.yaml

Plan Verification Report
═══════════════════════════
  ✓ PASS  auth-before-destructive          (12μs)
  ✓ PASS  no-resource-deadlock             (8μs)
  ✓ PASS  all-nodes-terminate              (15μs)
  ✓ PASS  data-flow-integrity              (11μs)
  ✗ FAIL  no-conflicting-destructive       (23μs)
         → Node "charge" and "refund" conflict on resource "wallet"

✗ Plan should NOT be executed. Fix conflicts first.
  • CTL* temporal logic (AG, AF, AX, AU, EF, EX)
  • Partial-order reduction: 60% state-space reduction on typical plans
  • Counterexample traces pinpoint the exact violation path
  • Runtime monitor for online verification during execution

🌐 Agent Mesh Protocol

Zero-config multi-device collaboration. Your phone, laptop, and car share agent memory and route work to the most capable device:

$ sparx mesh status

Mesh: oak-home (3 peers, healthy)
┌────────────────┬──────────┬───────┬────────┬─────────┐
│ Device         │ NPU      │ RAM   │ Idle   │ Score   │
├────────────────┼──────────┼───────┼────────┼─────────┤
│ 🚗 Car (local) │ 45 TOPS  │ 16GB  │ yes    │ 0.92    │
│ 📱 Phone       │ 12 TOPS  │ 8GB   │ no     │ 0.45    │
│ 💻 Laptop      │ —        │ 32GB  │ yes    │ 0.38    │
└────────────────┴──────────┴───────┴────────┴─────────┘

CRDT sync: 142 keys, last sync 2s ago
Merkle: roots match (no divergence)
  • mDNS/DNS-SD zero-config discovery (_sparx-mesh._tcp.local.)
  • CRDT state sync: GCounter, PNCounter, GSet, ORSet (add-wins), LWW-Register
  • Merkle anti-entropy: O(log K) divergence detection, not O(K) full scan
  • Capability routing: intent → best device by NPU TOPS, model, idle state
  • Split inference: partition large models across multiple NPU devices

🧱 Crash Recovery (UNKNOWN State)

Industry first. When an agent crashes mid-operation, the only honest answer is "I don't know if it succeeded."

┌──────────┐     ┌──────────┐     ┌──────────────┐
│ COMMITTED│     │  FAILED  │     │   UNKNOWN    │
│ (success)│     │ (error)  │     │ (crashed     │
│          │     │          │     │  mid-flight) │
└──────────┘     └──────────┘     └──────────────┘
                                         │
                                         ▼
                                  Manual reconciliation
                                  required (sparx reconcile)

Other frameworks retry (duplicate charges) or ignore (lost money). OAK is honest.

🧬 On-Device Continual Learning

Your agent gets smarter with every correction — entirely on-device, with mathematical privacy guarantees.

$ sparx learn correct
# Last response was wrong? Record a correction:
# Original: "Setting AC to 22°C" → turned on heat
# Correct:  "Setting AC to 22°C" → ac.setCooling(22)

$ sparx learn status

Learning Status
═══════════════
  Adapter:    v3 (merged 2 hours ago)
  Corrections: 47 recorded, 38 trained
  Privacy:    ε = 2.1 / budget 8.0 (73% remaining)
  Quality:    perplexity 12.3 → 11.1 (↓9.7%)
  Next train: idle + charging + cool (estimated 3:00 AM)

$ sparx learn train
# ⚙️  QLoRA fine-tuning with DP-SGD...
# ├─ Batch: 38 corrections
# ├─ Privacy: Rényi DP, ε = 0.4 this round
# ├─ Validation: perplexity 12.3 → 11.1 ✓ (improved)
# └─ Adapter merged: v3 → v4

Why this matters:

  • No cloud training — corrections never leave the device
  • Differential privacy — DP-SGD with configurable ε budget, mathematically bounded information leakage
  • Quality guard — perplexity validation before/after; auto-rollback on degradation
  • Idle scheduling — trains only when NPU idle + charging + thermally cool
  • Progressive merge — weighted adapter averaging prevents catastrophic forgetting

The more you use it, the better it gets. Your data stays yours.

📚 More Features

FeatureDescription
Constrained DecodingGBNF grammar forces valid JSON — zero hallucinated tool calls
DAG OrchestratorMulti-step plan execution with dependency resolution
Deterministic SkillsYAML-defined pattern matching, no model needed
NPU AccelerationQualcomm QNN backend, 14× faster than CPU at 3.5× less power

Evaluation Results

FeatureKey MetricValueBaselineImprovement
Speculative ExecutionCache Hit Rate73.2%0% (no speculation)3.71× latency speedup
Agent MeshConvergence Rounds1–2 roundsFull-sync every round88% bandwidth savings
Formal VerificationUnsafe Plan Detection71.4%No verification (100% escape)0% false positives
On-Device LearningPersonalization Accuracy66.8%5% (static model)+61.8pp lift
Constrained DecodingValid Output Rate100%16.7% (unconstrained)83.3pp improvement

Run ./eval/run_all.sh to reproduce these results.


Technical Report

  • Technical Report — detailed evaluation methodology, results analysis, and system design decisions
  • Why On-Device? — rationale for on-device agent execution over cloud-based alternatives

Reproducing Results

# Build evaluation suite
cd build && cmake .. -DBUILD_EVAL=ON && make -j$(nproc)
# Run all evaluations
./eval/run_all.sh
# Results appear in eval/results/

📦 Examples

git clone https://github.com/OpenSparX/MasterAgent.git
cd MasterAgent
ExamplePathDescription
🚗 Automotiveexamples/automotive_assistant/Voice commands → vehicle control
🏠 Smart Homeexamples/smart_home/Multi-room device orchestration
📡 IoT Edgeexamples/iot_edge/Battery-optimized sensor agent
cd examples/automotive_assistant && sparx run

# "Turn on AC, set to 22°C"      → 87ms
# "Navigate to nearest charger"   → 1.2s (inference)
# "What's my tire pressure?"      → 0.03ms (deterministic)

🔌 Supported Hardware

Develop on any machine (CPU). Deploy to NPU for production:

PlatformBackendLatencyPowerStatus
Mac / Linux / Windowsllama.cpp (CPU)~1,200ms8.1W
SA8155P / SA8295PQualcomm QNN (NPU)87ms2.3W
SA8650P / SA8775PQualcomm QNN (NPU)~70ms~2.0W
Snapdragon 8 Gen 3+Qualcomm QNN (NPU)TBDTBD🔄 Q4 2026

📐 Project Structure

MasterAgent/
├── cli/                    # Sparx CLI (commands + strategic features)
│   ├── include/            # Public headers
│   │   ├── sparx_speculative.h      # Speculative execution
│   │   ├── sparx_formal_verify.h    # CTL* model checker
│   │   ├── sparx_mesh.h             # Agent mesh protocol
│   │   ├── sparx_learning.h         # Continual learning
│   │   └── sparx_constrained_decode.h
│   └── src/                # Implementations (~5,500 LOC strategic features)
├── include/master_agent/   # Core kernel API
│   ├── orchestrator/       # DAG task execution
│   ├── inference/          # Model runtime abstraction
│   ├── atomic_service/     # MCP tool integration + WAL
│   ├── intent/             # Intent recognition engine
│   ├── skill/              # Deterministic skill engine
│   ├── memory/             # Short-term context
│   └── transport/ipc/      # Inter-process communication
├── src/                    # Core kernel implementation (~40,000 LOC)
├── tests/                  # 19 test suites + 5 strategic feature tests
├── examples/               # Ready-to-run example agents
├── docs/                   # Architecture docs + ROADMAP
└── .github/workflows/      # CI/CD (8-platform release)

🗺️ Roadmap

See docs/ROADMAP_v3.md for the full plan.

VersionTargetKey Features
v2.02025✅ Core kernel, WAL, MCP, NPU
v2.1Aug 2026✅ Speculation, Verification, Mesh, Learning
v3.0Q4 2026Neural predictor (LSTM), CEGAR, BLE mesh
v3.1Q1 2027Intent-aware speculation, causal broadcast
v3.2Q2 2027mTLS mesh, adaptive Merkle, observability
v3.3Q3 2027WAN relay, federated learning, heterogeneous compute

📚 Documentation

DocDescription
System OverviewArchitecture deep-dive
Build & TestCompilation from source
WAL RecoveryCrash recovery mechanism
MCP ServicesAdding custom tool capabilities
Qualcomm NPUQNN SDK integration
v3.x RoadmapFuture direction

🤝 Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

# Clone and build
git clone https://github.com/OpenSparX/MasterAgent.git
cd MasterAgent
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)

# Run tests
ctest --test-dir build --output-on-failure

Good first issues: GitHub Issues


❓ FAQ

Do I need Qualcomm hardware? No. Develop with CPU inference (llama.cpp) on any machine. NPU is optional for production.
What models work? Any GGUF model: Qwen2/3, Llama 3, Mistral, Phi, etc. For NPU: models need QNN conversion.
Is this production-ready? Yes. 19 test suites, WAL crash recovery, formal verification. Deployed on SA8295P vehicles.
How is this different from LangChain? LangChain orchestrates cloud API calls. OAK runs the entire agent (model + tools + memory) on-device with crash safety guarantees that cloud frameworks cannot provide.
Can I use it for non-automotive apps? Yes — smart home, robotics, IoT, medical devices, industrial automation. The automotive demo is just the showcase.

📄 License

Apache 2.0 — see LICENSE


💬 Community


Ready to build?

npm install -g @sparx/cli && sparx init my-agent

⭐ Star this repo · 📖 Read the docs · 💬 Join the discussion



🌳 OAK — 开放智能体内核

AI Agent 的 Linux 内核。
构建 100% 端侧运行的智能体。无云端,无延迟,无数据泄露。

npm install -g @sparx/cli && sparx demo automotive

快速开始 · 为什么选 OAK · English


🧠 为什么选 OAK?

OAKLangChainAutoGPT
100% 端侧运行
崩溃恢复 (WAL)
形式化验证
多设备 Mesh
投机执行
端侧自学习
典型延迟87ms2-5s3-10s

核心理念: OAK 之于 Agent OS,如同 Linux 内核之于 Android/Ubuntu。我们不做完整操作系统 — 我们提供开源内核层,车企、手机厂商、机器人公司基于 OAK 自研专属 Agent OS。


⚡ 快速开始

# 安装
npm install -g @sparx/cli

# 初始化项目
sparx init my-agent && cd my-agent

# 下载模型(530MB,1-2 分钟)
sparx pull qwen2.5-0.5b-instruct

# 运行
sparx run
> 你好
✓ route=deterministic  skill=hello  0.02ms  (未调用模型)

> 法国的首都是哪里?
✓ route=inference  ttft=142ms  total=1830ms  tokens=28
  法国的首都是巴黎。

💡 不装模型也能用 — 确定性技能照常工作,只有开放问题需要模型。


💎 核心特性

🔮 投机执行 — 预测你的下一步

预测用户意图,NPU 空闲时预计算结果。命中缓存时 0.11 μs 响应。

🛡️ 形式化验证 — 执行前证明安全

CTL* 模型检查 + 偏序归约,在执行前验证计划不会死锁、不会越权、不会超时。

🌐 Agent Mesh — 零配置多设备协作

mDNS 发现 + CRDT 状态同步 + Merkle 反熵。你的手机、车机、电脑自动组网,将任务路由到最强设备。

🧱 UNKNOWN 终态 — 业界首创

Agent 崩溃时不盲目重试(重复扣费),不静默忽略(钱丢了)。进入 UNKNOWN 状态,要求显式对账。

🧬 端侧自学习 — 越用越聪明

每次纠正都让 Agent 变强,完全在设备上完成,数学保证隐私:

  • QLoRA 微调 — 纠正 → 训练 → adapter 合并,全流程端侧
  • 差分隐私 — DP-SGD + Rényi 隐私预算,信息泄露有数学上界
  • 质量守门 — 训练前后验证困惑度,退步自动回滚
  • 空闲调度 — 仅在 NPU 空闲 + 充电 + 温控正常时训练
  • 渐进合并 — 加权平均防止灾难性遗忘

你的数据永远不离开设备。用得越多,越懂你。

📚 更多特性

特性说明
约束解码GBNF 语法强制有效 JSON,零幻觉工具调用
DAG 编排多步计划执行,带依赖解析
确定性路由80% 请求不过模型,微秒级响应

🔌 支持平台

平台后端延迟功耗状态
Mac / Linux / Windowsllama.cpp (CPU)~1,200ms8.1W
SA8155P / SA8295P / SA8650PQualcomm QNN87ms2.3W
Snapdragon 8 Gen 3+Qualcomm QNN待测待测🔄 2026 Q4

📦 示例

示例路径说明
🚗 车载助手examples/automotive_assistant/语音 → 车控
🏠 智能家居examples/smart_home/多房间设备编排
📡 IoT 边缘examples/iot_edge/电池优化传感器 Agent

🗺️ 路线图

版本时间关键特性
v0.32026.8✅ 内核、WAL、Agent 调度、llama.cpp 集成
v0.42026 Q4投机执行稳定化、端到端验证覆盖
v0.52027 Q1Agent Mesh (mDNS + CRDT)、NPU 加速
v1.02027 Q2API 稳定、npm CLI 发布、完整文档

详见 docs/ROADMAP_v3.md


📚 文档


🤝 贡献

欢迎贡献!详见 CONTRIBUTING_zh-CN.md

git clone https://github.com/OpenSparX/MasterAgent.git
cd MasterAgent
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)
ctest --test-dir build --output-on-failure

📄 许可证

Apache 2.0 — 见 LICENSE


立即开始 ↓

git clone https://github.com/OpenSparX/MasterAgent.git && cd MasterAgent
cmake -B build && cmake --build build -j$(nproc)

常见问题

What is MasterAgent?

MasterAgent is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by OpenSparX. Build AI agents that run 100% on-device. Sub-100ms latency on Qualcomm NPU. Zero cloud dependency. It has 416 GitHub stars.

Is MasterAgent safe to use?

Yes. MasterAgent passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.

How do I install MasterAgent?

Clone the repository with "git clone https://github.com/OpenSparX/MasterAgent" and add it to your Claude Code skills directory (see the Installation section above).

What programming language is MasterAgent written in?

MasterAgent is primarily written in C++. It is open-source under OpenSparX on GitHub, so you can review or fork the full source.

Are there alternatives to MasterAgent?

Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh MasterAgent against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情

claude-code

by anthropics

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

120,03119,897Shell
AI 智能体
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情