feat(bridge): add Hermes JSONL bridge with native/synthetic streaming…#287
feat(bridge): add Hermes JSONL bridge with native/synthetic streaming…#287zayr0-9 wants to merge 1 commit into
Conversation
…, docs, and tests
|
Hey @zayr0-9, thanks for the effort here — the bridge concept is genuinely useful and the protocol design (JSONL over stdio, ping/pong, interrupt, shutdown) is well thought out. However, we have a concern with the scope of the run_agent.py changes. This PR adds ~400 lines to an already complex file — event emission at every return point, a full streaming code path, tool call accumulation, etc. It makes the core agent loop significantly harder to read and maintain. After reviewing, we believe the bridge can deliver its full value without touching run_agent.py at all:
The only thing that genuinely requires run_agent internals is native token-by-token streaming ( What we'd like to see: A refactored PR where bridge.py is a clean wrapper around the existing AIAgent API:
The type hint cleanups and tool_calls parsing improvements in run_agent.py are welcome but should be a separate small PR. If we later want an This would take the PR from ~1800 lines touching the agent core to a ~700-line additive-only change, which is much easier to review and merge confidently. Let us know if you have questions or want to discuss the approach! |
|
All right I will trim it down to just have a simple headless server interface without touching run_agent.py 😁 |
Title
feat(bridge): add JSONL stdio bridge with native/synthetic streaming support, docs, and tests
Summary
This PR adds a new
hermes bridgemode for embedding Hermes in external hosts (Electron apps, local servers, custom frontends, etc.) using a deterministic JSONL protocol over stdio.It supports both streaming and non-streaming consumers:
native_stream=true+native_assistant_delta=true)assistant_delta)assistant_message+finalevents)Why
Host integrations currently need a stable, machine-readable transport.
This introduces a first-class bridge protocol so frontends can consume Hermes output without scraping TUI text.
What’s included
New
hermes_cli/bridge.pyrunping→ponginterrupt→interrupt_ackshutdown/exit/quit→shutdown_acksession_idcwdhandlingUpdated
hermes_cli/main.pyhermes bridgecommand + args:--model,--base-url,--api-key,--max-iterations--toolsets,--disabled-toolsets--cwd,--once,--verbose--assistant-delta,--assistant-delta-chunk-size--native-assistant-delta,--native-streamrun_agent.pyREADME.mdassistant_deltaTests
tests/hermes_cli/test_bridge.pytests/test_run_agent.pyProtocol behavior notes
Backward compatibility
hermes/hermes chatflows.hermes bridgeonly).How to test
Manual smoke:
{"type":"run","request_id":"req-1","session_id":"sess-1","message":"Summarize README.md","assistant_delta":true,"native_stream":true,"native_assistant_delta":true} {"type":"interrupt","request_id":"req-2","session_id":"sess-1","message":"stop now"} {"type":"shutdown","request_id":"req-3"}Branch may drift due to active upstream updates; happy to rebase/sync once review feedback is in.