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 autonomous reflect

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

Overview

Concrete tool for post-action quality scoring using heuristic signals — keyword overlap, response length, and error keyword detection — without any LLM cost.

Description

The autonomous_reflect handler scores the quality of a completed action's result using _heuristic_score(), a pure-Python heuristic that combines three signals:

  1. Keyword coverage: overlap between task words (minus stopwords) and the result text. ≥60% overlap adds 2 points, ≥30% adds 1, below 30% subtracts 1.
  2. Response length: <20 chars subtracts 2, <100 subtracts 1, >10000 subtracts 1, otherwise adds 1.
  3. Error keywords: if any of ERROR_KEYWORDS (error, fail, exception, traceback, timeout, refused, denied, unauthorized, crash) appear in the result, subtracts 2; otherwise adds 1.

The base score is 5.0, adjusted by these three signals, clamped to 1-10. The handler maps the score to a label (excellent/good/adequate/poor) and a suggestion, then logs the reflection via _log_decision.

Usage

Call this tool after completing a delegated task to assess output quality without spending tokens on an LLM validation call. Registered as autonomous_reflect on the evey_autonomy toolset.

Code Reference

Source Location

  • Repository: hermes-plugins
  • File: evey-autonomy/__init__.py
  • Lines: L553-633 (schema L553-565, heuristic_score L568-607, handler L610-633)

Signature

def reflect_handler(args: dict, **kwargs) -> str:
    """
    Args:
        args: {
            task_description: str (required) - original intent,
            result_text: str (required) - what was produced,
            model_used: str - which model did the work
        }
    Returns:
        JSON with status, score (1-10), label, assessment, suggestion
    """

def _heuristic_score(task: str, result: str) -> tuple[int, str]:
    """
    Heuristic quality scoring: keyword overlap + length + error detection.
    Returns (score 1-10, assessment string).
    """

Import

from evey_autonomy import reflect_handler
# Or accessed via Hermes tool call: autonomous_reflect

I/O Contract

Inputs

Name Type Required Description
task_description str Yes The original task intent
result_text str Yes What was produced by the action
model_used str No Which model did the work (used in suggestion text)

Outputs

Name Type Description
status str "reflected" or "error"
score int Quality score 1-10
label str "excellent" (≥9), "good" (≥7), "adequate" (≥5), "poor" (<5)
assessment str Semicolon-separated assessment reasons
suggestion str Next-step recommendation based on score

Usage Examples

Reflect on a Code Task

result = tool_call("autonomous_reflect", {
    "task_description": "Fix the authentication bug in login.py",
    "result_text": "Fixed the JWT token validation by adding expiry check. All tests pass.",
    "model_used": "claude-sonnet-4-20250514"
})
# Returns: {"status":"reflected","score":8,"label":"good",
#   "assessment":"Good keyword coverage; Appropriate length; No error indicators",
#   "suggestion":"Quality work. Run autonomous_decide for next priority."}

Detecting Poor Quality

result = tool_call("autonomous_reflect", {
    "task_description": "Write a comprehensive research report on quantum computing",
    "result_text": "Error: connection timeout",
    "model_used": "local-model"
})
# Returns: {"status":"reflected","score":2,"label":"poor",
#   "assessment":"Low relevance to task; Response too short; Error keywords found: error, timeout",
#   "suggestion":"Needs rework. Try a different approach or model (was: local-model)."}

Related Pages

Implements Principle

Requires Environment

Page Connections

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