Files
hermes-agent/agent
Teknium 2ee1cd1ebb fix(gateway): accept -s/--checkpoints/--pass-session-id/--accept-hooks as session creation policy
These four launch options had no working path on the canonical gateway. Classic
`hermes chat` refused them and pointed users at `hermes --tui ...`. The Ink TUI sent
them in session.create, but CREATE_FIELDS rejected them (4001 invalid_params at the
canonical contract), and canonicalRequest threw before the session existed.
localCreationOptions read the documented, exported HERMES_ACCEPT_HOOKS=1, so with
that variable set no TUI session could be created at all. HERMES_TUI_PASS_SESSION_ID
was read by nothing and was silently dropped. On main the in-process TUI gateway and
cli.py applied all four, and tests/hermes_cli/test_cli_preloaded_skills.py covered
the -s preload. That test was deleted on the branch with no replacement.

All four options are now creation fields of the session that names them, applied
by the owner:

- skills: rendered once with build_preloaded_skills_prompt (off the owner loop,
  only for a new session; a retried request_id resumes the frozen route) and stored
  in the frozen LocalSessionPolicy.skills_prompt. The in-process turn appends it to
  the ephemeral prompt and the managed worker passes it as ephemeral_system_prompt,
  matching the CLI/TUI startup preload. A typo among good names is logged and
  skipped, as on main. When no name resolves, creation is refused with unknown_skill.
  A bypass (--safe-mode / --ignore-user-config) launch refuses -s because it must
  not read the profile.
- checkpoints: folded into the frozen config's checkpoints.enabled, which the
  in-process agent already reads through _checkpoint_agent_kwargs(policy config).
  The managed worker now passes it too.
- pass_session_id: frozen in the request and passed to AIAgent (in-process and
  managed), so "Session ID: <id>" rides the system prompt.
- accept_hooks: consents to the profile's configured shell hooks (per-user
  allowlist, off-loop) and registers them on the owner, like the in-process
  --accept-hooks. It is a no-op on a bypass launch, so an exported
  HERMES_ACCEPT_HOOKS=1 cannot brick --safe-mode.

Classic `hermes chat` is a gateway client too: it forwards the same fields, plus
HERMES_ACCEPT_HOOKS=1 when that variable is exported, instead of refusing them.
The Ink TUI maps HERMES_TUI_SKILLS to a list and the flags to booleans, and the
pipe bootstrap stops leaking HERMES_TUI_CHECKPOINTS/HERMES_TUI_PASS_SESSION_ID into a
spawned daemon. The canonical contract (CanonicalCreateParams plus the generated
TS/OpenRPC) advertises the new fields.

Live proof: a real `python -m gateway.run` daemon on a fake home, a real WS
session.create per field, the real Ink mapping via tsx with HERMES_ACCEPT_HOOKS=1
exported, and a real turn against a loopback model. The skill body and
"Session ID: <id>" reach the model's system prompt, a write snapshots into the
checkpoint store (no snapshot without the flag), and the hook command lands in
the allowlist. A real `hermes chat -Q -q ... -s X --checkpoints --pass-session-id
--accept-hooks` exits 0 with the skill in its prompt. On the base, all of these
were refused with invalid_params, Ink threw, and classic chat exited 2.

Review: https://github.com/NousResearch/hermes-agent/pull/106742#pullrequestreview-5456384314
2026-10-08 09:10:37 -07:00
..
…