| name | hermes-agent-framework |
| description | Hermes Agent framework by Nous Research - self-improving AI agent with built-in learning loop, three-layer memory, and automatic skill evolution |
| triggers | ["help me set up Hermes Agent","how do I use the Hermes framework","create a Hermes agent with custom skills","configure Hermes memory system","build an AI agent with Hermes","how does Hermes learning loop work","integrate tools with Hermes Agent","customize Hermes agent behavior"] |
Hermes Agent Framework
Skill by ara.so — Hermes Skills collection.
Hermes Agent is an open-source AI Agent framework by Nous Research that features a built-in self-improving learning loop, three-layer memory system (episodic, semantic, procedural), and automatic Skill creation and evolution. Unlike traditional agentic frameworks, Hermes continuously learns from interactions and builds up capabilities over time.
Installation
Prerequisites
- Python 3.9+
- API key for LLM provider (OpenAI, Anthropic, etc.)
Basic Installation
git clone https://github.com/NousResearch/hermes-agent.git
cd hermes-agent
pip install -r requirements.txt
pip install hermes-agent
Configuration
Create a .env file in the project root:
OPENAI_API_KEY=your_openai_key_here
ANTHROPIC_API_KEY=your_anthropic_key_here
HERMES_MODEL=gpt-4
HERMES_MEMORY_PATH=./memory
HERMES_SKILLS_PATH=./skills
Core Concepts
Three-Layer Memory System
- Episodic Memory: Stores conversation history and interaction sequences
- Semantic Memory: Long-term knowledge and facts extracted from experiences
- Procedural Memory: Skills and learned procedures (how to do things)
Learning Loop
Hermes operates in a continuous cycle:
- Perceive: Receive user input and context
- Reflect: Analyze what happened and extract learnings
- Learn: Update memory systems and create/modify Skills
- Act: Execute tasks using available tools and Skills
Skills
Skills are reusable capabilities that Hermes creates and refines automatically. They're stored as structured modules in the procedural memory.
Basic Usage
Starting a Hermes Agent
from hermes_agent import HermesAgent, Config
config = Config(
model="gpt-4",
memory_path="./memory",
skills_path="./skills",
temperature=0.7
)
agent = HermesAgent(config)
response = agent.chat("Help me analyze this CSV file and create visualizations")
print(response)
With Custom System Prompt
from hermes_agent import HermesAgent, Config
config = Config(
model="claude-3-5-sonnet-20241022",
system_prompt="""You are a specialized data analysis agent.
Focus on statistical rigor and clear visualizations.
Always explain your analytical choices."""
)
agent = HermesAgent(config)
Enabling Memory Persistence
from hermes_agent import HermesAgent, Config, MemoryConfig
memory_config = MemoryConfig(
episodic_enabled=True,
semantic_enabled=True,
procedural_enabled=True,
retention_days=90,
auto_consolidate=True
)
config = Config(
model="gpt-4",
memory_config=memory_config
)
agent = HermesAgent(config)
agent.chat("Remember that I prefer Python over JavaScript")
Working with Skills
Creating a Custom Skill
from hermes_agent import Skill, SkillParameter
web_scraper_skill = Skill(
name="web_scraper",
description="Scrape and extract structured data from websites",
parameters=[
SkillParameter(name="url", type="string", required=True),
SkillParameter(name="selectors", type="object", required=False)
],
implementation="""
import requests
from bs4 import BeautifulSoup
def execute(url, selectors=None):
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
if selectors:
results = {}
for key, selector in selectors.items():
results[key] = soup.select(selector)
return results
return soup.get_text()
"""
)
agent.register_skill(web_scraper_skill)
Loading Skills from Directory
from hermes_agent import HermesAgent, Config
config = Config(
model="gpt-4",
skills_path="./my_custom_skills"
)
agent = HermesAgent(config)
Skill Auto-Evolution
from hermes_agent import HermesAgent, Config, LearningConfig
learning_config = LearningConfig(
auto_create_skills=True,
skill_refinement=True,
min_usage_for_creation=3
)
config = Config(
model="gpt-4",
learning_config=learning_config
)
agent = HermesAgent(config)
agent.chat("Convert this JSON to CSV format")
agent.chat("Convert this other JSON to CSV")
agent.chat("And convert this JSON to CSV too")
Tool Integration
Registering External Tools
from hermes_agent import HermesAgent, Tool
def search_api(query: str) -> dict:
"""Search using external API"""
import os
import requests
api_key = os.getenv("SEARCH_API_KEY")
response = requests.get(
"https://api.example.com/search",
params={"q": query, "key": api_key}
)
return response.json()
search_tool = Tool(
name="web_search",
description="Search the web for current information",
function=search_api,
parameters={
"query": {"type": "string", "description": "Search query"}
}
)
agent = HermesAgent(config)
agent.register_tool(search_tool)
Built-in Tool Categories
from hermes_agent import HermesAgent, Config, ToolConfig
tool_config = ToolConfig(
enable_file_operations=True,
enable_web_browsing=True,
enable_code_execution=True,
enable_shell_commands=False,
allowed_domains=["*.example.com", "api.trusted.com"]
)
config = Config(
model="gpt-4",
tool_config=tool_config
)
agent = HermesAgent(config)
Multi-Agent Orchestration
Creating Agent Teams
from hermes_agent import HermesAgent, AgentTeam, Config
researcher = HermesAgent(Config(
model="gpt-4",
system_prompt="You are a research specialist. Focus on gathering and analyzing information."
))
coder = HermesAgent(Config(
model="claude-3-5-sonnet-20241022",
system_prompt="You are a coding specialist. Write clean, efficient code."
))
writer = HermesAgent(Config(
model="gpt-4",
system_prompt="You are a technical writer. Create clear documentation."
))
team = AgentTeam(
agents=[researcher, coder, writer],
coordinator=HermesAgent(Config(
model="gpt-4",
system_prompt="Coordinate agent activities and synthesize results."
))
)
result = team.execute(
"Research best practices for API design, implement a sample API, and document it"
)
Agent Communication
from hermes_agent import HermesAgent, AgentChannel
channel = AgentChannel()
agent_a = HermesAgent(config)
agent_b = HermesAgent(config)
agent_a.connect(channel)
agent_b.connect(channel)
agent_a.chat("Learn about Python async patterns")
agent_b.chat("Use async patterns to build a web scraper")
Advanced Configuration
Feedback Loop Customization
from hermes_agent import HermesAgent, Config, FeedbackConfig
feedback_config = FeedbackConfig(
enable_self_critique=True,
reflection_frequency="after_task",
quality_threshold=0.8,
auto_correction=True
)
config = Config(
model="gpt-4",
feedback_config=feedback_config
)
agent = HermesAgent(config)
Constraints and Safety
from hermes_agent import HermesAgent, Config, ConstraintConfig
constraints = ConstraintConfig(
max_iterations=10,
timeout_seconds=300,
max_tool_calls_per_turn=5,
blocked_operations=["rm -rf", "DROP TABLE"],
require_approval_for=["file_delete", "api_payment"]
)
config = Config(
model="gpt-4",
constraint_config=constraints
)
agent = HermesAgent(config)
Memory Management
from hermes_agent import HermesAgent, Config
config = Config(model="gpt-4")
agent = HermesAgent(config)
episodic = agent.memory.get_episodic(last_n=10)
semantic = agent.memory.get_semantic(topic="python programming")
skills = agent.memory.get_skills()
agent.memory.clear_episodic()
agent.memory.clear_semantic(topic="outdated_info")
agent.memory.export("backup.json")
agent.memory.import_from("backup.json")
Real-World Examples
Personal Knowledge Assistant
from hermes_agent import HermesAgent, Config, MemoryConfig, ToolConfig
memory_config = MemoryConfig(
episodic_enabled=True,
semantic_enabled=True,
retention_days=365,
auto_consolidate=True
)
tool_config = ToolConfig(
enable_file_operations=True,
enable_web_browsing=True
)
config = Config(
model="gpt-4",
memory_config=memory_config,
tool_config=tool_config,
system_prompt="""You are a personal knowledge assistant.
Learn from all our interactions and help me recall information,
make connections, and build on past conversations."""
)
agent = HermesAgent(config)
agent.chat("I'm working on a new Python project for data analysis")
agent.chat("What was that project I mentioned last week?")
Development Automation Agent
from hermes_agent import HermesAgent, Config, ToolConfig, LearningConfig
tool_config = ToolConfig(
enable_code_execution=True,
enable_file_operations=True,
enable_shell_commands=True
)
learning_config = LearningConfig(
auto_create_skills=True,
skill_refinement=True
)
config = Config(
model="claude-3-5-sonnet-20241022",
tool_config=tool_config,
learning_config=learning_config,
system_prompt="You are a development automation specialist."
)
agent = HermesAgent(config)
agent.chat("Set up a new FastAPI project with PostgreSQL")
agent.chat("Add authentication with JWT")
agent.chat("Create CRUD endpoints for a User model")
Content Creation Pipeline
from hermes_agent import HermesAgent, AgentTeam, Config
researcher = HermesAgent(Config(
model="gpt-4",
system_prompt="Research topics and gather information.",
tool_config=ToolConfig(enable_web_browsing=True)
))
writer = HermesAgent(Config(
model="claude-3-5-sonnet-20241022",
system_prompt="Create engaging, well-structured content."
))
editor = HermesAgent(Config(
model="gpt-4",
system_prompt="Review and refine content for clarity and quality."
))
team = AgentTeam(agents=[researcher, writer, editor])
result = team.execute(
"Create a comprehensive blog post about Hermes Agent framework"
)
CLI Usage
If Hermes provides a command-line interface:
hermes chat
hermes chat --model gpt-4
hermes chat --skills ./my_skills
hermes chat --debug
hermes exec "analyze this CSV: data.csv"
hermes memory export backup.json
hermes memory import backup.json
hermes memory clear --episodic
hermes skills list
hermes skills export web_scraper > web_scraper.py
Troubleshooting
Memory Not Persisting
import os
from hermes_agent import HermesAgent, Config
memory_path = "./hermes_memory"
os.makedirs(memory_path, exist_ok=True)
config = Config(
model="gpt-4",
memory_path=memory_path,
auto_save=True
)
agent = HermesAgent(config)
Skills Not Loading
from hermes_agent import HermesAgent, Config
config = Config(
model="gpt-4",
skills_path="./skills",
debug=True
)
agent = HermesAgent(config)
print(agent.list_skills())
High Token Usage
from hermes_agent import HermesAgent, Config, MemoryConfig
memory_config = MemoryConfig(
max_episodic_context=5,
semantic_relevance_threshold=0.7,
consolidation_frequency="daily"
)
config = Config(
model="gpt-4",
memory_config=memory_config,
max_tokens=2000
)
agent = HermesAgent(config)
Tool Execution Failures
from hermes_agent import HermesAgent, Config, ToolConfig
tool_config = ToolConfig(
timeout_seconds=30,
retry_attempts=3,
error_handling="graceful",
log_tool_calls=True
)
config = Config(
model="gpt-4",
tool_config=tool_config
)
agent = HermesAgent(config)
Rate Limiting Issues
from hermes_agent import HermesAgent, Config
config = Config(
model="gpt-4",
rate_limit_rpm=20,
backoff_strategy="exponential",
retry_on_rate_limit=True
)
agent = HermesAgent(config)
Best Practices
- Start Simple: Begin with basic configuration and add complexity as needed
- Enable Memory: Hermes's strength is learning over time - enable all memory systems
- Curate Skills: Review auto-created skills periodically and refine them
- Set Constraints: Always configure safety constraints for production use
- Monitor Token Usage: Use memory consolidation to manage costs
- Version Skills: Export and version control important skills
- Use Teams Wisely: Specialized agents work better than one generalist for complex tasks
- Provide Feedback: The more feedback in the loop, the better Hermes learns
Resources