Hermes plugin that detects model refusals and deflections and retries the turn on a fallback model
Repo 0ldev/refusal, read from GitHub 1 d ago. 0ldev has not joined Take My Repo.
0ldev/refusal is a public repo on GitHub by 0ldev. Hermes plugin that detects model refusals and deflections and retries the turn on a fallback model. It declares the MIT license on GitHub. It is written mainly in Python, has 39 stars and last changed on 2026-11-20. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-23.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
A Hermes plugin that detects when a model refuses a request, or deflects to an educational alternative, and retries the turn on your configured fallback model.
Some primary models decline legitimate work, such as security research, penetration-testing help and malware analysis. Instead of leaving you with a dead-end reply, refusal reports the refusal to Hermes so the turn continues on the next model in your fallback chain.
stop_reason: refusal, finish_reason: content_filter) are recognized even though they carry no text.llm_execution and llm_request middlewares and four observer hooks (on_session_finalize, on_session_reset, on_session_delete, post_compaction), and never patches Hermes core.>= 0.22.3 (the requires_hermes floor in plugin.yaml)>= 3.10fallback_providers. Without one, a detected refusal ends the turn (see Behavior and disclosures).hermes plugins install refusal
hermes plugins enable refusal
To install from a local checkout:
ln -s "$(pwd)" ~/.hermes/plugins/refusal
hermes plugins enable refusal
Check that it loaded:
hermes plugins list
hermes plugins capabilities refusal
Out of the box the plugin only needs a fallback chain, configured in ~/.hermes/config.yaml (or with hermes fallback add):
model:
default: gemini-3.8-flash
provider: openrouter
fallback_providers:
- provider: anthropic
model: claude-haiku-4-5
The retry preprompt and its controls are plugin settings under plugins.entries.refusal.settings (the manifest declares a config_schema, so Hermes's settings form can render them). All of them are optional:
| Setting | Type | Default | What it does |
|---|---|---|---|
preprompt |
string | empty | Text appended to the system prompt after a refusal. Empty turns the whole preprompt feature off. |
preprompt_escalated |
string | empty | Text used instead of preprompt once the preprompt itself was refused (only with on_preprompt_refusal: escalate). Empty reuses preprompt. |
on_preprompt_refusal |
disarm | escalate | keep |
disarm |
What a refusal that happened with the preprompt does to the session. |
preprompt_scope |
turn | session |
turn |
How long a session stays armed. |
preprompt_models |
list of globs | empty (any) | Only send the preprompt to matching model or provider/model names. |
arm_on_native_refusal |
bool | true |
Also arm on provider-signalled refusals. |
persist_state |
bool | false |
Keep armed levels in Hermes's plugin state so they survive a restart and are shared between processes. See Persistence. |
max_armed_sessions |
int ≥ 1 | 1024 |
How many armed sessions are tracked at once. |
Environment: REFUSAL_PREPROMPT=0 (or off, false, no) disables arming and injection regardless of the settings. It is read at call time, so it works without a restart.
llm_execution middleware and calls the model as usual.tool_calls or Anthropic tool_use) are returned untouched.RefusalDetector checks the prose, ignoring fenced code blocks, against refusal, deflection and partial-answer patterns.finish_reason to content_filter (Anthropic: stop_reason to refusal).content_filter through its content-policy path and activates the next fallback model.Hermes does not let plugins register custom failover reasons, so a detected refusal appears under Hermes's own content_policy_blocked reason.
By default a refusal only triggers the fallback. If you set a preprompt, the retry is also made with your text in the system prompt:
plugins:
entries:
refusal:
settings:
preprompt: "<text appended to the system prompt after a refusal>"
preprompt_escalated: "<optional: used instead after the preprompt itself was refused>"
on_preprompt_refusal: disarm # disarm | escalate | keep
preprompt_scope: turn # turn | session
preprompt_models: [] # e.g. ["google/gemini-*"]; empty = any model
arm_on_native_refusal: true
persist_state: false # opt in to survive restarts / share between processes
max_armed_sessions: 1024
You are responsible for the text you configure: it is sent to your model provider, and you must comply with that provider's usage policy.
Each session has a level: 0 (unarmed), 1, or 2.
A refusal on a request that did not carry the preprompt sets the session to level 1.
An llm_request middleware appends the text for the current level to the system prompt of later requests in the session, including the fallback retry. The first call of a turn in an unarmed session is untouched, so a refusal on it is genuine.
If a request that did carry the preprompt is refused too, on_preprompt_refusal decides:
disarm: back to level 0, the preprompt is no longer sent.escalate: level 2, which sends preprompt_escalated (or preprompt if empty).keep: the level stays as it is.Hermes moves on to the next fallback entry in every case. A refusal from a model the preprompt was not sent to (see preprompt_models) does not count as "despite the preprompt".
With preprompt_scope: turn the level is forgotten when the next user turn starts. With session it lasts until the session is finalized or reset. If Hermes gives no turn_id, turn behaves like session.
The ending session's armed state is dropped on on_session_finalize, on_session_reset (the old session id) and on_session_delete. When context compression rotates the session id, post_compaction carries the level (and a same-turn disarm) over to the new id. The last two hooks exist from Hermes 0.22.4; on older versions Hermes logs a one-line "unknown hook" warning at startup and never calls them (the plugin still works, see Limitations). At most max_armed_sessions sessions are tracked; the least recently armed is evicted first.
| Situation | Plugin does | Hermes does |
|---|---|---|
| Text refusal, no preprompt sent | Marks content_filter, level → 1 |
Falls back to the next chain entry |
| Provider-signalled refusal, no preprompt sent | Level → 1 (response untouched) | Falls back |
| Refusal despite the preprompt | Marks it, applies on_preprompt_refusal |
Falls back; with no entry left, shows the safety notice |
| Normal answer on an armed request | Logs answered with preprompt, level unchanged |
Continues |
| Tool-call response | Ignored | Continues |
Refusal with no session_id |
Marks it, does not arm | Falls back |
| No fallback configured | Arms anyway (it cannot see the chain) | Shows the safety notice |
The text is added where each provider reads its system prompt: the system message for chat completions, the top-level system field for Anthropic and Bedrock (string or text blocks; existing blocks and their cache_control markers are left intact), and instructions for Responses/Codex. The text is never stored, and the original request object is never mutated.
preprompt_models takes case-insensitive globs matched against the model name or provider/model, for example ["google/gemini-*", "claude-*"]. When set, the preprompt is only sent to matching models, so a last-resort backup on another vendor never receives it.
| Level | Message | Meaning |
|---|---|---|
| WARNING | Refusal detected (kind=…, reason=…, text=…, session=…, model=…, provider=…, api_request_id=…) |
A text refusal was matched and the response marked. The correlation fields are there so this line can be joined back to Hermes's own content_policy_blocked line — see Limitations |
| INFO | provider-signalled refusal (…) |
The provider flagged the response itself |
| INFO | preprompt armed (session=… level=1) |
First refusal in the session |
| INFO | preprompt injected (session=… level=… provider=… model=…) |
A request was modified |
| INFO | answered with preprompt (…) |
A request that carried the preprompt got a normal answer |
| WARNING | refused despite preprompt (…); mode=… -> level … |
The preprompt did not help |
| INFO | refused without preprompt (…); level unchanged |
Armed session, but this request was not sent the text (model filter or scope) |
| INFO | refusal detected without a session_id; preprompt not armed |
Hermes gave no session id |
Injected requests also carry source: refusal and a reason in Hermes's middleware trace.
By default armed levels live in process memory. With persist_state: true the plugin keeps them in Hermes's per-plugin state store (ctx.state, a JSON file state.json in this plugin's directory under <HERMES_HOME>/plugin-data/, written atomically under a cross-process file lock), so:
What is stored: a single list of [session_id, level, turn_id] rows, at most max_armed_sessions of them. No preprompt text, no message content and no credentials are stored. Rows are removed when a session is finalized or reset and when the cap evicts them.
Costs and caveats:
ctx.state also falls back, with a warning.Hermes skips fallback entries that resolve to the same backend as the current one (same provider + model), so to retry the same model the fallback entry must be a different route to the same model:
model:
default: gemini-3.8-flash
provider: openrouter
fallback_providers:
- provider: google # same model, different route -> preprompt retry
model: gemini-3.8-flash
- provider: anthropic # final backup if the preprompt retry also fails
model: claude-haiku-4-5
Call 1: openrouter/gemini-3.8-flash without the preprompt. Refusal → call 2: google/gemini-3.8-flash with preprompt. Refusal again → level 2 → call 3: the next chain entry (here anthropic/claude-haiku-4-5). To use preprompt_escalated on the same model, list two different routes to it in the chain (e.g. openrouter → google → a custom endpoint).
Injection happens at request time, and auxiliary calls (compression, titles) are unaffected — they do not pass through the agent's request middleware.
finish_reason, stop_reason) so that Hermes triggers failover. Provider-signalled refusals are not altered.0ldev/refusal is a public repo on GitHub by 0ldev. Hermes plugin that detects model refusals and deflections and retries the turn on a fallback model.
It declares the MIT license on GitHub.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2026-11-20. GitHub counts 0 open issues and pull requests. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.
Take My Repo cannot say: it does not audit code and has not run refusal. What is known comes from GitHub. It declares the MIT license on GitHub. Its last change was on 2026-11-20. It has 39 stars, which measure popularity, not safety. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read the source before you run it. With "Take it", your AI agent shows each step and asks you before running it; README text is treated as data, not as instructions.