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

Command icon 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

joshua1234511 created an issue. See original summary.

joshua1234511’s picture

joshua1234511 changed the visibility of the branch 1.0.x to hidden.

joshua1234511 changed the visibility of the branch 1.0.x to active.

joshua1234511’s picture

Assigned: Unassigned » joshua1234511
Status: Active » Needs review

Uses 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

joshua1234511’s picture

Issue summary: View changes

joshua1234511 changed the visibility of the branch 1.0.x to hidden.

joshua1234511’s picture

Assigned: joshua1234511 » Unassigned
Issue tags: +Needs manual testing
joshua1234511’s picture

joshua1234511’s picture

Status: Needs review » Fixed

Merged, will be out in the next release.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.