MasterAgent

OpenSparXApache-2.0活跃维护

在 Qualcomm NPU 上本地运行 AI Agent 的 C++ 框架,延迟低于 100ms,完全不依赖云端,适合车载、嵌入式和 IoT 场景。

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

v2.1.15发布于 2026-08-12 11:57 UTC979star37fork同步于 2026-11-07 07:32 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/OpenSparX/MasterAgent.git
cd MasterAgent
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel 4
./build/cli/sparx demo automotive
硬件要求按 README 说明

README 未说明具体显存或 GPU 型号要求;演示与确定性技能无需模型、网络或车辆硬件即可运行,模型推理需自行启动本地 llama-server。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

本地优先的 C++17 智能体运行时,先匹配确定性技能再按需调用模型

在 Qualcomm NPU 上本地运行 AI Agent 的 C++ 框架,延迟低于 100ms,完全不依赖云端,适合车载、嵌入式和 IoT 场景。

核心能力

  • 先匹配精确短语技能,未命中才调用模型
  • 工具名与参数强制校验,非法输出直接报错
  • 可选 SQLite 持久化,支持请求去重与崩溃恢复
  • 提供可安装的 CMake SDK 与 sparx CLI
  • 内置 HTTP 适配器对接本地 llama-server

容易踩的坑

CLI 不会自动下载或启动模型,需自行准备 GGUF 并另起 llama-server;HTTP 适配器依赖 libcurl、持久化依赖 SQLite 开发包,缺失需关闭对应开关;持久化只保存执行回执,模拟器状态仍随进程重启重置。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

3 个版本v2.1.15
  1. v2.1.15最新正式版2026-08-12 · 2026-08-12 11:57 UTC
  2. v2.1.142026-08-12 · 2026-08-12 08:49 UTC
    查看更新说明
  3. v2.1.62026-08-10 · 2026-08-10 22:09 UTC
    查看更新说明

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    OAK / MasterAgent

    An embeddable, local-first C++17 agent runtime: turn input into validated tool execution, with deterministic skills before model inference.

    0.4.0-alpha.3 — open reference runtime with contextual tools and durable receipts. Public source now builds a working sparx CLI and an installable C++ SDK. This is a small synchronous runtime, not the proprietary durable kernel described by the legacy interfaces.

    中文:开源版现可独立构建、运行,并作为 C++ SDK 集成。先匹配确定性技能,再按需调用模型; 工具名称和参数必须通过校验。默认使用内存;显式启用 SQLite 后,支持跨重启请求去重、历史恢复、UNKNOWN 故障恢复和人工对账。

    Quick start

    Requires CMake 3.18+, C++17, and libcurl development files for the optional HTTP adapter, plus SQLite development files for durable storage. Tests/packaging require Python 3. The release CI targets Linux and macOS.

    git clone https://github.com/OpenSparX/MasterAgent.git
    cd MasterAgent
    # Ubuntu HTTP dependency: sudo apt-get install libcurl4-openssl-dev libsqlite3-dev
    cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
    cmake --build build --parallel 4
    ctest --test-dir build --output-on-failure
    ./build/cli/sparx demo automotive
    

    The demo sets an in-memory simulated AC temperature, then reads it back. It needs no model, credentials, network, or vehicle hardware. Each output is JSON.

    ./build/cli/sparx run --input '把空调调到22度'
    ./build/cli/sparx run --input 'vehicle status'
    

    Each process starts a new demo state. To preserve state between requests in a single process, run sparx run and enter one input per line until EOF. An unmatched phrase returns NO_ROUTE unless a model is explicitly configured.

    Use an existing local model server

    Start a compatible llama-server separately with your chosen GGUF model, then:

    ./build/cli/sparx run --endpoint 127.0.0.1:8080 --model local \
      --input 'Set the AC to 24 degrees'
    

    The adapter sends non-streaming /v1/chat/completions requests. The runtime asks for a JSON response or a single tool call, rejects unknown tools and invalid arguments, and returns the actual tool result. Model compliance depends on the model; malformed output produces an error, never a guessed tool call. No model is downloaded or started by this CLI. A full HTTP(S) endpoint URL may also be provided explicitly; no cloud fallback happens automatically.

    A request timeout can be set with --timeout-ms 3000. To use an authenticated endpoint, pass the environment-variable name via --api-key-env MODEL_API_KEY; credentials are not supplied as CLI arguments.

    For an SDK and deterministic CLI without libcurl:

    cmake -S . -B build-offline -DMASTER_AGENT_ENABLE_HTTP=OFF -DBUILD_EVAL=OFF
    cmake --build build-offline --parallel 4
    

    Persist requests and recover interrupted tools

    ./build/cli/sparx run --state ./state/agent.db --session alice --request-id ac-001 \
      --input 'set AC to 22 degrees'
    ./build/cli/sparx recover --state ./state/agent.db
    

    Repeating the same request after restarting returns the recorded outcome without calling the tool again. Unfinished requests become UNKNOWN, require external verification, and can be explicitly reconciled. A database failure blocks further execution instead of silently switching to memory. See the recovery guide for JSONL input, ownership locks, audit notes, backups and failure behavior.

    Only execution receipts/history are persisted; the AC simulator itself still resets on process restart. There is no transaction spanning a real device and SQLite, so this is not a distributed exactly-once guarantee. Storage is not encrypted.

    To omit both optional dependencies, build with MASTER_AGENT_ENABLE_HTTP=OFF and MASTER_AGENT_ENABLE_STORAGE=OFF.

    Embed the SDK

    cmake --install build --prefix "$PWD/install-sdk"
    cmake -S examples/reference_agent -B build-consumer \
      -DCMAKE_PREFIX_PATH="$PWD/install-sdk"
    cmake --build build-consumer
    ctest --test-dir build-consumer --output-on-failure
    

    Consumer CMake:

    find_package(MasterAgent CONFIG REQUIRED)
    target_link_libraries(your_app PRIVATE MasterAgent::Core)
    # Optional HTTP adapter:
    # target_link_libraries(your_app PRIVATE MasterAgent::Http)
    

    The public reference API is in reference_runtime.h. Register a tool with a supported parameter schema and callback, register exact phrase skills, optionally set a model callback, then call Runtime::run(). See the integration contract for errors, schema support, sessions, request replay, and concurrency limitations.

    Connect a business tool

    Context-aware tools receive the session/request identity, a stable scoped idempotency key, deadline and cooperative cancellation signal. They return an explicit committed, failed or unknown outcome. The existing registerTool() API remains available. See the execution contract.

    The inventory example talks to a separate HTTP service that commits inventory and an idempotency receipt in its own SQLite database. Its integration test deliberately drops a response after commit, checks UNKNOWN recovery, reconciles against the service receipt and proves no second stock decrement after either process restarts. This is a local business-service integration example, not a real-model or third-party production validation.

    Capability status

    CapabilityPublic reference release
    Deterministic exact-phrase skillsAvailable, no model required
    Host-defined tools and argument validationAvailable; primitive object schema subset
    Execution context and typed tool outcomesAvailable; identity, deadline, cooperative cancellation, committed/failed/unknown
    Independent HTTP business exampleInventory service with atomic idempotency and lost-response recovery
    Local model HTTP adapterAvailable when built with libcurl
    Sessions and request deduplicationIn memory, or persistent SQLite receipts/history with explicit opt-in
    Crash recovery and reconciliationInterrupted single requests become UNKNOWN; explicit evidence-based reconciliation
    CLI and relocatable CMake SDK packageBuilt and exercised by CI
    Speculation, mesh, verification, learning, decodingExperimental modules and synthetic evaluations; not wired into the reference CLI
    Edge/cloud harnessExperimental; explicit opt-in; bounded outstanding inference workers
    Multi-step durable DAG and legacy kernel factoriesNot supplied by this reference runtime
    Qualcomm QNN/Genie integrationPlatform integration required; not verified by this release
    Production encryption / DP learning guaranteesNot claimed for this release

    Other headers under include/master_agent/ describe legacy kernel contracts; including them does not mean their factories have public implementations. Use master_agent::reference for the supported open runtime entry point.

    Tests, evaluations, and releases

    ctest --test-dir build --output-on-failure
    bash eval/run_all.sh
    bash scripts/package.sh build dist/sparx-sdk.tar.gz
    

    Evaluations use synthetic workloads (learning includes a simulated model), not end-to-end evidence for real-model latency, personalization, or NPU performance. Results are written to build/eval-results/. Missing or failed evaluations return a nonzero status. BUILD_EVAL=OFF excludes them from an SDK-only build.

    The package script installs the SDK and CLI, unpacks the archive in a new location, runs the demo, and builds an external consumer before publishing the archive. The archive also includes the inventory example; HTTP/storage-enabled packages build and exercise it after unpacking. The archive includes BUILD_INFO.json and a SHA-256 sidecar. The package uses platform system dependencies, including libcurl and SQLite when enabled; it is not a universally static binary.

    Contributing

    See CONTRIBUTING.md. Changes must keep Release assertions active and pass the CLI, HTTP protocol fixture, installed consumer, and runtime failure tests. Hardware and actual model validation should record the model, quantization, device, workload, and latency distribution separately.

    Apache-2.0. See LICENSE.