hermes-agent-framework

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Hermes Agent Framework

Hermes Agent框架

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.
ara.so开发的Skill — AI Agent技能合集。
本指南提供关于Hermes Agent的专业知识,这是Nous Research推出的开源AI Agent框架,具备内置自我提升学习循环、三层内存系统(情景式、语义式、过程式)以及自动Skill创建与进化功能。

What is Hermes Agent?

什么是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.
Hermes Agent是2026年2月发布的可投入生产的AI Agent框架,与传统Agent(如OpenClaw/Claude Code)的区别在于实现了以下特性:
  • 自我提升学习循环:自动从交互中学习并随时间迭代改进
  • 三层内存系统:情景式(对话记录)、语义式(知识库)、过程式(Skill)
  • 自动Skill创建:生成并进化可复用能力
  • 内置工具生态:可扩展的插件架构支持自定义工具
核心理念:Agent应自主学习与提升,而非仅执行任务。

Installation

安装

Prerequisites

前置条件

  • Python 3.10 or higher
  • OpenAI API key (or compatible provider like Anthropic, local models)
  • Git
  • Python 3.10或更高版本
  • OpenAI API密钥(或兼容提供商如Anthropic、本地模型)
  • Git

Quick Start

快速开始

bash
undefined
bash
undefined

Clone the repository

Clone the repository

Install dependencies

Install dependencies

pip install -r requirements.txt
pip install -r requirements.txt

Or use poetry

Or use poetry

poetry install
poetry install

Set up environment variables

Set up environment variables

cp .env.example .env
cp .env.example .env

Edit .env with your API keys

Edit .env with your API keys

undefined
undefined

Environment Configuration

环境配置

Create a
.env
file:
bash
undefined
创建
.env
文件:
bash
undefined

Required: Your LLM provider API key

Required: Your LLM provider API key

OPENAI_API_KEY=your_key_here
OPENAI_API_KEY=your_key_here

Or for Anthropic

Or for Anthropic

ANTHROPIC_API_KEY=your_key_here
ANTHROPIC_API_KEY=your_key_here

Optional: Model selection

Optional: Model selection

HERMES_MODEL=gpt-4-turbo
HERMES_MODEL=gpt-4-turbo

or

or

HERMES_MODEL=claude-3-5-sonnet-20241022
HERMES_MODEL=claude-3-5-sonnet-20241022

Memory configuration

Memory configuration

HERMES_MEMORY_PATH=~/.hermes/memory HERMES_ENABLE_SEMANTIC_MEMORY=true
HERMES_MEMORY_PATH=~/.hermes/memory HERMES_ENABLE_SEMANTIC_MEMORY=true

Skill storage

Skill storage

HERMES_SKILL_PATH=~/.hermes/skills
undefined
HERMES_SKILL_PATH=~/.hermes/skills
undefined

Core Architecture

核心架构

Three-Layer Memory System

三层内存系统

python
from hermes_agent import HermesAgent, MemoryConfig
python
from hermes_agent import HermesAgent, MemoryConfig

Configure memory layers

Configure memory layers

memory_config = MemoryConfig( episodic_enabled=True, # Conversation history semantic_enabled=True, # Knowledge base procedural_enabled=True, # Skills/procedures memory_path="~/.hermes/memory" )
agent = HermesAgent( model="gpt-4-turbo", memory_config=memory_config )
undefined
memory_config = MemoryConfig( episodic_enabled=True, # Conversation history semantic_enabled=True, # Knowledge base procedural_enabled=True, # Skills/procedures memory_path="~/.hermes/memory" )
agent = HermesAgent( model="gpt-4-turbo", memory_config=memory_config )
undefined

Self-Improving Learning Loop

自我提升学习循环

python
from hermes_agent import HermesAgent, LearningConfig

learning_config = LearningConfig(
    enable_auto_learning=True,
    reflection_interval=5,       # Reflect every 5 interactions
    skill_creation_threshold=3,  # Create skill after 3 similar tasks
    feedback_sensitivity=0.7
)

agent = HermesAgent(
    model="gpt-4-turbo",
    learning_config=learning_config
)
python
from hermes_agent import HermesAgent, LearningConfig

learning_config = LearningConfig(
    enable_auto_learning=True,
    reflection_interval=5,       # Reflect every 5 interactions
    skill_creation_threshold=3,  # Create skill after 3 similar tasks
    feedback_sensitivity=0.7
)

agent = HermesAgent(
    model="gpt-4-turbo",
    learning_config=learning_config
)

The agent will automatically:

The agent will automatically:

1. Detect patterns in user requests

1. Detect patterns in user requests

2. Create Skills for repeated tasks

2. Create Skills for repeated tasks

3. Improve existing Skills based on feedback

3. Improve existing Skills based on feedback

4. Store knowledge in semantic memory

4. Store knowledge in semantic memory

undefined
undefined

Basic Usage

基础用法

Simple Conversation

简单对话

python
from hermes_agent import HermesAgent
python
from hermes_agent import HermesAgent

Initialize agent

Initialize agent

agent = HermesAgent( model="gpt-4-turbo", api_key=os.getenv("OPENAI_API_KEY") )
agent = HermesAgent( model="gpt-4-turbo", api_key=os.getenv("OPENAI_API_KEY") )

Single interaction

Single interaction

response = agent.chat("Help me analyze this Python code for bugs") print(response)
response = agent.chat("Help me analyze this Python code for bugs") print(response)

Conversational context is maintained

Conversational context is maintained

response = agent.chat("Now optimize it for performance") print(response)
undefined
response = agent.chat("Now optimize it for performance") print(response)
undefined

Using the CLI

使用CLI

bash
undefined
bash
undefined

Start interactive mode

Start interactive mode

python -m hermes_agent
python -m hermes_agent

Or use the CLI directly

Or use the CLI directly

hermes chat "What's the weather today?"
hermes chat "What's the weather today?"

Load specific Skill

Load specific Skill

hermes chat --skill code-reviewer "Review my Python script"
hermes chat --skill code-reviewer "Review my Python script"

Show agent's memory

Show agent's memory

hermes memory list
hermes memory list

Show available Skills

Show available Skills

hermes skills list
hermes skills list

Export learned knowledge

Export learned knowledge

hermes memory export --format json --output knowledge.json
undefined
hermes memory export --format json --output knowledge.json
undefined

Skill System

Skill系统

Creating Custom Skills

创建自定义Skill

Skills are reusable procedures stored in the agent's procedural memory.
python
from hermes_agent import Skill, SkillParameter
Skill是存储在Agent过程式内存中的可复用流程。
python
from hermes_agent import Skill, SkillParameter

Define a custom Skill

Define a custom Skill

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." } ] )
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." } ] )

Register Skill with agent

Register Skill with agent

agent.register_skill(code_review_skill)
agent.register_skill(code_review_skill)

Use the Skill

Use the Skill

result = agent.execute_skill("code_reviewer", { "code": "def calculate(a,b):\n return a+b", "language": "python" }) print(result)
undefined
result = agent.execute_skill("code_reviewer", { "code": "def calculate(a,b):\n return a+b", "language": "python" }) print(result)
undefined

Skill YAML Definition

Skill YAML定义

Skills can also be defined in YAML files:
yaml
undefined
Skill也可以通过YAML文件定义:
yaml
undefined

~/.hermes/skills/code-reviewer.yaml

~/.hermes/skills/code-reviewer.yaml

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: author: HuaShu tags: [code, review, python] auto_improve: true

Load from YAML:

```python
agent.load_skill_from_file("~/.hermes/skills/code-reviewer.yaml")
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: author: HuaShu tags: [code, review, python] auto_improve: true

从YAML加载:

```python
agent.load_skill_from_file("~/.hermes/skills/code-reviewer.yaml")

Tool Integration

工具集成

Built-in Tools

内置工具

python
from hermes_agent import HermesAgent
from hermes_agent.tools import (
    WebSearchTool,
    CodeExecutorTool,
    FileSystemTool,
    APICallerTool
)

agent = HermesAgent(model="gpt-4-turbo")
python
from hermes_agent import HermesAgent
from hermes_agent.tools import (
    WebSearchTool,
    CodeExecutorTool,
    FileSystemTool,
    APICallerTool
)

agent = HermesAgent(model="gpt-4-turbo")

Enable built-in tools

Enable built-in tools

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 ))
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 ))

Agent can now use these tools automatically

Agent can now use these tools automatically

response = agent.chat("Search for Python best practices and create a summary file")
undefined
response = agent.chat("Search for Python best practices and create a summary file")
undefined

Creating Custom Tools

创建自定义工具

python
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"):
        # Your database logic here
        import sqlite3
        conn = sqlite3.connect(f"{database}.db")
        cursor = conn.execute(query)
        results = cursor.fetchall()
        conn.close()
        return results
python
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"):
        # Your database logic here
        import sqlite3
        conn = sqlite3.connect(f"{database}.db")
        cursor = conn.execute(query)
        results = cursor.fetchall()
        conn.close()
        return results

Register custom tool

Register custom tool

agent.enable_tool(DatabaseQueryTool())
agent.enable_tool(DatabaseQueryTool())

Agent can now use it

Agent can now use it

response = agent.chat("Query the users table for active users")
undefined
response = agent.chat("Query the users table for active users")
undefined

Memory Management

内存管理

Accessing Memory Layers

访问内存层

python
from hermes_agent import HermesAgent

agent = HermesAgent(model="gpt-4-turbo")
python
from hermes_agent import HermesAgent

agent = HermesAgent(model="gpt-4-turbo")

Episodic memory (conversation history)

Episodic memory (conversation history)

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}")
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}")

Semantic memory (knowledge base)

Semantic memory (knowledge base)

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}")
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}")

Procedural memory (Skills)

Procedural memory (Skills)

skills = agent.memory.procedural.list_skills() for skill in skills: print(f"Skill: {skill.name} - {skill.description}") print(f"Used {skill.usage_count} times")
undefined
skills = agent.memory.procedural.list_skills() for skill in skills: print(f"Skill: {skill.name} - {skill.description}") print(f"Used {skill.usage_count} times")
undefined

Manual Memory Operations

手动内存操作

python
undefined
python
undefined

Add to semantic memory manually

Add to semantic memory manually

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.semantic.add( topic="Python Type Hints", content="Type hints improve code readability and enable static analysis...", source="user_input", tags=["python", "typing"] )

Clear episodic memory (conversation history)

Clear episodic memory (conversation history)

agent.memory.episodic.clear()
agent.memory.episodic.clear()

Export all memory

Export all memory

agent.memory.export_all(output_path="./memory_backup")
agent.memory.export_all(output_path="./memory_backup")

Import memory from backup

Import memory from backup

agent.memory.import_all(input_path="./memory_backup")
undefined
agent.memory.import_all(input_path="./memory_backup")
undefined

Advanced Patterns

进阶模式

Multi-Agent Collaboration

多Agent协作

python
from hermes_agent import HermesAgent, AgentOrchestrator
python
from hermes_agent import HermesAgent, AgentOrchestrator

Create specialized agents

Create specialized agents

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" )
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" )

Orchestrate agents

Orchestrate agents

orchestrator = AgentOrchestrator( agents=[code_agent, review_agent, doc_agent], coordination_strategy="sequential" # or "parallel", "hierarchical" )
orchestrator = AgentOrchestrator( agents=[code_agent, review_agent, doc_agent], coordination_strategy="sequential" # or "parallel", "hierarchical" )

Execute workflow

Execute workflow

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)
undefined
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)
undefined

Feedback Loop for Improvement

反馈改进循环

python
from hermes_agent import HermesAgent, Feedback

agent = HermesAgent(model="gpt-4-turbo")
python
from hermes_agent import HermesAgent, Feedback

agent = HermesAgent(model="gpt-4-turbo")

Execute task

Execute task

response = agent.chat("Create a REST API client for GitHub")
response = agent.chat("Create a REST API client for GitHub")

Provide feedback

Provide feedback

feedback = Feedback( interaction_id=response.interaction_id, rating=4, # 1-5 scale 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)
feedback = Feedback( interaction_id=response.interaction_id, rating=4, # 1-5 scale 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)

Agent will learn and improve future responses

Agent will learn and improve future responses

Next similar task will incorporate this feedback

Next similar task will incorporate this feedback

undefined
undefined

Custom Learning Rules

自定义学习规则

python
from hermes_agent import HermesAgent, LearningRule
python
from hermes_agent import HermesAgent, LearningRule

Define custom learning rule

Define custom learning rule

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):
    # Create skill after 2 successful code tasks
    return pattern_count >= 2
agent = HermesAgent(model="gpt-4-turbo") agent.add_learning_rule(CodeQualityRule())
undefined
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):
    # Create skill after 2 successful code tasks
    return pattern_count >= 2
agent = HermesAgent(model="gpt-4-turbo") agent.add_learning_rule(CodeQualityRule())
undefined

Configuration

配置

Full Configuration Example

完整配置示例

python
from hermes_agent import (
    HermesAgent,
    MemoryConfig,
    LearningConfig,
    ModelConfig,
    ToolConfig
)
python
from hermes_agent import (
    HermesAgent,
    MemoryConfig,
    LearningConfig,
    ModelConfig,
    ToolConfig
)

Model configuration

Model configuration

model_config = ModelConfig( provider="openai", model="gpt-4-turbo", temperature=0.7, max_tokens=4000, api_key=os.getenv("OPENAI_API_KEY") )
model_config = ModelConfig( provider="openai", model="gpt-4-turbo", temperature=0.7, max_tokens=4000, api_key=os.getenv("OPENAI_API_KEY") )

Memory configuration

Memory configuration

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 # seconds )
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 # seconds )

Learning configuration

Learning configuration

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 )
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 configuration

Tool configuration

tool_config = ToolConfig( enabled_tools=["web_search", "code_executor", "file_system"], tool_timeout=30, allow_dangerous_tools=False )
tool_config = ToolConfig( enabled_tools=["web_search", "code_executor", "file_system"], tool_timeout=30, allow_dangerous_tools=False )

Create agent with full configuration

Create agent with full configuration

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." )
undefined
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." )
undefined

Configuration File

配置文件

Create
hermes_config.yaml
:
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
    - code_executor
    - file_system
  timeout: 30
  allow_dangerous: false
Load configuration:
python
from hermes_agent import HermesAgent

agent = HermesAgent.from_config_file("hermes_config.yaml")
创建
hermes_config.yaml
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
    - code_executor
    - file_system
  timeout: 30
  allow_dangerous: false
加载配置:
python
from hermes_agent import HermesAgent

agent = HermesAgent.from_config_file("hermes_config.yaml")

Real-World Examples

实际应用示例

Knowledge Assistant

知识助手

python
from hermes_agent import HermesAgent
from hermes_agent.tools import WebSearchTool, FileSystemTool
python
from hermes_agent import HermesAgent
from hermes_agent.tools import WebSearchTool, FileSystemTool

Create knowledge assistant

Create knowledge assistant

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"]))
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"]))

Research and learn

Research and learn

response = assistant.chat( "Research Python async/await patterns and create a summary document" )
response = assistant.chat( "Research Python async/await patterns and create a summary document" )

Later, retrieve knowledge

Later, retrieve knowledge

response = assistant.chat("What are the best practices for async Python?")
response = assistant.chat("What are the best practices for async Python?")

Agent uses semantic memory to answer without re-searching

Agent uses semantic memory to answer without re-searching

undefined
undefined

Development Automation

开发自动化

python
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())
python
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())

Automated development workflow

Automated development workflow

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)
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)

Agent will:

Agent will:

- Create files

- Create files

- Write code

- Write code

- Execute tests

- Execute tests

- Iterate on failures

- Iterate on failures

- Use git for version control

- Use git for version control

- Generate docs

- Generate docs

undefined
undefined

Content Creation Pipeline

内容创作流水线

python
from hermes_agent import HermesAgent, AgentOrchestrator
python
from hermes_agent import HermesAgent, AgentOrchestrator

Research agent

Research agent

researcher = HermesAgent( name="Researcher", model="gpt-4-turbo", system_prompt="Research topics thoroughly and gather facts" )
researcher = HermesAgent( name="Researcher", model="gpt-4-turbo", system_prompt="Research topics thoroughly and gather facts" )

Writer agent

Writer agent

writer = HermesAgent( name="Writer", model="gpt-4-turbo", system_prompt="Write engaging, well-structured content" )
writer = HermesAgent( name="Writer", model="gpt-4-turbo", system_prompt="Write engaging, well-structured content" )

Editor agent

Editor agent

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" )
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" )

Content pipeline

Content pipeline

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)
undefined
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)
undefined

Troubleshooting

故障排查

Common Issues

常见问题

Agent not learning from interactions
python
undefined
Agent未从交互中学习
python
undefined

Check learning config

Check learning config

agent = HermesAgent( model="gpt-4-turbo", learning_config=LearningConfig( enable_auto_learning=True, # Must be True reflection_interval=5 ) )
agent = HermesAgent( model="gpt-4-turbo", learning_config=LearningConfig( enable_auto_learning=True, # Must be True reflection_interval=5 ) )

Verify memory is enabled

Verify memory is enabled

print(agent.memory.config.procedural_enabled) # Should be True
print(agent.memory.config.procedural_enabled) # Should be True

Check logs

Check logs

import logging logging.basicConfig(level=logging.DEBUG)

**Skills not being created automatically**

```python
import logging logging.basicConfig(level=logging.DEBUG)

**Skill未自动创建**

```python

Lower the threshold

Lower the threshold

agent.learning_config.skill_creation_threshold = 2
agent.learning_config.skill_creation_threshold = 2

Manually trigger skill creation

Manually trigger skill creation

agent.create_skill_from_pattern( pattern_name="code_review", interactions=[id1, id2, id3] )

**Memory not persisting between sessions**

```python
agent.create_skill_from_pattern( pattern_name="code_review", interactions=[id1, id2, id3] )

**内存未在会话间持久化**

```python

Ensure auto_save is enabled

Ensure auto_save is enabled

agent.memory.config.auto_save = True agent.memory.config.save_interval = 60
agent.memory.config.auto_save = True agent.memory.config.save_interval = 60

Or manually save

Or manually save

agent.memory.save_all()
agent.memory.save_all()

Check memory path exists

Check memory path exists

import os print(os.path.exists(agent.memory.config.memory_path))

**API rate limits**

```python
import os print(os.path.exists(agent.memory.config.memory_path))

**API速率限制**

```python

Add retry logic

Add retry logic

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**

```python
from hermes_agent import RetryConfig
agent = HermesAgent( model="gpt-4-turbo", retry_config=RetryConfig( max_retries=3, backoff_factor=2, respect_rate_limits=True ) )

**工具执行超时**

```python

Increase timeout

Increase timeout

from hermes_agent.tools import CodeExecutorTool
agent.enable_tool(CodeExecutorTool( timeout=60, # seconds max_output_length=10000 ))
undefined
from hermes_agent.tools import CodeExecutorTool
agent.enable_tool(CodeExecutorTool( timeout=60, # seconds max_output_length=10000 ))
undefined

Debug Mode

调试模式

python
from hermes_agent import HermesAgent

agent = HermesAgent(
    model="gpt-4-turbo",
    debug=True  # Enables verbose logging
)
python
from hermes_agent import HermesAgent

agent = HermesAgent(
    model="gpt-4-turbo",
    debug=True  # Enables verbose logging
)

Access internal state

Access internal state

print(agent.debug_info()) print(agent.memory.stats()) print(agent.learning.stats())
undefined
print(agent.debug_info()) print(agent.memory.stats()) print(agent.learning.stats())
undefined

Logging

日志

python
import logging
python
import logging

Configure Hermes logging

Configure Hermes logging

logging.getLogger("hermes_agent").setLevel(logging.DEBUG)
logging.getLogger("hermes_agent").setLevel(logging.DEBUG)

Log to file

Log to file

file_handler = logging.FileHandler("hermes.log") file_handler.setLevel(logging.DEBUG) logging.getLogger("hermes_agent").addHandler(file_handler)
undefined
file_handler = logging.FileHandler("hermes.log") file_handler.setLevel(logging.DEBUG) logging.getLogger("hermes_agent").addHandler(file_handler)
undefined

Best Practices

最佳实践

  1. Start with conservative learning settings - Begin with higher thresholds and adjust based on results
  2. Provide feedback regularly - The learning loop improves with human feedback
  3. Review auto-generated Skills - Inspect and refine Skills before heavy use
  4. Use semantic memory strategically - Add important knowledge manually for faster retrieval
  5. Monitor token usage - Learning loops can increase API calls
  6. Version control your Skills - Keep Skill definitions in git
  7. Separate agents by role - Use specialized agents with orchestration for complex workflows
  8. Test Skills in isolation - Validate Skill behavior before relying on them
  9. Regular memory maintenance - Periodically review and clean semantic memory
  10. Environment-specific configs - Use different configs for dev/prod environments
  1. 从保守的学习设置开始 - 初始使用较高阈值,根据结果逐步调整
  2. 定期提供反馈 - 人类反馈能有效提升学习循环效果
  3. 审核自动生成的Skill - 在大规模使用前检查并优化Skill
  4. 策略性使用语义内存 - 手动添加重要知识以加快检索速度
  5. 监控token使用 - 学习循环会增加API调用量
  6. 版本控制Skill - 将Skill定义存储在Git中
  7. 按角色拆分Agent - 针对复杂工作流,使用编排器管理专业化Agent
  8. 独立测试Skill - 在依赖前验证Skill行为
  9. 定期维护内存 - 定期检查并清理语义内存
  10. 环境专属配置 - 为开发/生产环境使用不同配置

Resources

资源