Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:42 evey Hermes plugins validate output

From Leeroopedia
Knowledge Sources
Domains Validation, Hallucination_Detection, Quality_Assessment
Last Updated 2026-10-29 00:00 GMT

Overview

Concrete tool for validating LLM delegation results through pattern-based hallucination detection and LLM-assisted reliability scoring.

Description

The validate_output handler checks delegation results for hallucination signals using two complementary methods:

  1. Pattern-based checks: Scans the result text against HALLUCINATION_PATTERNS, a list of regex patterns that flag common hallucination indicators — knowledge cutoff references, capability denial while giving specifics, specific date/version claims, vague authority claims, and weasel words. Each match adds a flag.
  2. LLM-based scoring: Sends a structured VALIDATE_PROMPT to the user's active model (via call_llm) asking it to rate the response 0-10 for reliability. The response is parsed for SCORE: N.

The final score is the LLM score minus the number of pattern flags (clamped to 0+). Scores map to recommendations: ≥7 = TRUST, 4-6 = CAUTION, <4 = REJECT.

The call_llm helper uses ctx.llm.complete with purpose="evey-validate" and strips thinking-model reasoning blocks (<think>/<thinking>/<reasoning>) via a regex.

Usage

Call this tool after delegate_with_model to verify the delegation's output before trusting it. Registered as validate_output on the evey_validate toolset.

Code Reference

Source Location

  • Repository: hermes-plugins
  • File: evey-validate/__init__.py
  • Lines: L29-157 (call_llm L29-40, HALLUCINATION_PATTERNS L71-78, VALIDATE_PROMPT L80-94, handler L103-146)

Signature

def handler(args: dict, **kwargs) -> str:
    """
    Args:
        args: {
            task: str (required) - original task description,
            result: str (required) - delegation result to validate,
            model_used: str - which model produced the result
        }
    Returns:
        JSON: {score: 0-10, recommendation: "TRUST/CAUTION/REJECT...",
               llm_assessment: str, pattern_flags: list[str], model_used: str}
    """

def call_llm(prompt: str, max_tokens: int = 200, temperature: float = 0.3) -> str | None:
    """One completion on the user's active model. Returns text or None."""

# HALLUCINATION_PATTERNS: list[tuple[str, str]] — (regex_pattern, description)
# VALIDATE_PROMPT: str — template with {task}, {model}, {result} placeholders

Import

from evey_validate import handler
# Or accessed via Hermes tool call: validate_output

I/O Contract

Inputs

Name Type Required Description
task str Yes The original task description
result str Yes The delegation result to validate
model_used str No Which model produced the result (default "unknown")

Outputs

Name Type Description
score int Reliability score 0-10 (LLM score minus pattern flags)
recommendation str TRUST (≥7), CAUTION (4-6), or REJECT (<4)
llm_assessment str Raw LLM validation response
pattern_flags list[str] Descriptions of matched hallucination patterns
model_used str Echo of the input model

Usage Examples

Validating a Delegation Result

# After delegate_with_model returns a result
result = tool_call("delegate_with_model", {"goal": "What version of Python added match/case?"})
delegation = json.loads(result)

validation = tool_call("validate_output", {
    "task": "What version of Python added match/case?",
    "result": delegation["result"],
    "model_used": delegation["model_used"]
})
# {"score":8,"recommendation":"TRUST — output looks reliable",
#  "llm_assessment":"SCORE: 8 | ISSUES: None, verifiable fact",
#  "pattern_flags":[],"model_used":"active-model"}

Detecting Hallucination

validation = tool_call("validate_output", {
    "task": "List the top 5 competitors to Acme Corp",
    "result": "As of my last knowledge cutoff, Acme Corp has 5 competitors: ...",
    "model_used": "free-model"
})
# {"score":3,"recommendation":"REJECT — high hallucination risk, re-delegate with better model",
#  "pattern_flags":["knowledge cutoff reference"],
#  "model_used":"free-model"}

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment