I open-sourced the part of a proactive AI assistant that decides when not to speak
说明与用途
开源的主动 AI 助手抑制模块,包含 12 条检查、原子预算控制和策略仿真。
问题
Proactive AI assistants often lack a robust mechanism to decide when not to speak, leading to unwanted or poorly timed messages.
结果
The open-source gate provides a single, ordered set of suppression checks, logs detailed reasons for rejections, enforces daily budgets atomically, and allows policy replay and simulation, enabling reliable proactive messaging.
工作流
- Install the gate:
npm install proactive-gate - Create a gate with a Redis store and default checks:
createGate({store:new RedisStore(redis), checks:defaultChecks({dailyLimit:3, quietHoursFloor:'high'}), onDecision:d=>log.info('gate',d)}) - Evaluate a candidate:
const decision=await gate.evaluate({user,candidate}) - If allowed and commit succeeds, send the message:
if(decision.allowed && await gate.commit(decision,{user,candidate})) await send(decision.surfaces,candidate.payload) - Use
npx proactive-gate simulateto replay traffic and analyze policy impact before shipping. - Define policies as JSON files and replay with
npx proactive-gate replay --policy policy.jsonto test new rules. - Handle store errors by configuring
onStoreErrorto either allow or reject on failure.
证据
Zero dependencies, TypeScript, Node 20 or newer.
The budget is enforced at send time, not at evaluate time
When Redis is down, the default lets the candidate through and writes outcome: "skip"
- 记录日期: 2026-09-18T05:30:32.507Z