← 返回 Skills 市场
mars375

ChromaDB Agent Router

作者 Mars375 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
101
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install chromadb-agent-router
功能描述
Local semantic message routing for multi-agent systems. Routes messages to the correct agent based on embeddings + keyword + context scoring. No external API...
使用说明 (SKILL.md)

Semantic Router — Local Agent Message Routing

Route messages to the correct agent in a multi-agent system using a 3-layer scoring architecture:

  1. Embedding similarity (ChromaDB) — semantic understanding
  2. Keyword scoring — exact domain matches
  3. Action verb stratification — "deploy" always → ops, "secure" → security

Why This Exists

Most agent routers either:

  • Call external APIs (latency, cost, privacy)
  • Use simple keyword matching (inaccurate)
  • Don't understand French/English bilingual queries

This router runs entirely locally in ~1.5ms per query with 100% accuracy.

Quick Start

1. Define Your Routes

Create a routes configuration file (JSON or Python dict):

ROUTES = {
    "ops": {
        "agent": "orion",
        "descriptions": [
            "Deploy and manage infrastructure and Docker containers",
            "Install, configure, and restart services",
            "DevOps operations, CI/CD, deployment pipelines",
        ],
        "keywords": ["deploy", "install", "docker", "compose", "container", "restart"],
        "action_verbs": ["déploie", "installe", "configure", "redémarre"],
    },
    "security": {
        "agent": "aegis",
        "descriptions": [
            "Security audits, vulnerability scanning, hardening",
            "Firewall rules, SSL certificates, access control",
        ],
        "keywords": ["security", "firewall", "ssl", "vulnerability"],
        "action_verbs": ["sécurise", "hardened"],
    },
    # ... add more routes
}

2. Initialize and Route

from semantic_router import SemanticRouter

router = SemanticRouter(routes_config="routes.json")
router.initialize()  # Builds ChromaDB index (~6s cold start, then cached)

result = router.route("Deploy the new monitoring stack on the homelab")
# → {"route": "ops", "agent": "orion", "confidence": 0.94}

3. Use in OpenClaw

# Start the API server
python3 scripts/router-api.py --port 8321

# Route a message
curl -X POST http://localhost:8321/route \
  -H "Content-Type: application/json" \
  -d '{"message": "Check the firewall logs for suspicious activity"}'

Architecture

Input Message
    │
    ├─► French Normalization (accent handling, verb mapping)
    │
    ├─► Layer 1: Embedding Similarity (ChromaDB)
    │   └─ cosine similarity against route descriptions
    │
    ├─► Layer 2: Keyword Scoring
    │   └─ exact/substring match with keyword-stealing avoidance
    │
    ├─► Layer 3: Action Verb Stratification
    │   └─ ops verbs → always override topic
    │   └─ topic verbs → override but route-specific
    │   └─ weak verbs → let embeddings decide
    │
    └─► Weighted Fusion → Route Selection

Scoring Formula

final_score = (0.4 × centroid_sim) + (0.3 × max_example_sim) + (0.3 × keyword_score) + action_boost

Where action_boost is additive for matched action verbs, allowing override of embedding scores.

Key Design Decisions

  1. No external API — Everything runs locally via ChromaDB + default embeddings
  2. Keyword stealing prevention — A keyword appears in exactly ONE route
  3. French normalization before action detection — Normalize accents but detect verbs on original text
  4. Cache to disk — Embeddings persist in /tmp/semantic_router_cache/
  5. Action verb stratification — The breakthrough from 92.7% to 100%

API Endpoints

Endpoint Method Description
/route POST Route a single message
/batch POST Route multiple messages
/benchmark POST Run accuracy benchmark
/stats GET Usage statistics
/routes GET List configured routes
/health GET Health check

Performance

Metric Value
Accuracy (benchmark) 100% (41/41 messages)
Query latency ~1.5ms (cached)
Cold start ~6s (embed routes)
Memory ~50MB
ARM64 compatible ✅ (tested on Raspberry Pi 5)

Use Cases

  • Multi-agent orchestration — Route user messages to specialized agents
  • Message bus routing — Front-load balancer for agent mesh networks
  • Intent classification — Classify support tickets, requests, commands
  • Bilingual routing — French/English queries handled natively

Files

semantic-router/
├── SKILL.md              ← This file
├── scripts/
│   ├── semantic_router.py    ← Core router library
│   └── router-api.py         ← REST API wrapper
└── references/
    └── ROUTING-RESEARCH.md   ← Design notes and benchmarks

License

MIT — Use freely, attribution appreciated.

安全使用建议
This skill appears to implement a local ChromaDB-based router and mostly matches its description, but proceed with caution. Before installing: 1) Note the SKILL.md only declares chromadb and numpy, yet the API needs starlette and uvicorn — verify and install the full dependency list in a virtualenv (or container) rather than system-wide. 2) The skill writes embeddings to /tmp/semantic_router_cache; decide whether persisting embeddings on-disk is acceptable for your environment. 3) The router runs a localhost HTTP server (bound to 127.0.0.1) — that's safer than binding publicly, but confirm you don't expose the port via proxy or firewall. 4) The README claims '100% accuracy' on a small benchmark — treat that as an unverified marketing claim and validate with your own test dataset. 5) If you plan to use this in production or with sensitive data, run it in an isolated environment (container/VM) and pin package versions from trusted sources. Install only the packages you audit, and review or test the EXAMPLE_ROUTES to ensure no unintended routing of sensitive queries.
功能分析
Type: OpenClaw Skill Name: chromadb-agent-router Version: 1.0.0 The skill bundle implements a local semantic message router using ChromaDB for vector embeddings and a custom scoring logic involving keywords and action verbs. The implementation in `scripts/semantic_router.py` and the Starlette-based API in `scripts/router-api.py` are well-documented, follow the stated purpose, and operate entirely locally (binding to 127.0.0.1 and using local storage in `/tmp/semantic_router_cache`). No evidence of data exfiltration, malicious execution, or prompt injection was found in the code or the `SKILL.md` instructions.
能力评估
Purpose & Capability
Name/description align with required runtime (python3 + chromadb + numpy). The code implements a local ChromaDB-based router and exposes a localhost REST API, which is coherent with the stated purpose. However, the SKILL.md's metadata lists only chromadb and numpy as Python deps while the API wrapper requires additional packages (starlette, uvicorn) that are not declared—this is an inconsistency.
Instruction Scope
Runtime instructions (start API, POST /route) and the included code stay within routing functionality. The skill does create a local REST endpoint and writes a ChromaDB persistent cache under /tmp/semantic_router_cache/, both of which are documented in SKILL.md. The code does not read environment variables or unrelated system files.
Install Mechanism
SKILL.md contains a pip install step for chromadb and numpy (reasonable). But router-api.py and runtime require starlette and uvicorn (and possibly other transitives) which are not declared in the install metadata—this mismatch can cause broken installs or surprise network installs at runtime. Installing PyPI packages is moderate risk but acceptable if the exact packages/versions are declared; here they are not.
Credentials
The skill requests no environment variables, no credentials, and does not access system configs beyond writing a cache directory under /tmp. That level of access is proportionate to a local embedding indexer.
Persistence & Privilege
The skill persistently stores embeddings to /tmp/semantic_router_cache/chromadb (documented). It runs a local HTTP server bound to 127.0.0.1 (not public). 'always' is false. Storing cache on disk and running a localhost API are reasonable for this purpose but users should be aware of on-disk persistence of embeddings and route data.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install chromadb-agent-router
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /chromadb-agent-router 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release — local multi-agent routing with ChromaDB, 100% accuracy, bilingual FR/EN, ARM64
元数据
Slug chromadb-agent-router
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

ChromaDB Agent Router 是什么?

Local semantic message routing for multi-agent systems. Routes messages to the correct agent based on embeddings + keyword + context scoring. No external API... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 101 次。

如何安装 ChromaDB Agent Router?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install chromadb-agent-router」即可一键安装,无需额外配置。

ChromaDB Agent Router 是免费的吗?

是的,ChromaDB Agent Router 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

ChromaDB Agent Router 支持哪些平台?

ChromaDB Agent Router 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 ChromaDB Agent Router?

由 Mars375(@mars375)开发并维护,当前版本 v1.0.0。

💬 留言讨论