MasterAgent README

The project's README from github.com/OpenSparX/MasterAgent. As one markdown file: README.md.

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

Capability Public reference release
Deterministic exact-phrase skills Available, no model required
Host-defined tools and argument validation Available; primitive object schema subset
Execution context and typed tool outcomes Available; identity, deadline, cooperative cancellation, committed/failed/unknown
Independent HTTP business example Inventory service with atomic idempotency and lost-response recovery
Local model HTTP adapter Available when built with libcurl
Sessions and request deduplication In memory, or persistent SQLite receipts/history with explicit opt-in
Crash recovery and reconciliation Interrupted single requests become UNKNOWN; explicit evidence-based reconciliation
CLI and relocatable CMake SDK package Built and exercised by CI
Speculation, mesh, verification, learning, decoding Experimental modules and synthetic evaluations; not wired into the reference CLI
Edge/cloud harness Experimental; explicit opt-in; bounded outstanding inference workers
Multi-step durable DAG and legacy kernel factories Not supplied by this reference runtime
Qualcomm QNN/Genie integration Platform integration required; not verified by this release
Production encryption / DP learning guarantees Not 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.

MasterAgent (OpenSparX/MasterAgent)

Searching Database…

这是什么?MasterAgent (OAK) 是一个可嵌入、本地优先的 C++17 agent 运行时:它把输入转化为经过验证的工具执行,先运行确定性技能,无果再回退到模型推理。它面向车载、嵌入式/高通 NPU 硬件等场景的端侧 AI agent,默认零云依赖。
它是独立应用,还是要构建进我自己的代码里?它是一个通过 CMake 链接进你自己程序的 C++17 SDK,外加一个用于测试和演示的小型 “sparx” CLI——没有 GUI,也没有打包好的应用。
怎么试用?用 CMake 3.18+ 和 C++17 编译器构建,然后运行 sparx CLI 演示,它完全在内存里模拟空调温度控制——不需要模型、网络、凭据或真实车辆硬件。
构建它需要装好什么?CMake 3.18+、C++17 编译器,以及用于测试/打包的 Python 3。libcurl 开发文件只有可选的 HTTP 模型适配器需要,SQLite 开发文件只有持久化存储需要——两者都可以在构建时用 MASTERAGENT_ENABLE_HTTP=OFF / MASTERAGENT_ENABLE_STORAGE=OFF 关闭。
它已经能像宣传语说的那样在高通 NPU 上加速运行了吗?不能——这个公开参考版本是同步 CPU 运行时。高通 QNN/Genie 集成需要另外的平台开发工作,本版本明确声明未经验证;投机(speculation)、mesh、验证和学习等模块仍是实验性的,也没有接入 CLI。
实际能在哪些平台上构建它?发布 CI 在 Linux 和 macOS 上构建并测试;没有提到 Windows 是受支持的构建目标。
它会把我的数据发到云端吗?CLI 不会下载或启动任何模型,也没有自动的云端回退——只有你显式配置了远程端点时才会用到。
MasterAgent 如何在“运行技能”和“调用模型”之间做决定?它先尝试匹配确定性的精确短语技能,全程不涉及模型;只有匹配不到的短语才会触发模型调用,如果没有配置模型,就直接返回 NOROUTE。
如果工具调用被打断(比如执行到一半崩溃)会怎样?启用 SQLite 存储时,被打断的请求会标记为 UNKNOWN,必须对照外部证据显式核对;重启后重复同一请求会回放已记录的结果,而不是重新执行工具。
能接入我自己的本地 LLM 吗?可以——把它指向一个加载了 GGUF 模型、正在运行的 llama-server 实例;适配器发送非流式的 /v1/chat/completions 请求,并拒绝任何带未知工具或无效参数的响应。
它现在可以用于生产环境吗?不行——它的版本号是 0.4.0-alpha,存储未加密,能力表把学习、mesh、验证、解码和多步持久 DAG 标为实验性或本参考版本未提供。
Creator
OpenSparX
Size
18.6 MB
Stars
1K
Age
2mo
Commits · 90 Days