Technical reference for building multi-agent systems with Hermes Agent, covering delegation, Telegram gateway, kanban coordination, cron automation, and production patterns.
AI Orchestration adalah koordinasi multiple AI agents untuk menyelesaikan task kompleks yang terlalu besar atau terlalu beragam untuk single agent. Satu orchestrator memecah task, mendistribusikan subtask ke specialist agents, dan menyatukan hasilnya.
| Problem | Orchestration Solution |
|---|---|
| Single agent kehabisan context window pada task besar | Orchestrator memecah task, setiap sub-agent punya context sendiri |
| Satu model tidak optimal untuk semua jenis task | Router mengirim coding ke model A, research ke model B |
| Task membutuhkan berbagai tools/permissions | Leaf agents dengan toolset terbatas sesuai peran |
| Parallelisasi tidak mungkin dengan single agent | Fan-out: N subtask berjalan bersamaan |
| Long-running task memblokir interaksi user | Background delegation: agent bekerja async |
| Error di satu step menghancurkan seluruh pipeline | Supervisor pattern: retry, fallback, checkpoint |
Hermes menggunakan delegate_task() sebagai API utama untuk mendelegasikan work ke sub-agent. Setiap delegation menghasilkan session terisolasi dengan context, tools, dan model config sendiri.
| Mode | Kapan Pakai | Sifat |
|---|---|---|
delegate_task(task="...", mode="single") | Task sekali jalan, butuh hasil sekarang | Blocking, tunggu sampai selesai |
delegate_task(task="...", mode="batch") | Multiple task paralel | Blocking semua, selesai bersamaan |
delegate_task(task="...", mode="background") | Task lama, user tidak perlu tunggu | Non-blocking, hasil kembali nanti |
Orchestrator (parent agent) bertugas: menerima user request, memecah task, delegate ke children, merge hasil. Tidak melakukan work berat sendiri.
Leaf agent (child) bertugas: eksekusi spesifik (coding, research, scraping). Punya toolset terbatas, context terisolasi, tidak bisa delegate lebih lanjut kecuali max_spawn_depth mengizinkan.
# ~/.hermes/config.yaml
delegation:
max_iterations: 50 # max tool calls per sub-agent session
max_concurrent_children: 3 # paralel sub-agents
max_spawn_depth: 2 # orchestrator -> child -> grandchild (max)
# Setiap sub-agent bisa override model:
delegate_task(
task="Research competitors",
model="claude-sonnet-4-20250514",
tools=["web_search", "web_extract"],
max_iterations=20
)
max_spawn_depth=2 berarti orchestrator bisa delegate ke child, child bisa delegate ke grandchild. Lebih dari 2 level = token cost explosion dan control loss.
Hermes berjalan sebagai Telegram bot melalui gateway layer. User berinteraksi via chat biasa, agent merespons dengan full tool access.
# Install gateway
hermes gateway install
# Configure (set bot token, allowed users)
hermes gateway setup
# Start gateway
hermes gateway start
# Check status
hermes gateway status
# View logs
hermes gateway logs
| Variable | Required | Description |
|---|---|---|
TELEGRAM_BOT_TOKEN | Yes | Bot token dari @BotFather |
TELEGRAM_ALLOWED_USERS | No | Comma-separated user IDs yang boleh interaksi |
TELEGRAM_GROUP_ALLOWED_CHATS | No | Chat IDs grup yang diizinkan |
TELEGRAM_ALLOW_ALL_USERS | No | true untuk buka akses ke semua user (hati-hati) |
TELEGRAM_REQUIRE_MENTION | No | true = bot hanya merespons jika di-mention di grup |
TELEGRAM_FREE_RESPONSE_CHATS | No | Chat IDs di mana bot merespons tanpa mention |
| Feature | Bot API (@BotFather) | User API (Telethon) |
|---|---|---|
| Baca chat history | Tidak bisa | Bisa |
| Join grup sendiri | Tidak bisa, harus diinvite | Bisa |
| Rate limit | 30 msg/detik per grup | FLOOD_WAIT (berfluktuasi) |
| Setup complexity | Rendah | Butuh phone number + session file |
| Forum topic support | Penuh | Penuh |
| Inline query | Didukung | Tidak |
| Risk ban | N/A (bot account) | User account bisa kena ban |
Hermes mendukung beberapa pattern koordinasi multi-agent. Pilih berdasarkan struktur task, bukan preferensi aesthetic.
Orchestrator memecah task identik menjadi N subtask paralel. Cocok untuk: batch processing, multi-source research, parallel testing.
Output agent A menjadi input agent B. Cocok untuk: research -> outline -> draft -> review -> publish.
Satu supervisor mengawasi quality output worker agents, bisa retry atau redirect. Cocok untuk: high-quality output yang butuh review loop.
Satu central agent (hub) memiliki akses ke specialist agents (spokes). Hub routing berdasarkan intent classification.
Telegram grup bisa diaktifkan sebagai forum dengan topik terpisah. Hermes bisa route pesan ke agent berbeda berdasarkan message_thread_id.
| Topic Name | Thread ID | Agent/Model | Purpose |
|---|---|---|---|
| #general | 1 | default | General conversation |
| #code-review | 108 | coding model | Code review requests |
| #research | 215 | research model | Deep research tasks |
| #devops | 342 | default + ssh tool | Server management |
| #content | 419 | default | Content writing pipeline |
| #monitoring | 587 | script-only | Cron-driven alerts |
| #store | 623 | store agent | E-commerce automation |
Hermes mendukung scheduled tasks yang berjalan tanpa user trigger. Bisa full agent mode atau script-only (tanpa LLM).
# Server monitoring setiap 5 menit (script-only, hemat token)
*/5 * * * * hermes cron run server-health --no_agent
# Daily digest jam 9 pagi (full agent mode)
0 9 * * * hermes cron run daily-digest
# Weekly report setiap Senin
0 10 * * 1 hermes cron run weekly-report
no_agent=True)Untuk task mekanis yang tidak butuh reasoning (health check, disk usage, restart service), script-only mode menjalankan bash/python script tanpa LLM. Token cost = 0.
Skills adalah procedural memory dalam format markdown. Disimpan di ~/.hermes/skills/. Setiap skill berisi: trigger conditions, numbered steps, pitfalls, verification. Agent auto-load skill yang relevan sebelum execute.
Session-based dan persistent memory. Agent bisa menyimpan context antar session (memories/ directory). Berguna untuk preference, project context, learned patterns.
Task board built-in untuk koordinasi multi-agent. Mendukung 8 coordination patterns:
| Pattern | Description |
|---|---|
| Fan-out | Split task ke N parallel cards |
| Pipeline | Card berpindah kolom (todo -> doing -> done) |
| Voting | Multiple agents vote on best option |
| Journal | Append-only log of decisions dan progress |
| Human-in-loop | Card menunggu approval user sebelum lanjut |
| @mention | Route card ke agent spesifik via mention |
| Thread-scoped | Card terikat ke Telegram topic/thread |
| Fleet farming | Distribute work across multiple Hermes instances |
Ketika bot-ke-bot communication tidak mungkin, gunakan shared context file:
# shared-context.json - flow states:
planning -> build_needed -> building -> test_needed -> testing -> done
# Orchestrator menulis:
{"task": "build login page", "status": "build_needed", "assigned_to": "builder-bot"}
# Builder bot membaca, menulis:
{"task": "build login page", "status": "test_needed", "output": "/tmp/login.html"}
Telegram bot sebagai first-line support. Agent classify intent, answer FAQ dari knowledge base, escalate ke human jika confidence rendah. Skill: firecrawl-knowledge-ingest untuk build knowledge base dari docs.
Research agent gather sources, writer agent draft, editor agent review, publisher agent format dan post. Pipeline pattern dengan kanban tracking. Setiap stage checkpoint ke shared context.
Telegram topic #code-review menerima PR link. Agent fetch diff, run multi-dimensional review (security, performance, style), post inline comments. Skill: claude-code-review.
Deep research dengan fan-out: 9 angle research (economic, technical, social, ...) dijalankan paralel, hasil di-synthesize oleh orchestrator. Skills: deep-research, firecrawl-deep-research.
Cron-driven monitoring: health check setiap 5 menit, alert ke Telegram topic #monitoring jika anomali. Script-only mode untuk checks, agent mode hanya untuk alert formatting dan root cause analysis.
Telegram digital store: catalog management, order processing, payment tracking. Skill: telegram-digital-store. SQLite-backed product DB, inline keyboard untuk browsing.
Satu bot token, satu Hermes instance. Semua routing via topic/thread_id atau intent classification. Simplest setup, cocok untuk personal use atau small team.
# Config
TELEGRAM_BOT_TOKEN=your_token
TELEGRAM_ALLOWED_USERS=user_id_1,user_id_2
# Routing: topic-based
# All tools available to single bot
Multiple bot tokens, setiap bot punya Hermes instance terpisah. Komunikasi via shared context file. Cocok untuk: specialization (coding bot vs research bot) dengan different model configs.
# Bot 1 (orchestrator): delegates, routes, merges
# Bot 2 (builder): coding, file operations
# Bot 3 (researcher): web search, scraping
# Shared context di /tmp/hermes-shared/
# File watcher trigger coordination
Tidak ada persistent bot. Cron jobs trigger Hermes agent secara periodik. Cocok untuk: monitoring, reporting, batch processing yang tidak butuh real-time response.
# Script-only (no LLM cost):
*/5 * * * * hermes cron run disk-check --no_agent
0 */6 * * * hermes cron run backup --no_agent
# Agent-mode (LLM reasoning):
0 9 * * * hermes cron run daily-report
0 8 * * 1 hermes cron run weekly-summary
Webhook-triggered: external events (GitHub push, form submission, payment callback) trigger Hermes task. Cocok untuk: CI/CD integration, automated workflows. Combine dengan background delegation.
| Feature | Hermes Agent | n8n | LangChain | CrewAI |
|---|---|---|---|---|
| Multi-agent delegation | Built-in, recursive | Via workflow nodes | LangGraph | Built-in (Crew/Agent) |
| Telegram native | First-class gateway | Via webhook/node | No (custom build) | No (custom build) |
| Terminal/shell access | Built-in tool | SSH node | Custom tool | Custom tool |
| File operations | Built-in (read/write/patch) | Via nodes | Custom tool | Custom tool |
| Skill/memory system | Markdown skills + SQLite | Workflow storage | Memory modules | Built-in memory |
| Cron/scheduling | Built-in cron system | Native scheduler | No | No |
| Self-hosted | Yes (single binary) | Yes (Docker) | Library (you host) | Library (you host) |
| Code execution | execute_code tool | Code node | Custom | Custom |
| Learning curve | Low (chat interface) | Medium (visual editor) | High (code-first) | Medium (code-first) |
| Visual workflow editor | No | Yes | LangGraph Studio | No |
| Rule | Why |
|---|---|
Set max_iterations per delegation | Prevent runaway agent loops burning tokens |
Use execute_code for mechanical pipelines | Token-efficient: single code block vs N tool calls |
Limit max_concurrent_children to 3-5 | Too many = context explosion + rate limits |
| Always provide constraints in task description | "Write to /tmp/out.md, max 500 words" vs vague "write something" |
| Use background mode for tasks > 30 detik | User tidak perlu tunggu, agent report selesai |
| Check sub-agent output before merging | Sub-agents hallucinate; orchestrator validates |
| Rule | Why |
|---|---|
| One orchestrator per task tree | Dua orchestrator = conflicting instructions |
| Leaf agents get minimal tools | Principle of least privilege + lower token cost |
| Use shared context file, not message passing | Telegram blocks bot-to-bot messages |
| Set spawn depth limit (2 max) | Deeper = more control loss + token cost |
| Log delegation chain | Debug: who did what, where did it fail |
| Use kanban for multi-step workflows | Persistence across crashes, visibility of progress |
| Anti-Pattern | Damage | Fix |
|---|---|---|
| 2+ bots di free-response chat | 3-10x token burn (bot reply loops) | Set TELEGRAM_REQUIRE_MENTION=true atau limit FREE_RESPONSE_CHATS |
| Restart Hermes setiap config change | Downtime, lost context | Gunakan hermes gateway reload (hot reload) |
Test bot via curl getUpdates | Steals updates dari polling bot | Gunakan hermes gateway logs untuk debug |
| SOUL.md terlalu panjang | Token waste setiap request | Max 200-300 baris, gunakan skills untuk detail |
| Delegation tanpa constraints | Sub-agent bikin file random, loop forever | Always set max_iterations, output path, scope limits |
cURL getUpdates saat polling aktif | Conflict: kedua consumer berebut updates | Hanya satu consumer per bot token |
Setiap delegation = new session = full system prompt + context. Orchestrator dengan 5 children bisa menghabiskan 5-10x token dibanding single agent. Mitigate: constrain max_iterations, use execute_code untuk task mekanis, use script-only cron jobs.
LLM providers: RPM/TPM limits berbeda per provider. Fan-out 10 concurrent agents bisa trigger rate limit. Mitigate: max_concurrent_children=3, stagger batch tasks.
Telegram: Bot API ~30 msg/detik per grup. User API FLOOD_WAIT unpredictable. Mitigate: queue messages, respect retry-after header.
Model context window (128K-200K) terasa besar tapi cepat habis dengan tool outputs (file contents, search results, code blocks). Sub-agent yang membaca file besar bisa kehabisan context sebelum selesai. Mitigate: chunk reads (offset/limit), summarize before delegate.
| Limit | Value | Impact |
|---|---|---|
| Message length | 4096 chars | Long responses dipotong, perlu split |
| File upload (bot) | 50 MB | Batas upload file |
| Inline keyboard buttons | 100 per message | Practically ~20-30 sebelum UI buruk |
| Bot-to-bot messaging | Tidak didukung | Perlu shared context workaround |
| Group join (bot) | Must be invited | Cannot self-join groups |
| Forum topic IDs | Not sequential | Must query actual IDs, cannot guess |
| Mechanism | Description |
|---|---|
secret_redaction | Auto-redact API keys, tokens, passwords dari agent output sebelum kirim ke Telegram |
command_approval | Mode: manual (user approve setiap command), smart (approve safe, flag risky), off (auto-execute) |
| User allowlist | TELEGRAM_ALLOWED_USERS - whitelist user IDs |
| Chat blocklist | Blacklist specific chat IDs dari akses |
| File path restrictions | Limit read/write path ke allowed directories |