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.
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-improving và multi-platform vượt trội.
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ẽ:
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
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:
- (a) Build prompt + memory — Kết hợp identity, project context, user preferences, skills liên quan
- (b) LLM decides — Model phân tích và quyết định gọi
terminaltool với lệnhtop -bn1 | head -20 - (c) Runs tool — Tool registry dispatch tới
tools/terminal.py, chạy lệnh, capture stdout/stderr - (d) Returns result — Output CPU info được append vào messages, LLM tổng hợp trả lời
- (e) Saves to memory — Nếu user thường hỏi về CPU, Hermes ghi nhớ preference này cho lần sau
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 |
|---|---|---|
terminal | run, shell, process, tmux | Server admin, devops, build scripts |
file | read, write, patch, search, glob, ls | Code editing, config management |
web | search, fetch, extract | Research, fact-checking, news |
browser | navigate, click, screenshot, pdf | SPA scraping, auth flows, testing |
code_execution | python, jupyter | Data analysis, visualization, ML |
vision | analyze, ocr | Image analysis, diagram reading |
image_gen | generate, edit | AI art, thumbnails, diagrams |
tts | speak, voices | Voice responses, accessibility |
skills | browse, install, create | Skill management |
memory | read, write, search | Cross-session recall |
delegation | spawn, batch | Parallel subagents |
cronjob | create, list, edit | Scheduling automation |
session_search | search | FTS5 full-text search |
todo | add, update, list | In-session task tracking |
spotify | play, pause, search | Media control |
homeassistant | call_service, get_state | Smart home control |
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)
tools/*.py có registry.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/.
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
- Theo dõi usage statistics (use_count, view_count, patch_count)
- Đánh dấu skills cũ là
stalesaustale_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.
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
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)
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
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:
- Giữ system prompt + recent turns (last 5-10 exchanges)
- Tóm tắt các turn cũ thành summary ngắn gọn
- Giữ tool results quan trọng (file reads, search results)
- Xoá reasoning traces, temporary tool outputs
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ụ |
|---|---|---|
schedule | Lịch chạy (cron expression hoặc human-readable) | "30m", "every 2h", "0 9 * * *" |
deliver | Nơi gửi kết quả | "origin", "telegram", "all", ["telegram", "email"] |
skills | Skills load trước khi run | ["daily-news", "vnexpress-news"] |
model | Override model cho job này | {provider: "openrouter", model: "..."} |
script | Script chạy trước prompt (no_agent mode) | /path/to/collect_data.py |
context_from | Chain job output từ job khác | ["job_id_1", "job_id_2"] |
workdir | Working directory | /path/to/project |
no_agent | Chạy script thuần, không tốn tokens LLM | true/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 |
| Cost | Tokens per run | Tokens per turn | Free (script only) |
| Debugging | hermes cron run ID | Interactive | Logs only |
| Max Duration | 3-min hard interrupt | Unlimited | Unlimited |
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 ⚔️
| 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 + subscription | Model + subscription |
7.1 Claude Code vs Hermes Agent — Specific Differences 🔍
- 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 🔍
- 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.
💻 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 📚
# 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 ⚙️
- Add context files — Tạo
.hermes.mdtrong project root để Hermes hiểu project của bạn - Install skills —
hermes skills browse→hermes skills install - Setup gateway —
hermes gateway setup→ Telegram/Discord/Slack - Create cron jobs —
hermes cron create "0 7 * * *" --prompt "Morning briefing" - Explore tools —
hermes tools list→ enable toolsets you need - Join community — Discord, GitHub Discussions, contribute skills
8.3 Resources 🔗
- 📖 Docs: hermes-agent.nousresearch.com/docs/
- 🐙 GitHub: github.com/NousResearch/hermes-agent
- 🎯 Skills Hub:
hermes skills browse(trong CLI) - 💬 Nous Research Discord: discord.gg/nousresearch
- 🐦 Twitter/X: @NousResearch
- 📝 Blog Series: HyHon Blog — nhiều bài viết chi tiết về Hermes, AI agents, automation