AgentsHybridFreeActiveMachine-verified· beginner · ~10 min setup

Wire GLM-5.2 into Hermes: valid route, 64k-context check, no key in config

Validate a Hermes Agent config that runs GLM-5.2 through a real provider route (direct Z.AI or OpenRouter), clears Hermes's 64k minimum context, and keeps the API key out of config.yaml, before you start a session.

by Shilpa Mitra· verified today· v1.0.0

Run this workflow

CI-verified, 2/2 fixtures passing.

Build this with your agent

One copy-paste hands Claude Code, Codex, or Cursor the full recipe, steps included, nothing to fetch.

Intended Use

Anyone wiring GLM-5.2 into Hermes and wanting the config caught before the session. CI validates config.yaml: provider is zai or openrouter, the model resolves to glm-5.2, context_window is at least 64000 (Hermes rejects smaller windows for tool use), and there is no raw api_key in config.yaml (the key is referenced by env var name; secrets live in ~/.hermes/.env). No key, no model call. The chat itself is fenced.

Not for

  • Quantized-host surprises, the cheapest OpenRouter hosts sometimes serve a quantized GLM-5.2 (very good, not identical); if quality matters, check the host or use direct Z.AI
  • Assuming unlimited output, several hosts cap output near 32,768 tokens per call despite the 1M input context, so long generations return in chunks
  • Trusting promo pricing, the GLM Coding Plan's headline prices are intro rates that step up; price it on the standing tier
  • Ignoring data residency, GLM-5.2 is served from multiple regions and Hermes auto-detects global vs China; pin GLM_BASE_URL to the endpoint you want if residency matters

The Stack

Tested Against

hermes-agent.nousresearch.com/docs (providers, 2026-07)openrouter.ai/z-ai/glm-5.2ruby@3.x (YAML stdlib)

Side effects & data flow

Network
none, local only
Writes
./config.yaml
Credentials
none required

Prerequisites

  • Hermes installed
  • A Z.AI, OpenRouter, or GLM Coding Plan key (only to actually chat)

Steps

  1. 1

    Write the Hermes GLM-5.2 config and validate it

    Set the provider (zai for direct/Coding Plan, openrouter for the gateway), the model (zai/glm-5.2 or z-ai/glm-5.2), the context window, and reference the key by env var name (not its value). CI checks the route is valid, the context clears Hermes's 64k floor, and no raw key leaked into config.yaml. Actually starting a chat needs the key and is fenced.

    cat > config.yaml <<'YAML'
    provider: zai
    model: zai/glm-5.2
    context_window: 1000000
    api_key_env: GLM_API_KEY
    YAML
    ruby -ryaml -e '
    c = YAML.load_file("config.yaml")
    provider = c["provider"].to_s
    abort "BAD: provider must be zai or openrouter" unless ["zai", "openrouter"].include?(provider)
    model = c["model"].to_s
    abort "BAD: model must be GLM-5.2" unless model.include?("glm-5.2")
    ctx = c["context_window"].to_i
    abort "BAD: Hermes requires at least 64k context" if ctx < 64000
    if c["api_key"] && !c["api_key"].to_s.empty?
      abort "BAD: do not put a raw api key in config.yaml; reference it via api_key_env"
    end
    keyenv = c["api_key_env"].to_s
    abort "BAD: set api_key_env to the env var name holding the key" if keyenv.empty?
    puts "config OK: Hermes -> " + model + " via " + provider + ", context " + ctx.to_s + " >= 64k min, key from $" + keyenv + " (not in config)"
    '
  2. 2

    Set the key and start a chat (the model step, not checked by CI)

    Run hermes config set GLM_API_KEY <your-key> (Hermes puts it in ~/.hermes/.env), then hermes config set model zai/glm-5.2 and hermes. Confirm the banner shows GLM-5.2 and ask something specific; hermes doctor diagnoses config problems. Do not move on to automations until a plain chat works. The chat is fenced.

Eval, 2 fixtures

Last passed: verified today
  • config-okcontainstimeout 30s · max $0

    Expected: config OK: Hermes -> zai/glm-5.2 via zai, context 1000000 >= 64k min, key from $GLM_API_KEY (not in config)

  • clean-exitexit_codetimeout 30s · max $0

    Expected: 0

Results

GLM-5.2 is a strong, cheap, open-weights model, and Hermes treats Z.AI as a first-class provider (id zai), so wiring the two is a two-line job. Three routes land on the same glm-5.2: direct Z.AI (canonical), OpenRouter (one key for everything, often cheapest, easiest to A/B), and the flat-rate GLM Coding Plan (same zai provider, coding endpoint auto-detected). GLM-5.2's 1M context clears Hermes's 64k floor with room to spare.

Did this work for you?

Our CI checks the setup runs. You tell us if the whole thing worked. Tell us straight.

Related workflows

Liked this workflow?

Get new verified workflows in WebAfterAI, three issues a week (Tue, Thu, Sat).