Knowledge Hubบทที่ 17
Updates · อัปเดตใหม่

Hermes Agent Actually Work · อ่านคู่มือให้ใช้งานจริง

PDF เล่มนี้ไม่ใช่คู่มือลงโปรแกรมตั้งแต่ศูนย์ แต่เป็นแผนที่ว่าพอ Hermes รันได้แล้วต้องดูอะไรเวลา operate จริง · This PDF is not the first-install book; it is the operating map for running Hermes without guessing.

อ่านเล่มนี้แบบไหนดี · How to read this PDF

Making Hermes Actually Work เป็น Book 2 ของ Hermes: มัน assume ว่า install พื้นฐานผ่านแล้ว แล้วพาอ่าน internals ที่มักทำให้ระบบพังตอนใช้งานจริง เช่น token หมดอายุ, gateway ไม่ reconnect, session key งง, profile clone แล้ว provider ไม่เปลี่ยน, และ kanban task ถูก route ผิดตัว

Making Hermes Actually Work is Hermes Book 2. It assumes the base install already exists, then explains the internals that break real operations: expired tokens, gateway reconnect loops, confusing session keys, cloned profiles keeping the wrong provider, and kanban routing to the wrong worker.

วิธีอ่านง่ายที่สุด: อย่าอ่านเป็น manual ยาว ๆ ให้อ่านเป็น failure map — ถ้าเห็นอาการนี้ ให้ตรวจชั้นนี้ก่อน

ติดตั้งบนเครื่องนี้แล้ว · Install status on this host

CheckResultMeaning
hermes --versionHermes Agent v0.16.0CLI installed and importable.
Install mode--skip-setup --skip-browser --non-interactiveInstalled CLI/runtime without opening the interactive key wizard or downloading Chromium.
Default profileanthropic/claude-opus-4.6, gateway stoppedHermes exists, but messaging gateway is not started yet.
Codex source~/.codex/auth.json presentCodex token import path is available if we configure an openai-codex profile later.

Mental model: 5 boxes

Token

Identity of the external platform bot. If it leaks or rotates, gateway behavior changes immediately.

Gateway

The long-running bridge that receives Discord/Telegram/etc. events and routes them into Hermes sessions.

Session

A deterministic address, not a random chat blob. Resetting text is not the same as changing the address.

Profile

A named Hermes identity with its own config, env, SOUL, sessions, memory, and home sandbox.

Kanban

A SQLite board used as the contract between profiles. Profiles do not need to RPC each other.

Token and PM2: จุดที่พังง่ายที่สุด

บทแรกของ PDF ย้ำว่า Discord bot token ไม่ใช่ string ธรรมดา แต่เป็น lifecycle object. พอ reset token ใน Developer Portal, gateway ที่ถือ token เก่าจะเจอ WebSocket close 4004 Authentication Failed ทันที

The first chapter treats the Discord bot token as a lifecycle object. Once the token is reset in the Developer Portal, a gateway still holding the old token will hit WebSocket close 4004 Authentication Failed.

DoAvoidWhy
Store bot token in pass.Raw token in .env or command args.Keeps secrets encrypted and out of shell history.
Verify with GET /users/@me before gateway launch.Assume a pasted token is valid.One curl beats ten minutes of gateway debugging.
Use a PM2 wrapper that reads pass after process start.Start PM2 with DISCORD_BOT_TOKEN=... in the parent env.pm2 save can serialize env into dump.pm2.
Stop, reload env, start after token rotation.PM2 restart/reconnect with stale env.Restart may reuse the captured old token.

Gateway: อย่าเชื่อว่า connected แปลว่าทำงานแล้ว

Gateway มีหลายชั้น: adapter รับข้อความ, session router หา address, agent runner ทำงาน, แล้ว platform adapter ส่งผลลัพธ์กลับ. ถ้าขั้นใดขั้นหนึ่งค้าง คนจะเห็นเหมือน bot เงียบทั้งที่ bridge ได้ยินแล้ว

The gateway has layers: adapter receives a message, session router builds the address, agent runner works, and the platform adapter sends the result back. If any layer stalls, the user sees silence even when the bridge heard the message.

Invariant: receive event ≠ delivered to agent ≠ replied to channel.

Session key: address ไม่ใช่ความจำ

PDF อธิบายว่า session key ถูกสร้างจาก pattern ประมาณ agent:main:<platform>:<chat_type>:<chat_id>[:thread][:user]. ดังนั้น DM, channel, thread, และ per-user grouping อาจเป็น address คนละอัน

The PDF explains that the session key is built from a shape like agent:main:<platform>:<chat_type>:<chat_id>[:thread][:user]. A DM, channel, thread, and per-user grouping may therefore land in different session addresses.

SymptomLikely layerFirst check
Agent seems to remember after /reset.Same session address, trimmed transcript.Check session key and session file.
Same bot behaves differently in DM vs channel.Different chat type/address.Compare platform + chat_id in logs.
Thread reply loses context.Thread id changed the key.Verify whether thread is part of the key.

Profiles: identity แยก แต่ infrastructure บางอย่าง share

Profile ไม่ใช่แค่ชื่อเล่น. ใน Hermes มันคือ isolated directory: config, env, SOUL, sessions, memories, และ home sandbox. แต่บาง credential เช่น Codex auth อาจ fallback ไป global root auth ได้

A profile is not just a nickname. In Hermes it is an isolated directory: config, env, SOUL, sessions, memories, and a home sandbox. Some infrastructure credentials, such as Codex auth, may still fall back to the global root auth store.

TaskCommand shape
Create a profilehermes profile create codex --description "Reads and writes Python backend code, runs tests, refactors, and verifies changes"
Inspect model confighermes -p codex config get model
Patch provider after clonehermes -p codex config set model.provider openai-codex
Patch model after clonehermes -p codex config set model.default gpt-5.5
List profileshermes profile list

Providers and auth: GLM ง่าย, Codex ต้องระวัง TTY

GLM/Z.ai เป็น API-key provider: set GLM_API_KEY แล้วเลือก provider. Codex ซับซ้อนกว่าเพราะ Hermes มี command ที่ถามยืนยันใน TTY ก่อน import token จาก Codex CLI

GLM/Z.ai is a simple API-key provider: set GLM_API_KEY and choose the provider. Codex is trickier because Hermes has an interactive confirmation step before importing tokens from Codex CLI.

บทเรียนของ PDF: ถ้า CLI ติด TTY prompt ใน automation ให้อ่าน source หา function-level path ก่อนสรุปว่าทำไม่ได้

Kanban: board คือ contract ระหว่าง engines

Hermes kanban ไม่ใช่ chat ระหว่าง agent. มันคือ SQLite board ที่ decomposer แยกงานจาก triage แล้ว route ตาม description ของ profile ไม่ใช่ตามชื่ออย่างเดียว

Hermes kanban is not agent chat. It is a SQLite board where the decomposer splits a triage task and routes work by profile description, not just by profile name.

RuleWhy it matters
Create root work with --triage.Decompose only works on triage tasks.
Describe every profile.Routing by description is more reliable than routing by name.
Use parents for real dependencies.Independent children can run in parallel; dependent children wait.
Treat gave_up as a circuit breaker.Fix auth/protocol, then unblock instead of pretending the task succeeded.

Slash commands: 3-second defer

Discord slash commands must acknowledge within about 3 seconds. Hermes therefore has a defer path: reply fast first, do the real work after. When users see “did not respond,” it can mean defer/sync/fingerprint timing, not that the handler does not exist

Discord slash commands must acknowledge within roughly 3 seconds. Hermes therefore defers quickly, then does the real work after. “Did not respond” can be a defer/sync/fingerprint timing issue, not proof that the command is missing.

maw hermes plugin: direct REST when gateway is too much

บทท้ายของ PDF แสดง pattern ที่ตรงกับงาน fleet: ถ้าต้องการส่ง/อ่าน Discord แบบเร็วและตรวจสอบได้ ไม่จำเป็นต้องผ่าน gateway หรือ LLM เสมอไป. Maw plugin เล็ก ๆ สามารถเรียก Discord REST ตรงด้วย token จาก pass

The final chapter shows a fleet-friendly pattern: for fast, verifiable Discord read/send, you do not always need the full gateway or an LLM. A small maw plugin can call Discord REST directly with a token from pass.

Command ideaREST endpoint
maw hermes whoamiGET /users/@me
maw hermes read <channel> <n>GET /channels/<channel>/messages?limit=n
maw hermes send <channel> <text>POST /channels/<channel>/messages
maw hermes channelsGET /users/@me/guilds

Trap table แบบอ่านเร็ว

TrapSymptomFix
Raw token in PM2 env~/.pm2/dump.pm2 can contain plaintext token.Use wrapper script that reads pass and execs Hermes.
Token rotated while gateway runsWS close 4004, repeated auth failure.Stop gateway, update pass, reload env, start fresh.
Cloned profile keeps old providerNew codex profile still uses GLM/Z.ai.Set model.provider and model.default after clone.
Codex import asks for TTYAutomation no-ops or hangs at Y/N prompt.Use source-verified import path or run interactive setup manually.
Kanban task not triagedecompose says task is not in triage.Create root task with --triage.
Slash command says did not respondDiscord UI reports timeout.Check defer timing, fingerprint sync, and handler logs before claiming command missing.

Operational checklist

  1. Install Hermes CLI first; verify hermes --version.
  2. Run setup/auth only in a channel that can handle secrets safely.
  3. Create profiles with descriptions before using kanban routing.
  4. Verify token with REST before gateway launch.
  5. Use pass-wrapper if PM2 manages a gateway.
  6. When something is silent, check receive → queue/session → agent → reply as four separate layers.