AI & Agent

Hermes Agent: Autonomous AI Agent Thế Hệ Mới

Nền tảng AI agent mã nguồn mở từ Nous Research — tự cải thiện, đa nền tảng, và cực kỳ mạnh mẽ. Giải pháp duy nhất cho một AI assistant 24/7 nhớ mọi thứ.

27/06/2026 20 phút đọc Võ Đào Huy Hoàng

1. Giới Thiệu — Bài Toán Thực Tế 🎯

Bạn đang chạy nhiều AI tools rời rạc: Claude chat trên web, Claude Code trong terminal, ChatGPT trên Telegram. Mỗi tool biết một ít về bạn, nhưng không tool nào nhớ được từ phiên trước. Bạn muốn một AI assistant duy nhất — nhớ mọi thứ, tự động hoá tác vụ, chạy trên server 24/7.

Đây chính xác là bài toán Hermes Agent giải quyết. Hermes là một nền tảng autonomous AI agent mã nguồn mở được xây dựng bởi Nous Research — phòng thí nghiệm AI nổi tiếng đứng sau các mô hình Hermes, Nomos và Psyche.

🔥 Điểm khác biệt cốt lõi: Hermes là AI agent duy nhất có một vòng lặp học tập khép kín (closed learning loop) — nó tự tạo skills từ các task đã hoàn thành, tự cải thiện skills khi dùng lại, và xây dựng mô hình người dùng ngày càng sâu sắc qua các phiên làm việc.

Không giống như các "coding copilot" bị giới hạn trong IDE hay các chatbot đơn thuần, Hermes là một agent tự trị có khả năng:

  • Tự cải thiện theo thời gian — học từ kinh nghiệm, tự động tạo skills, ghi nhớ preferences 🔄
  • Chạy ở mọi nơi — từ VPS $5/tháng đến GPU cluster, serverless infrastructure ☁️
  • Kết nối 20+ nền tảng — Telegram, Discord, Slack, WhatsApp, CLI, Email... 🌐
  • Provider-agnostic — dùng OpenAI, Anthropic, OpenRouter, DeepSeek, local models... tuỳ ý 🔌
  • Tự động hoá — cron jobs, webhooks, background tasks, delegation ⏰

Hermes Agent thuộc cùng hệ sinh thái với Claude Code (Anthropic), Codex (OpenAI), và OpenCode — các autonomous coding agents sử dụng tool calling để tương tác với hệ thống. Tuy nhiên, Hermes vượt trội hơn nhờ khả năng self-improvingmulti-platform vượt trội.

60+ Built-in Tools
20+ Messaging Platforms
3000+ Auto Tests
MIT License

Dự án hoàn toàn mã nguồn mở (MIT license) trên GitHub với hơn 3,000 bài test tự động và tài liệu đầy đủ tại hermes-agent.nousresearch.com.

2. Kiến Trúc Hệ Thống 🏗️

Hermes Agent được thiết kế theo kiến trúc modular, event-driven với các thành phần độc lập nhưng phối hợp chặt chẽ:

🔄
Agent Loop
🧠
Prompt Builder
🔧
Tool Registry
🌐
Gateway
💾
Memory
Cron

Mỗi thành phần có trách nhiệm rõ ràng:

  • Agent Loop — Conversation engine điều phối luồng: prompt → LLM → tools → response
  • Prompt Builder — Factory xây dựng system prompt từ identity, project context, memory, skills
  • Tool Registry — 60+ built-in tools, auto-discovery, MCP support
  • Gateway — 20+ platform adapters (Telegram, Discord, Slack, WhatsApp...)
  • Memory — Persistent storage: user preferences, session search (FTS5), skills
  • Cron — Built-in job scheduler với multi-platform delivery
💡 Project Layout: Codebase được tổ chức rõ ràng: run_agent.py (core loop), model_tools.py (tool dispatch), toolsets.py (tool groups), cli.py (interactive), hermes_state.py (SQLite store), agent/ (prompt, compression, memory, routing), hermes_cli/ (commands, config), tools/ (mỗi tool 1 file), gateway/ (platform adapters), cron/ (scheduler).

2.1 Agent Loop Chi Tiết — Trái Tim Của Hermes ⚡

Đây là vòng lặp cốt lõi xử lý mọi tương tác. Hiểu nó giúp bạn debug và tối ưu hiệu suất:

# Vòng lặp Agent Loop (đơn giản hoá)
while turns < max_turns:
    # 1. Build system prompt
    system_prompt = build_prompt(identity, project_context, memory, skills)
    
    # 2. Call LLM
    response = llm_call(messages + [system_prompt], tool_schemas)
    
    # 3. Dispatch tools
    if response.has_tool_calls:
        for tool_call in response.tool_calls:
            result = tool_registry.dispatch(tool_call)
            messages.append(tool_result(result))
        continue  # Lặp lại với kết quả tool
    
    # 4. Return text
    if response.has_text:
        messages.append(assistant(response.text))
        break
    
    # 5. Context compression
    if tokens_near_limit:
        compress_context(messages)

Ví dụ thực tế: Khi user hỏi "check CPU usage", Hermes thực hiện:

  1. (a) Build prompt + memory — Kết hợp identity, project context, user preferences, skills liên quan
  2. (b) LLM decides — Model phân tích và quyết định gọi terminal tool với lệnh top -bn1 | head -20
  3. (c) Runs tool — Tool registry dispatch tới tools/terminal.py, chạy lệnh, capture stdout/stderr
  4. (d) Returns result — Output CPU info được append vào messages, LLM tổng hợp trả lời
  5. (e) Saves to memory — Nếu user thường hỏi về CPU, Hermes ghi nhớ preference này cho lần sau
⚠️ Chi tiết quan trọng: Mỗi turn có tối đa max_turns (mặc định 90) iterations giữa LLM và tools. Hermes dùng message role alternation — không bao giờ có hai assistant messages liên tiếp — để tối ưu prompt caching. Nếu model không gọi tool khi cần, config agent.tool_use_enforcement sẽ nhắc nhở.

3. Tools & Skills — Trái Tim Hermes ❤️

Đây là section quan trọng nhất — nơi Hermes khác biệt hẳn so với các agent khác. Tools cho phép Hermes hành động, Skills cho phép Hermes học cách hành động tốt hơn.

3.1 Toolsets & 60+ Built-in Tools 🔧

Hermes tổ chức tools thành toolsets — nhóm tools theo chức năng. Bật/tắt linh hoạt:

# Quản lý tools
hermes tools              # Interactive UI (curses)
hermes tools list         # Show all + status
hermes tools enable web   # Enable web toolset
hermes tools disable web  # Disable
Toolset Tools Chính Use Case
terminalrun, shell, process, tmuxServer admin, devops, build scripts
fileread, write, patch, search, glob, lsCode editing, config management
websearch, fetch, extractResearch, fact-checking, news
browsernavigate, click, screenshot, pdfSPA scraping, auth flows, testing
code_executionpython, jupyterData analysis, visualization, ML
visionanalyze, ocrImage analysis, diagram reading
image_gengenerate, editAI art, thumbnails, diagrams
ttsspeak, voicesVoice responses, accessibility
skillsbrowse, install, createSkill management
memoryread, write, searchCross-session recall
delegationspawn, batchParallel subagents
cronjobcreate, list, editScheduling automation
session_searchsearchFTS5 full-text search
todoadd, update, listIn-session task tracking
spotifyplay, pause, searchMedia control
homeassistantcall_service, get_stateSmart home control
🔌 MCP Support: Ngoài built-in tools, Hermes hỗ trợ Model Context Protocol (MCP) — kết nối bất kỳ MCP server nào để mở rộng khả năng vô hạn. Dùng hermes mcp add để thêm server (filesystem, database, API, etc.).

3.2 Adding Custom Tools — Chỉ 3 Files 📝

Devs có thể tự thêm tool cực kỳ dễ dàng:

# 1. tools/my_tool.py
from tools.registry import registry

def my_tool(param: str) -> str:
    return json.dumps({"success": True, "data": param})

registry.register(
    name="my_tool",
    toolset="custom",
    schema={
        "type": "object",
        "properties": {
            "param": {"type": "string", "description": "Input parameter"}
        },
        "required": ["param"]
    },
    handler=lambda args: my_tool(args.get("param"))
)

# 2. toolsets.py → thêm vào _HERMES_CORE_TOOLS list
# 3. Done! Tool auto-discovered (mọi file tools/*.py có registry.register)
✅ Auto-discovery: Mọi file tools/*.pyregistry.register() được auto-import — không cần manual list. Reload với /reload-tools trong session.

3.3 Skills: Procedural Memory — Self-Improving Loop 🧠

Skills là procedural memory — các hướng dẫn tái sử dụng cho các dạng task lặp lại. Mỗi skill là một file Markdown với YAML frontmatter, lưu tại ~/.hermes/skills///SKILL.md.

Ví dụ SKILL.md thực tế:

---
name: daily-tech-blog
description: "Viết blog công nghệ hàng ngày — chuẩn HyHon"
version: 1.2.0
tags: [blog, automation, content-creation]
triggers:
  - cron: "0 7 * * *"
  - manual: true
---

# Quy Trình Viết Blog Hàng Ngày

## 1. Chuẩn Bị
- Kiểm tra topic trong queue
- Research từ 3+ nguồn uy tín
- Extract key data points

## 2. Viết Nội Dung
1. `hermes -s hyhon-daily-tech-blog -q "Viết blog về [topic]"`
2. Verify structure: hero, 8 sections, CSS utils, 30+ emojis
3. Run audit script: `bash .hermes/scripts/audit-blogs.sh`

## 3. Review & Publish
- Pre-commit review: security scan, quality gates
- Push to GitHub → auto deploy

## Pitfalls
- ❌ Không dùng bash heredoc >8KB → dùng Python file append
- ❌ Footer phải copy EXACT từ gold standard
- ❌ Nav paths blog dùng ../ prefix

Quản lý skills:

# CLI commands
hermes skills list            # Installed skills
hermes skills browse          # Browse hub (community skills)
hermes skills install ID      # Install from hub
hermes skills update          # Update outdated
hermes skills publish PATH    # Publish to registry

# In-session
/skill daily-tech-blog        # Load skill
/reload-skills                # Rescan directory

# CLI flag
hermes -s daily-tech-blog     # Preload skill
🔥 Điều khiến Hermes UNIQUE: Curator — background service tự động bảo trì skills:
  • Theo dõi usage statistics (use_count, view_count, patch_count)
  • Đánh dấu skills cũ là stale sau stale_after_days
  • Archive skills không dùng — không bao giờ xoá
  • Backup tự động trước mọi thay đổi
  • Skills pinned được bảo vệ khỏi mọi auto-transition
hermes curator status/run/pin/unpin để quản lý.

So với Claude Code (chỉ có instructions trong CLAUDE.md) và Codex (chỉ AGENTS.md), Hermes có hệ thống skill đầy đủ với versioning, publishing, auto-maintenance — đây là procedural memory thực sự, tự cải thiện theo thời gian.

4. Multi-Platform Gateway 🌐

Gateway là thành phần cho phép Hermes kết nối với 20+ nền tảng messaging cùng lúc — bạn chat với Hermes trên Telegram, và nó có thể làm việc trên server cloud mà không cần SSH.

🤖
Single Hermes Agent
💬
Telegram
🎮
Discord
💼
Slack
📱
WhatsApp
💻
CLI
✉️
Email
🏠
Home Assistant

Platforms supported: Telegram, Discord, Slack, WhatsApp, Signal, Matrix, Email, SMS, Teams, Google Chat, Home Assistant, Feishu, DingTalk, BlueBubbles, Webhook/API, và nhiều hơn nữa.

# Chạy gateway
hermes gateway run              # Foreground (dev)
hermes gateway install          # Background service (systemd)
hermes gateway setup            # Configure platforms interactively
hermes gateway status           # Check connection status
hermes gateway restart          # Restart
⚠️ Deploy tip: Dùng sudo loginctl enable-linger $USER để gateway không bị die khi SSH logout. Trên WSL2, cần systemd=true trong /etc/wsl.conf.

4.1 Practical Setup Example — Telegram 📱

# 1. Tạo bot với @BotFather → lấy token
# 2. Setup Hermes gateway
hermes gateway setup
# Chọn Telegram → nhập token → xong!

# 3. Chạy service
hermes gateway install

# 4. Test: chat với bot trên Telegram
# Hermes sẽ nhận message, xử lý qua Agent Loop, trả lời qua gateway

4.2 Gateway Slash Commands (Cross-Platform) ⌨️

Khi dùng Hermes qua messaging platforms, các lệnh đặc biệt:

  • /approve — duyệt command pending
  • /deny — từ chối command
  • /restart — restart gateway
  • /sethome — set home channel
  • /platforms — show connection status
  • /topic — Telegram DM topic sessions (multi-thread)
💡 Architecture Note: Gateway dùng adapter pattern — mỗi platform là một adapter implement interface chung. Message flow: Platform → Adapter → Gateway Core → Agent Loop → Response → Adapter → Platform. Shared session state across platforms via SQLite.

5. Memory & Context System 💾

Đây là tính năng khác biệt nhất của Hermes so với các AI agent khác. Hermes không chỉ ghi nhớ — nó học và cải thiện qua thời gian.

5.1 Three Memory Types (Hoạt Động Đồng Thời) 🧩

Memory Type Storage Content Injected Into
Persistent Memory (memory.md) Markdown file User preferences, environment facts, lessons learned, corrections Every turn (system prompt)
User Profile (user.md) Markdown file Name, role, communication style, timezone, goals Every turn (system prompt)
Session Search (FTS5) SQLite + FTS5 Full conversation history, searchable On-demand via session_search tool
# Memory management
hermes memory status

# Provider options
hermes config set memory.provider builtin   # Built-in (default, Markdown)
hermes config set memory.provider honcho    # Honcho dialectic (structured)

# Toggle
hermes config set memory.memory_enabled true
hermes config set memory.user_profile_enabled false
🧠 Cách hoạt động: Agent tự động ghi memory khi phát hiện thông tin quan trọng (preferences, corrections, environment facts). Memory được nén và ưu tiên — không ghi task progress hay temporary state. Bạn cũng có thể dùng memory tool để thêm thủ công: memory write "User prefers dark mode".

5.2 Concrete Example: What Hermes Remembers 🎯

Sau 1 tuần làm việc, Hermes sẽ nhớ:

  • Preferences: "User likes concise answers, uses pnpm not npm, prefers TypeScript"
  • Environment: "Project at ~/work/myapp, uses PostgreSQL on port 5433, Redis on 6380"
  • Corrections: "Don't use 'rm -rf' without confirmation, always run tests before commit"
  • Patterns: "Morning = news briefing, Evening = code review, Weekend = refactoring"

Khi bạn hỏi "deploy staging" tuần sau, Hermes tự động biết: dùng pnpm, chạy test, deploy to staging env, notify trên Telegram — không cần giải thích lại.

5.3 Context Compression — What Happens At Token Limit 📦

Khi conversation gần tới context_length, Hermes tự động nén context:

# Config compression
hermes config set compression.enabled true
hermes config set compression.threshold 0.50    # Trigger at 50% capacity
hermes config set compression.target_ratio 0.20 # Compress to 20%

# Manual compress in session
/compress

Compression strategy:

  1. Giữ system prompt + recent turns (last 5-10 exchanges)
  2. Tóm tắt các turn cũ thành summary ngắn gọn
  3. Giữ tool results quan trọng (file reads, search results)
  4. Xoá reasoning traces, temporary tool outputs
✅ Kết quả: Conversation có thể kéo dài vô hạn mà không bị truncation. Memory & skills vẫn được inject đầy đủ vì nằm ngoài context window (system prompt).

6. Cron & Automation ⏰

Hermes có built-in job scheduler — không cần system crontab, không cần cấu hình phức tạp. Jobs chạy trong cùng process Hermes, có đầy đủ truy cập tools, skills, memory.

6.1 Practical Cron Job Examples 📋

# Morning news briefing (runs 7 AM daily)
hermes cron create "0 7 * * *" \
  --prompt "Tóm tắt tin tức AI/Tech hôm nay từ 9 nguồn, gửi Telegram" \
  --skills "daily-news,vnexpress-news" \
  --deliver telegram

# Server health check (every 30 min)
hermes cron create "*/30 * * * *" \
  --script /opt/scripts/check_health.sh \
  --no-agent \
  --deliver telegram

# Weekly code review (Sunday 10 AM)
hermes cron create "0 10 * * 0" \
  --prompt "Review PRs opened this week, check security, performance" \
  --skills "code-review" \
  --deliver all \
  --workdir ~/work/myapp

# Chain jobs: data collection → analysis → report
hermes cron create "0 8 * * *" \
  --script /opt/scripts/collect_metrics.py \
  --no-agent \
  --context_from "job_123" \
  --prompt "Analyze metrics and generate weekly report" \
  --skills "data-analysis"

6.2 Job Options Deep Dive ⚙️

Option Mô tả Ví Dụ
scheduleLịch chạy (cron expression hoặc human-readable)"30m", "every 2h", "0 9 * * *"
deliverNơi gửi kết quả"origin", "telegram", "all", ["telegram", "email"]
skillsSkills load trước khi run["daily-news", "vnexpress-news"]
modelOverride model cho job này{provider: "openrouter", model: "..."}
scriptScript chạy trước prompt (no_agent mode)/path/to/collect_data.py
context_fromChain job output từ job khác["job_id_1", "job_id_2"]
workdirWorking directory/path/to/project
no_agentChạy script thuần, không tốn tokens LLMtrue/false

6.3 Cron vs Interactive Sessions vs System Crontab 📊

Aspect Hermes Cron Interactive Session System Crontab + Bash
Tools Access✅ Full (60+ tools)✅ Full❌ Manual
Skills & Memory✅ Auto-loaded✅ Available❌ None
Multi-platform Delivery✅ Built-in✅ Manual❌ Manual curl/API
LLM Reasoning✅ Yes✅ Yes❌ No
CostTokens per runTokens per turnFree (script only)
Debugginghermes cron run IDInteractiveLogs only
Max Duration3-min hard interruptUnlimitedUnlimited
⚠️ Best Practice: Dùng Hermes cron cho scheduling phức tạp (multi-platform delivery, skill loading, chaining, cần LLM reasoning). Dùng system crontab cho simple script-only tasks (backup, cleanup, watchdog). Hermes cron có 3-minute hard interrupt — jobs không được chạy quá lâu.

6.4 Cron CLI Commands 🖥️

hermes cron list              # List all jobs
hermes cron create SCHED      # Create (interactive prompt)
hermes cron edit ID           # Edit job
hermes cron pause/resume ID   # Pause/resume
hermes cron run ID            # Run now (debug)
hermes cron remove ID         # Delete
hermes cron status            # Scheduler health

7. So Sánh Với Các Agent Khác ⚔️

📊 Bảng so sánh chi tiết — Hermes vs Claude Code vs OpenAI Codex:
Tính Năng Hermes Agent Claude Code OpenAI Codex
Mã nguồn mở✅ MIT❌ Closed❌ Closed
Self-improving skills✅ Curator auto-maintenance❌ Static CLAUDE.md❌ Static AGENTS.md
Persistent memory✅ 3 types (persistent, profile, FTS5)❌ Session-only❌ Session-only
Provider-agnostic✅ 20+ providers❌ Anthropic only❌ OpenAI only
Multi-platform✅ 20+ (Telegram, Discord, Slack...)❌ CLI + IDE only❌ CLI + IDE only
Built-in cron✅ Scheduler + delivery
MCP support✅ Full✅ Full
Delegation✅ Subagents + batch✅ Subagents✅ Subagents
Voice mode✅ CLI, Telegram, Discord
Windows support✅ Native✅ WSL2✅ Native
Serverless run✅ Modal, Daytona
Profiles (isolated instances)✅ Full isolation
Checkpoints/Snapshots✅ Git-like history
GiáMiễn phí (chỉ trả model)Model + subscriptionModel + subscription

7.1 Claude Code vs Hermes Agent — Specific Differences 🔍

🔑 Key differentiators:
  • Lock-in: Claude Code chỉ dùng Anthropic models. Hermes swap provider bất kỳ lúc nào.
  • Memory: Claude Code không có persistent memory cross-session. Hermes nhớ preferences, environment, corrections mãi mãi.
  • Skills: CLAUDE.md là static instructions. Hermes skills có versioning, publishing, auto-maintenance (Curator), usage tracking.
  • Platforms: Claude Code = CLI + IDE. Hermes = 20+ platforms including mobile (Telegram, WhatsApp).
  • Automation: Không có cron. Hermes có built-in scheduler với multi-platform delivery.
  • Cost: Claude Code cần subscription. Hermes = free (chỉ trả API model).

7.2 OpenAI Codex CLI vs Hermes Agent 🔍

🔑 Key differentiators:
  • Lock-in: Codex chỉ dùng OpenAI models. Hermes = provider-agnostic.
  • Memory: Codex không có persistent memory. Hermes = 3 memory types.
  • Skills: AGENTS.md static. Hermes = procedural memory with Curator.
  • Platforms: Codex = CLI + IDE. Hermes = 20+ platforms.
  • MCP: Codex không hỗ trợ MCP. Hermes = full MCP client.
  • Voice: Codex không có voice. Hermes = voice trên CLI, Telegram, Discord.
  • Open Source: Codex closed. Hermes = MIT license, 3000+ tests.
🏆 Kết luận: Hermes Agent vượt trội về tính linh hoạt (provider, platform), khả năng tự học (skills, memory), và mã nguồn mở hoàn toàn. Claude Code và Codex mạnh về integration IDE nhưng bị lock-in vào hệ sinh thái riêng.

💻 Code Example: Hermes Agent

from hermes import Agent, Task

agent = Agent(
    name="DataAnalyst",
    tools=["web_search", "python_exec"],
    model="claude-sonnet-4"
)

task = Task(
    goal="Analyze sales data",
    context={"data_path": "/data/sales.csv"}
)

result = agent.run(task)
print(result.summary)

8. Kết Luận & Lộ Trình Học 🚀

Hermes Agent không chỉ là một AI coding tool — nó là một nền tảng autonomous agent hoàn chỉnh với khả năng tự cải thiện, đa nền tảng, và mã nguồn mở. Dù bạn là developer, sysadmin, researcher, hay content creator, Hermes đều có thể trở thành trợ lý AI đắc lực chạy 24/7 trên server của bạn.

8.1 Learning Path for Beginners 📚

1 Install
2 Configure
3 Customize
4 Automate
# Step 1: Install (60 seconds)
curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash

# Step 2: Configure (interactive wizard)
hermes setup --portal    # Nous Portal OAuth + 4 tools (fastest)
# OR
hermes setup             # Full setup: pick model, providers, tools

# Step 3: Verify
hermes doctor            # Health check

# Step 4: Start chatting
hermes                   # Interactive mode
hermes chat -q "Hello"   # Single query

8.2 Next Steps — Customize & Automate ⚙️

  1. Add context files — Tạo .hermes.md trong project root để Hermes hiểu project của bạn
  2. Install skillshermes skills browsehermes skills install
  3. Setup gatewayhermes gateway setup → Telegram/Discord/Slack
  4. Create cron jobshermes cron create "0 7 * * *" --prompt "Morning briefing"
  5. Explore toolshermes tools list → enable toolsets you need
  6. Join community — Discord, GitHub Discussions, contribute skills

8.3 Resources 🔗

🔥 TL;DR: Hermes Agent = Open Source + Self-Improving + Multi-Platform + Persistent Memory + Built-in Automation. Một agent duy nhất thay thế mọi AI tools rời rạc. Cài đặt 60 giây, dùng trọn đời.