s3_call_hermes.md 1.04 KB

PLAN: S3 — Hermes CLI Integration (call_hermes function)

Goal

Encapsulate the inline subprocess.run(["hermes", "chat", ...]) code in app.py into a standalone call_hermes() function.

Current State

  • Lines 1364-1386: inline hermes call in POST /api/conversations//messages
  • Uses subprocess.run (blocking), which is fine for now but S4 needs Popen for SSE
  • Context building (history) already done above the call
  • Error handling exists: TimeoutExpired, FileNotFoundError, generic Exception

What to Change

  1. Extract inline code into call_hermes(user_input: str, timeout: int = 120) -> str
  2. Function takes user input string, runs hermes chat -m, returns stdout or error string
  3. Update the route handler to call call_hermes() instead of inline code

Files

  • app.py: extract function + update caller
  • test_s3_hermes_call.py: new test file

Verification

  • Test imports and runs without error
  • Mock subprocess.run to verify function signature and behavior

Risks

  • None — purely refactoring, behavior unchanged