| name | hermes-agent-framework |
| description | Expert guide for Nous Research's Hermes Agent framework with self-improving learning loops, three-layer memory, and automatic Skill creation |
| triggers | ["help me set up Hermes Agent","how do I use Hermes Agent framework","configure Hermes Agent memory system","create custom Skills for Hermes","build an AI agent with Hermes","Hermes Agent learning loop and tools","integrate Hermes Agent into my project","troubleshoot Hermes Agent issues"] |
Hermes Agent Framework
Skill by ara.so — AI Agent Skills collection.
Expert knowledge for working with Hermes Agent, the open-source AI Agent framework by Nous Research featuring built-in self-improving learning loops, three-layer memory system (episodic, semantic, procedural), and automatic Skill creation and evolution.
What is Hermes Agent?
Hermes Agent is a production-ready AI Agent framework released in February 2026 that differs from traditional agents (like OpenClaw/Claude Code) by implementing:
- Self-improving learning loop: Automatically learns from interactions and improves over time
- Three-layer memory system: Episodic (conversations), semantic (knowledge), procedural (Skills)
- Automatic Skill creation: Generates and evolves reusable capabilities
- Built-in tool ecosystem: Extensible plugin architecture for custom tools
Core philosophy: Agents should learn and improve themselves, not just execute tasks.
Installation
Prerequisites
- Python 3.10 or higher
- OpenAI API key (or compatible provider like Anthropic, local models)
- Git
Quick Start
git clone https://github.com/NousResearch/hermes-agent.git
cd hermes-agent
pip install -r requirements.txt
poetry install
cp .env.example .env
Environment Configuration
Create a .env file:
OPENAI_API_KEY=your_key_here
ANTHROPIC_API_KEY=your_key_here
HERMES_MODEL=gpt-4-turbo
HERMES_MODEL=claude-3-5-sonnet-20241022
HERMES_MEMORY_PATH=~/.hermes/memory
HERMES_ENABLE_SEMANTIC_MEMORY=true
HERMES_SKILL_PATH=~/.hermes/skills
Core Architecture
Three-Layer Memory System
from hermes_agent import HermesAgent, MemoryConfig
memory_config = MemoryConfig(
episodic_enabled=True,
semantic_enabled=True,
procedural_enabled=True,
memory_path="~/.hermes/memory"
)
agent = HermesAgent(
model="gpt-4-turbo",
memory_config=memory_config
)
Self-Improving Learning Loop
from hermes_agent import HermesAgent, LearningConfig
learning_config = LearningConfig(
enable_auto_learning=True,
reflection_interval=5,
skill_creation_threshold=3,
feedback_sensitivity=0.7
)
agent = HermesAgent(
model="gpt-4-turbo",
learning_config=learning_config
)
Basic Usage
Simple Conversation
from hermes_agent import HermesAgent
agent = HermesAgent(
model="gpt-4-turbo",
api_key=os.getenv("OPENAI_API_KEY")
)
response = agent.chat("Help me analyze this Python code for bugs")
print(response)
response = agent.chat("Now optimize it for performance")
print(response)
Using the CLI
python -m hermes_agent
hermes chat "What's the weather today?"
hermes chat --skill code-reviewer "Review my Python script"
hermes memory list
hermes skills list
hermes memory export --format json --output knowledge.json
Skill System
Creating Custom Skills
Skills are reusable procedures stored in the agent's procedural memory.
from hermes_agent import Skill, SkillParameter
code_review_skill = Skill(
name="code_reviewer",
description="Reviews code for bugs, style, and best practices",
parameters=[
SkillParameter(
name="code",
type="string",
description="The code to review",
required=True
),
SkillParameter(
name="language",
type="string",
description="Programming language",
required=False,
default="python"
)
],
instructions="""
1. Analyze the code for syntax errors
2. Check for common bugs and anti-patterns
3. Review style and formatting
4. Suggest performance improvements
5. Provide specific line-by-line feedback
""",
examples=[
{
"input": {"code": "def foo():\n x=1\n return x", "language": "python"},
"output": "Style: Use spaces around operators. Function name could be more descriptive."
}
]
)
agent.register_skill(code_review_skill)
result = agent.execute_skill("code_reviewer", {
"code": "def calculate(a,b):\n return a+b",
"language": "python"
})
print(result)
Skill YAML Definition
Skills can also be defined in YAML files:
name: code_reviewer
description: Reviews code for bugs, style, and best practices
version: 1.0.0
parameters:
- name: code
type: string
required: true
description: The code to review
- name: language
type: string
required: false
default: python
description: Programming language
instructions: |
1. Analyze the code for syntax errors
2. Check for common bugs and anti-patterns
3. Review style and formatting
4. Suggest performance improvements
5. Provide specific line-by-line feedback
examples:
- input:
code: "def foo():\n x=1\n return x"
language: python
output: "Style: Use spaces around operators. Function name could be more descriptive."
metadata:
[, , ]
Load from YAML:
agent.load_skill_from_file("~/.hermes/skills/code-reviewer.yaml")
Tool Integration
Built-in Tools
from hermes_agent import HermesAgent
from hermes_agent.tools import (
WebSearchTool,
CodeExecutorTool,
FileSystemTool,
APICallerTool
)
agent = HermesAgent(model="gpt-4-turbo")
agent.enable_tool(WebSearchTool())
agent.enable_tool(CodeExecutorTool(
allowed_languages=["python", "javascript"],
timeout=30
))
agent.enable_tool(FileSystemTool(
allowed_paths=["/home/user/projects"],
read_only=False
))
response = agent.chat("Search for Python best practices and create a summary file")
Creating Custom Tools
from hermes_agent import Tool, ToolParameter
class DatabaseQueryTool(Tool):
name = "database_query"
description = "Executes SQL queries against the database"
parameters = [
ToolParameter(
name="query",
type="string",
description="SQL query to execute",
required=True
),
ToolParameter(
name="database",
type="string",
description="Database name",
required=False,
default="main"
)
]
def execute(self, query: str, database: str = "main"):
import sqlite3
conn = sqlite3.connect(f"{database}.db")
cursor = conn.execute(query)
results = cursor.fetchall()
conn.close()
return results
agent.enable_tool(DatabaseQueryTool())
response = agent.chat("Query the users table for active users")
Memory Management
Accessing Memory Layers
from hermes_agent import HermesAgent
agent = HermesAgent(model="gpt-4-turbo")
conversation_history = agent.memory.episodic.get_recent(limit=10)
for entry in conversation_history:
print(f"User: {entry.user_message}")
print(f"Agent: {entry.agent_response}")
knowledge = agent.memory.semantic.search("Python best practices")
for item in knowledge:
print(f"Topic: {item.topic}")
print(f"Content: {item.content}")
print(f"Source: {item.source}")
skills = agent.memory.procedural.list_skills()
for skill in skills:
print(f"Skill: {skill.name} - {skill.description}")
print(f"Used {skill.usage_count} times")
Manual Memory Operations
agent.memory.semantic.add(
topic="Python Type Hints",
content="Type hints improve code readability and enable static analysis...",
source="user_input",
tags=["python", "typing"]
)
agent.memory.episodic.clear()
agent.memory.export_all(output_path="./memory_backup")
agent.memory.import_all(input_path="./memory_backup")
Advanced Patterns
Multi-Agent Collaboration
from hermes_agent import HermesAgent, AgentOrchestrator
code_agent = HermesAgent(
name="CodeExpert",
model="gpt-4-turbo",
system_prompt="You are a code expert specializing in Python and JavaScript"
)
review_agent = HermesAgent(
name="CodeReviewer",
model="gpt-4-turbo",
system_prompt="You are a code reviewer focusing on quality and best practices"
)
doc_agent = HermesAgent(
name="DocWriter",
model="gpt-4-turbo",
system_prompt="You write clear, comprehensive documentation"
)
orchestrator = AgentOrchestrator(
agents=[code_agent, review_agent, doc_agent],
coordination_strategy="sequential"
)
result = orchestrator.execute_workflow(
task="Create a Python function to parse CSV files, review it, and write docs",
workflow=[
{"agent": "CodeExpert", "task": "Write the function"},
{"agent": "CodeReviewer", "task": "Review the code"},
{"agent": "CodeExpert", "task": "Apply review feedback"},
{"agent": "DocWriter", "task": "Write documentation"}
]
)
print(result.final_output)
Feedback Loop for Improvement
from hermes_agent import HermesAgent, Feedback
agent = HermesAgent(model="gpt-4-turbo")
response = agent.chat("Create a REST API client for GitHub")
feedback = Feedback(
interaction_id=response.interaction_id,
rating=4,
comments="Good structure but missing error handling",
corrections={
"missing": ["try-except blocks", "timeout configuration"],
"suggestions": ["Add retry logic", "Use requests session"]
}
)
agent.provide_feedback(feedback)
Custom Learning Rules
from hermes_agent import HermesAgent, LearningRule
class CodeQualityRule(LearningRule):
def should_trigger(self, interaction):
return "code" in interaction.user_message.lower()
def extract_knowledge(self, interaction, feedback):
if feedback.rating >= 4:
return {
"topic": "code_patterns",
"content": interaction.agent_response,
"tags": ["approved", "high_quality"]
}
return None
def should_create_skill(self, pattern_count):
return pattern_count >= 2
agent = HermesAgent(model="gpt-4-turbo")
agent.add_learning_rule(CodeQualityRule())
Configuration
Full Configuration Example
from hermes_agent import (
HermesAgent,
MemoryConfig,
LearningConfig,
ModelConfig,
ToolConfig
)
model_config = ModelConfig(
provider="openai",
model="gpt-4-turbo",
temperature=0.7,
max_tokens=4000,
api_key=os.getenv("OPENAI_API_KEY")
)
memory_config = MemoryConfig(
episodic_enabled=True,
episodic_max_size=1000,
semantic_enabled=True,
semantic_embedding_model="text-embedding-3-small",
procedural_enabled=True,
memory_path="~/.hermes/memory",
auto_save=True,
save_interval=60
)
learning_config = LearningConfig(
enable_auto_learning=True,
reflection_interval=5,
skill_creation_threshold=3,
feedback_sensitivity=0.7,
auto_improve_skills=True,
learning_rate=0.1
)
tool_config = ToolConfig(
enabled_tools=["web_search", "code_executor", "file_system"],
tool_timeout=30,
allow_dangerous_tools=False
)
agent = HermesAgent(
name="MyAssistant",
model_config=model_config,
memory_config=memory_config,
learning_config=learning_config,
tool_config=tool_config,
system_prompt="You are a helpful AI assistant that learns and improves over time."
)
Configuration File
Create hermes_config.yaml:
agent:
name: MyAssistant
system_prompt: "You are a helpful AI assistant that learns and improves over time."
model:
provider: openai
model: gpt-4-turbo
temperature: 0.7
max_tokens: 4000
api_key_env: OPENAI_API_KEY
memory:
episodic:
enabled: true
max_size: 1000
semantic:
enabled: true
embedding_model: text-embedding-3-small
procedural:
enabled: true
path: ~/.hermes/memory
auto_save: true
save_interval: 60
learning:
auto_learning: true
reflection_interval: 5
skill_creation_threshold: 3
feedback_sensitivity: 0.7
auto_improve_skills: true
learning_rate: 0.1
tools:
enabled:
- web_search
-
Load configuration:
from hermes_agent import HermesAgent
agent = HermesAgent.from_config_file("hermes_config.yaml")
Real-World Examples
Knowledge Assistant
from hermes_agent import HermesAgent
from hermes_agent.tools import WebSearchTool, FileSystemTool
assistant = HermesAgent(
name="KnowledgeAssistant",
model="gpt-4-turbo",
system_prompt="""You are a knowledge assistant that:
1. Researches topics using web search
2. Stores learned knowledge in semantic memory
3. Creates summaries and documentation
4. Answers questions based on accumulated knowledge
"""
)
assistant.enable_tool(WebSearchTool())
assistant.enable_tool(FileSystemTool(allowed_paths=["./knowledge"]))
response = assistant.chat(
"Research Python async/await patterns and create a summary document"
)
response = assistant.chat("What are the best practices for async Python?")
Development Automation
from hermes_agent import HermesAgent
from hermes_agent.tools import CodeExecutorTool, FileSystemTool, GitTool
dev_agent = HermesAgent(
name="DevAutomation",
model="gpt-4-turbo"
)
dev_agent.enable_tool(CodeExecutorTool(allowed_languages=["python"]))
dev_agent.enable_tool(FileSystemTool(allowed_paths=["./project"]))
dev_agent.enable_tool(GitTool())
workflow_prompt = """
1. Create a Python FastAPI application with user authentication
2. Write unit tests with pytest
3. Run the tests
4. Fix any failures
5. Commit the working code
6. Generate API documentation
"""
result = dev_agent.chat(workflow_prompt)
Content Creation Pipeline
from hermes_agent import HermesAgent, AgentOrchestrator
researcher = HermesAgent(
name="Researcher",
model="gpt-4-turbo",
system_prompt="Research topics thoroughly and gather facts"
)
writer = HermesAgent(
name="Writer",
model="gpt-4-turbo",
system_prompt="Write engaging, well-structured content"
)
editor = HermesAgent(
name="Editor",
model="gpt-4-turbo",
system_prompt="Edit for clarity, grammar, and style"
)
orchestrator = AgentOrchestrator(
agents=[researcher, writer, editor],
coordination_strategy="sequential"
)
result = orchestrator.execute_workflow(
task="Create a blog post about AI Agents",
workflow=[
{"agent": "Researcher", "task": "Research AI Agents, find recent developments"},
{"agent": "Writer", "task": "Write 1000-word blog post using research"},
{"agent": "Editor", "task": "Edit for publication"},
{"agent": "Writer", "task": "Apply edits and finalize"}
]
)
print(result.final_output)
Troubleshooting
Common Issues
Agent not learning from interactions
agent = HermesAgent(
model="gpt-4-turbo",
learning_config=LearningConfig(
enable_auto_learning=True,
reflection_interval=5
)
)
print(agent.memory.config.procedural_enabled)
import logging
logging.basicConfig(level=logging.DEBUG)
Skills not being created automatically
agent.learning_config.skill_creation_threshold = 2
agent.create_skill_from_pattern(
pattern_name="code_review",
interactions=[id1, id2, id3]
)
Memory not persisting between sessions
agent.memory.config.auto_save = True
agent.memory.config.save_interval = 60
agent.memory.save_all()
import os
print(os.path.exists(agent.memory.config.memory_path))
API rate limits
from hermes_agent import RetryConfig
agent = HermesAgent(
model="gpt-4-turbo",
retry_config=RetryConfig(
max_retries=3,
backoff_factor=2,
respect_rate_limits=True
)
)
Tool execution timeouts
from hermes_agent.tools import CodeExecutorTool
agent.enable_tool(CodeExecutorTool(
timeout=60,
max_output_length=10000
))
Debug Mode
from hermes_agent import HermesAgent
agent = HermesAgent(
model="gpt-4-turbo",
debug=True
)
print(agent.debug_info())
print(agent.memory.stats())
print(agent.learning.stats())
Logging
import logging
logging.getLogger("hermes_agent").setLevel(logging.DEBUG)
file_handler = logging.FileHandler("hermes.log")
file_handler.setLevel(logging.DEBUG)
logging.getLogger("hermes_agent").addHandler(file_handler)
Best Practices
- Start with conservative learning settings - Begin with higher thresholds and adjust based on results
- Provide feedback regularly - The learning loop improves with human feedback
- Review auto-generated Skills - Inspect and refine Skills before heavy use
- Use semantic memory strategically - Add important knowledge manually for faster retrieval
- Monitor token usage - Learning loops can increase API calls
- Version control your Skills - Keep Skill definitions in git
- Separate agents by role - Use specialized agents with orchestration for complex workflows
- Test Skills in isolation - Validate Skill behavior before relying on them
- Regular memory maintenance - Periodically review and clean semantic memory
- Environment-specific configs - Use different configs for dev/prod environments
Resources