Steps to reproduce
The Drupal AI module (1.3.0+) provides an AI Guardrails system that can check AI responses before/after generation and block or rewrite them based on configurable rules. Currently there is no guardrail that evaluates the empathy quality of AI responses. This means AI-generated content with poor empathetic reasoning can pass through to end users unchecked.
As Dries states in the 2026 roadmap: AI must operate within structured governance frameworks. An empathy guardrail makes empathetic quality a first-class governance check.
Proposed resolution
Create a new submodule `ai_empathy_guardrail` that provides an "Empathy Score Check" guardrail plugin:
1. Submodule at `modules/ai_empathy_guardrail/` with dependency on both `ai_empathy` and `ai:ai` (guardrails infrastructure). This keeps the base module dependency-free.
2. `EmpathyScoreGuardrail` plugin class implementing `AiGuardrailPluginBase`, `ConfigurableInterface`, `PluginFormInterface`, `NonDeterministicGuardrailInterface`, and `NonStreamableGuardrailInterface`.
3. `processOutput()`: Extracts response text, calls `EmpathyScoringService::scoreResponseGeneral()`, compares empathy score against configured threshold. Returns `StopResult` if below, `PassResult` if above.
4. New method `scoreResponseGeneral()` on `EmpathyScoringService` — scores empathy without requiring a specific scenario entity (generic empathy assessment prompt).
5. Config form: Empathy threshold setting (1.0-5.0, step 0.1).
6. Pass/fail badge: Generate an "Empathy Certified" status for each provider/model combination.
Remaining tasks
- [x] Add `scoreResponseGeneral()` to `EmpathyScoringService`
- [x] Create submodule directory structure and `ai_empathy_guardrail.info.yml`
- [x] Implement `EmpathyScoreGuardrail` plugin class
- [x]Write unit tests for `scoreResponseGeneral()`
- [ ] Manual testing: enable submodule, create guardrail, add to guardrail set, verify blocking
- [x] Test that base module still works without the submodule enabled
Issue fork ai_empathy-3583738
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
joshua1234511Comment #3
joshua1234511Comment #6
joshua1234511Uses existing scoring infrastructure — the guardrail injects EmpathyScoringService rather than duplicating AI scoring logic
Non-deterministic + non-streamable — correctly declares that the guardrail uses AI (produces varying results) and needs the full response (can't work with streams)
Configurable threshold — admins set empathy threshold 1.0–5.0 via the guardrail config form
Comment #7
joshua1234511Comment #10
joshua1234511Comment #11
joshua1234511Comment #12
joshua1234511Merged, will be out in the next release.