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 update identity

From Leeroopedia
Knowledge Sources
Domains Identity, Self_Improvement, Behavioral_Rules
Last Updated 2026-10-29 00:00 GMT

Overview

Concrete tool for self-updating the agent's identity by extracting behavioral rules from reflections and appending them to a Learned Behaviors section in SOUL.md.

Description

The update_identity handler lets the agent evolve its behavioral identity based on experience. It accepts either an explicit behavior rule string, or a reflection text from which it extracts a rule using the LLM via _extract_rule.

The _extract_rule(reflection) function sends the REFLECT_PROMPT to the active model (via call_llm), which asks it to distill the reflection into ONE concise behavioral rule (max 15 words, starting with a verb like Always/Never/Prefer/Check/Use). It takes the first non-empty line of the response.

The handler then reads ~/.hermes/SOUL.md, finds or creates the ## Learned Behaviors section, appends "- {rule} ({date})", and keeps only the latest MAX_LEARNED = 10 behaviors (oldest dropped).

The call_llm helper uses ctx.llm.complete with purpose="evey-identity" and strips thinking-model reasoning blocks.

Usage

Call this tool after completing a significant task, learning something new, or when the self-improve cron runs at 3am. Registered as update_identity on the evey_identity toolset.

Code Reference

Source Location

  • Repository: hermes-plugins
  • File: evey-identity/__init__.py
  • Lines: L17-147 (call_llm L32-43, REFLECT_PROMPT L69-78, _extract_rule L81-89, handler L92-140, schema L45-67)

Signature

def handler(args: dict, **kwargs) -> str:
    """
    Args:
        args: {
            reflection: str (required) - what was learned,
            behavior: str - explicit rule to add (optional, otherwise extracted via LLM)
        }
    Returns:
        JSON: {status: "updated"/"skipped"/"error", rule_added?, reflection, total_behaviors}
    """

def _extract_rule(reflection: str) -> str | None:
    """Use the active model to distill reflection into a behavioral rule. Returns first non-empty line."""

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

Import

from evey_identity import handler
# Or accessed via Hermes tool call: update_identity

I/O Contract

Inputs

Name Type Required Description
reflection str Yes What was learned; what worked or should change
behavior str No Explicit rule to add (if not provided, extracted from reflection via LLM)

Outputs

Name Type Description
status str "updated", "skipped", or "error"
rule_added str The behavioral rule that was added (on success)
reflection str Truncated reflection text (200 chars)
total_behaviors int Total learned behaviors in SOUL.md after update

Usage Examples

From Reflection (LLM Extracts Rule)

result = tool_call("update_identity", {
    "reflection": "The local model failed at code generation but excelled at summarization. I should route code tasks to the heavy model."
})
# {"status":"updated",
#  "rule_added":"Always route code generation tasks to the heavy model",
#  "reflection":"The local model failed at code generation...",
#  "total_behaviors":5}

Explicit Behavior Rule

result = tool_call("update_identity", {
    "reflection": "Learned to validate delegation results",
    "behavior": "Always validate delegation results before reporting"
})
# {"status":"updated","rule_added":"Always validate delegation results before reporting",
#  "total_behaviors":6}

SOUL.md Structure

# SOUL

You are an autonomous AI agent...

## Learned Behaviors
- Always route code generation tasks to the heavy model (2026-10-28)
- Always validate delegation results before reporting (2026-10-29)
- Prefer local models for research_quick tasks (2026-10-29)

Related Pages

Implements Principle

Requires Environment

Page Connections

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