Skip to content

fix(hermes): trim registered session env names so Windows bash -c never overflows - #52703

Merged
nwparker merged 1 commit into
mainfrom
fix/hermes-session-env-wrapper-limit
Nov 29, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/hermes-session-env-wrapper-limit

Conversation

@nwparker

@nwparker nwparker commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #51914.

Root Cause

Hermes's tools/environments/base_session_env.py emits ~500 bytes of bash save/restore wrapper per variable registered with ctx.register_session_env(...) on every bash -c invocation. Registering all 14 ORCA_* variables in orca-status/__init__.py inflated the wrapper to ~7.7 KiB before the command itself, overflowing Windows Git Bash's ~8,186-byte -c cap and truncating the wrapper tail (breaking every terminal call and read_file / write_file / patch / search_files).

Fix

  1. Register only 2 names in orca-status/__init__.py: ORCA_AGENT_SESSION_TOOL_TOKEN and ORCA_CLI_COMMAND (~990 bytes instead of ~6,924 bytes — ~86% reduction, leaving >5.5 KiB for commands on Windows). Updating pluginInitTemplate() also bumps HERMES_PLUGIN_GENERATION, so existing running Hermes gateways automatically update and reload in place on the next chat start.
  2. Load CLI routing env from the session file in orca CLI: Before trading ORCA_AGENT_SESSION_TOOL_TOKEN with the host, adoptSessionToolCaller reads the matching <home>/orca-sessions/<sessionId>.json file and applies SHARED_TOOL_PROCESS_CLI_ENV (ORCA_USER_DATA_PATH, ORCA_STRUCTURED_SESSION, ORCA_CLI_COMMAND, ORCA_ENVIRONMENT, ORCA_PAIRING_CODE, ORCA_REMOTE_PAIRING, and ORCA_RUNTIME_SOURCE_*), deleting any null entries so stale gateway routing never leaks.
  3. Adopt session caller before dropForeignTerminalHandle in src/cli/index.ts so foreign-handle checks run against the session's own routing env and handle rather than stale values inherited from a shared gateway.

Verification

  • Executed the generated orca-status/__init__.py in python3 and verified register_session_env registers only ['ORCA_AGENT_SESSION_TOOL_TOKEN', 'ORCA_CLI_COMMAND'] and _session_env filters to those keys (and unsets ORCA_AGENT_SESSION_TOOL_TOKEN when unpublished or closed).
  • Added unit tests in src/cli/runtime/session-tool-caller.test.ts and src/main/hermes/hermes-session-tool-env.test.ts.
  • pnpm check:changed passed (31/31 checks).
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​74 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​73
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​90 $\color{#cf222e}{\Huge{\mathbf{−}}}$​44 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​46

@nwparker
nwparker merged commit a8fb68e into main Nov 29, 2026
11 of 12 checks passed
@nwparker
nwparker deleted the fix/hermes-session-env-wrapper-limit branch November 29, 2026 22:49
@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge; no actionable defects were found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

This PR reduces the environment names registered with Hermes and moves CLI routing lookup into orca.

  • Hermes passes only two session names through its bash wrapper.
  • The orca CLI restores each chat's routing before connecting.

No actionable issues were found. Review was based on source inspection; tests were not run.

Diagram

sequenceDiagram
  participant H as Hermes plugin
  participant F as Published session file
  participant C as Orca CLI
  participant R as Local Orca host
  H->>F: Read this chat's environment
  H->>C: Forward token and CLI command
  C->>F: Find routing values matching the token
  C->>C: Apply routing and clear inherited caller
  C->>R: Trade token for session caller
  R-->>C: Return caller environment
  C->>C: Check terminal handle, then dispatch
Loading

Reviews (1) · Last reviewed commit: "fix(hermes): trim registered session env..." · Reviewed by Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant