Tools
Model Totem
OpenClaw plugin: inject custom messages when session model matches configured rules
Configuration Example
{
"plugins": {
"allow": ["model-totem", "..."]
}
}
README
# model-totem
OpenClaw plugin that injects custom messages before the assistant turn when the session's current model matches a configured rule.
Useful for giving models behavioral reminders (e.g., "don't fabricate data") on a configurable interval.
## Features
- **Multi-rule support** — define multiple model→message rules, evaluated in order (first match wins)
- **Hot-reload config** — edits to `model-totem.config` take effect on the next turn without restart
- **Per-rule intervals** — inject every N user messages (1 = every turn)
- **Session & agent targeting** — scope rules to specific agents or sessions using wildcard patterns
- **Exact or partial model matching** — match by full model name or substring
- **Session cleanup** — turn counters reset when a session ends
- **Legacy format support** — old flat config auto-wrapped into single-rule format
## Install
Copy the plugin directory into your OpenClaw extensions folder:
```bash
cp -r model-totem ~/.openclaw/extensions/
```
Then add `"model-totem"` to the `plugins.allow` list in `~/.openclaw/openclaw.json`:
```json
{
"plugins": {
"allow": ["model-totem", "..."]
}
}
```
Restart the gateway to load the plugin.
## Configuration
Create `model-totem.config` in the same directory as the plugin (or use the example provided).
### Rules format (recommended)
```json
{
"rules": [
{
"targetModel": "glm-4.7-flash",
"matchMode": "partial",
"customMessage": "[TOTEM] Be careful with assumptions.",
"intervalTurns": 3
},
{
"targetModel": "step-3.7",
"matchMode": "exact",
"customMessage": "[TOTEM] This is a premium model. Use it wisely.",
"intervalTurns": 1
}
],
"targetAgents": ["*"],
"targetSessions": ["*"],
"enabled": true
}
```
### Config fields
| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `rules` | array | `[]` | List of model→message rules. Evaluated in order; first match wins. |
| `rules[].targetModel` | string | `""` | Model name to match against. |
| `rules[].matchMode` | `"partial"` \| `"exact"` | `"partial"` | `partial` = case-insensitive substring match, `exact` = full match. |
| `rules[].customMessage` | string | `"[MODEL TOTEM] ..."` | Message to inject when this rule matches. |
| `rules[].intervalTurns` | number | `1` | Inject every N user messages (1 = every turn). |
| `targetAgents` | string[] | `["*"]` | Agent IDs to target. Use `["*"]` for all agents. Supports `*` wildcard. |
| `targetSessions` | string[] | `["*"]` | Session key patterns to target. Supports `*` wildcard. |
| `enabled` | boolean | `true` | Master on/off switch. |
### Legacy flat format (still supported)
```json
{
"targetModel": "glm-4.7-flash",
"matchMode": "partial",
"customMessage": "[TOTEM] Be careful.",
"intervalTurns": 2
}
```
This is automatically wrapped into a single-rule array.
## How it works
1. On each user message, the plugin reads `model-totem.config` (hot-reload).
2. It checks `targetAgents` and `targetSessions` filters.
3. It evaluates rules in order — the first rule whose `targetModel` matches the session's current model wins.
4. If the turn counter for that rule is divisible by `intervalTurns`, the `customMessage` is injected as `prependContext`.
5. The injected message appears in the assistant's context before it generates a response.
## License
MIT
tools
Comments
Sign in to leave a comment