← Back to Plugins
Tools

Cost Aware Router

bgoertzel-sing By bgoertzel-sing 👁 43 views ▲ 0 votes

Reusable OpenClaw plugin for cost-aware model routing with per-day Fable budget guard and human-only override

GitHub

Configuration Example

{
  "fableMode": "off",
  "fableDailyBudgetUsd": 0
}

README

# OpenClaw Cost-Aware Intent Router

Reusable OpenClaw plugin for cost-aware model routing across routine, deep, and explicitly budgeted high-end model usage.

Current working target:

- routine chat → low-cost GLM-class model;
- substantive technical/coding/research work → GPT-5.5/default strong model;
- Claude Fable / Anthropic Fable → explicit or configured escalation only;
- Fable usage ledger → JSONL cost accounting without raw prompts, replies, API keys, or secrets;
- per-day Fable budget guard → defaults to `$0/day`, so no Fable spend occurs until a daily cap is configured;
- human-only per-day override → requires a same-day override object with `approvedBy` matching `human...`, a reason, and a higher limit.

## Files

- `index.js` — OpenClaw plugin entry point.
- `router-core.js` — pure routing, budget, and cost-accounting helpers.
- `index.test.js` — Node test suite for routing and budget behavior.
- `openclaw.plugin.json` — plugin metadata and config schema.
- `fable-routing-cost-tracking.plain` — Plain spec for the router.
- `fable-routing-cost-tracking.assumptions.md` — assumptions and open context.
- `fable-routing-cost-tracking.spec-review.md` — PlainSpecReviewer review summary.

## Safety defaults

Fable routing is fail-closed by default:

```json
{
  "fableMode": "off",
  "fableDailyBudgetUsd": 0
}
```

To allow explicit Fable requests within a daily cap:

```json
{
  "fableMode": "explicit",
  "fableDailyBudgetUsd": 25
}
```

To temporarily raise the cap for one local day by explicit human say-so:

```json
{
  "fableDailyBudgetOverride": {
    "date": "2026-07-04",
    "limitUsd": 100,
    "approvedBy": "human:ben",
    "reason": "approved focused proof/debugging run"
  }
}
```

Agent/bot-approved overrides are rejected by schema and by runtime logic.

## Test

```bash
node --test index.test.js
node --check router-core.js
node --check index.js
node -e 'JSON.parse(require("fs").readFileSync("openclaw.plugin.json", "utf8")); console.log("plugin json ok")'
```

## Status

Draft extracted from Benjamin Goertzel's OpenClaw research-agent workspace, July 2026. Anthropic/Fable model naming may need adjustment after API model discovery.

## License

MIT License. See [`LICENSE`](LICENSE).
tools

Comments

Sign in to leave a comment

Loading comments...