Skip to content

draft: add gateway-backed WebUI chat mode#2553

Draft
AJV20 wants to merge 2 commits into
nesquena:masterfrom
AJV20:feat/webui-gateway-chat
Draft

draft: add gateway-backed WebUI chat mode#2553
AJV20 wants to merge 2 commits into
nesquena:masterfrom
AJV20:feat/webui-gateway-chat

Conversation

@AJV20
Copy link
Copy Markdown
Contributor

@AJV20 AJV20 commented May 18, 2026

Thinking Path

WebUI currently has a direct in-process chat execution path, while messaging surfaces go through Hermes gateway/runtime paths. This draft PR introduces an opt-in gateway-backed browser chat mode so maintainers can review the architectural direction without changing default behavior.

What Changed

  • Adds HERMES_WEBUI_CHAT_BACKEND=gateway to route /api/chat/start turns through Hermes Gateway/API Server.
  • Adds HERMES_WEBUI_GATEWAY_BASE_URL and HERMES_WEBUI_GATEWAY_API_KEY / API_SERVER_KEY handling for the gateway connection.
  • Translates gateway OpenAI-compatible streaming chunks and hermes.tool.progress events back into the existing WebUI SSE events (token, tool, done, stream_end).
  • Preserves the existing direct _start_chat_stream_for_session(...) path as the default fallback.
  • Documents the env vars in ARCHITECTURE.md and adds static regression coverage for the opt-in branch and streaming mapping.

Why It Matters

This is a reversible architecture slice for making WebUI behave more like Hermes messaging surfaces by delegating execution to the gateway/runtime layer instead of constructing AIAgent directly in WebUI. It is intentionally draft/default-off so maintainers can evaluate config, auth, cancellation, attachment, and runtime-ownership tradeoffs before considering merge readiness.

Verification

Set HERMES_AGENT_PY to the Hermes Agent virtualenv Python for your install, for example ~/.hermes/hermes-agent/venv/bin/python.

  • $HERMES_AGENT_PY -m py_compile api/routes.py api/config.py api/streaming.py
  • $HERMES_AGENT_PY -m pytest tests/test_gateway_chat_bridge.py tests/test_sprint42.py -q
  • Result: 33 passed in 2.20s
  • Local manual smoke outside this clean PR worktree: Hermes Gateway /health returned OK and /v1/chat/completions returned the expected gateway-ok response.

Risks / Follow-ups

  • Draft only: upstream should review whether this should be an env flag, settings-backed config, or a RuntimeAdapter slice.
  • Cancellation currently clears WebUI-side pending state but does not yet forward a stop request to a gateway run id.
  • Attachment/image parity is not complete in this spike.
  • Approval/clarify/queue/goal controls may need deeper gateway/run API integration before this is ready to merge.
  • The state layer affected is the WebUI chat streaming/runtime boundary: WebUI still owns browser presentation/session JSON while gateway owns model/tool execution for opted-in turns.

Model Used

OpenAI Codex CLI via Hermes Agent, with terminal/file tools for implementation, tests, git, and GitHub REST automation.

AJV20 added 2 commits May 18, 2026 15:38
(cherry picked from commit cf69b4053c8f756f7c6f62109bf7f2ae0446af4c)
…chat

# Conflicts:
#	CHANGELOG.md
#	api/routes.py
@AJV20
Copy link
Copy Markdown
Contributor Author

AJV20 commented May 19, 2026

Updated the draft branch in 3e51156 after the latest master merge.

What changed:

  • Resolved CHANGELOG.md.
  • Resolved the api/routes.py conflict by preserving the gateway-backed chat helpers and the new _runtime_adapter_goal_action() helper from current master before /goal handling.

Verification:

  • python3 -m py_compile api/routes.py
  • /Users/abdiel/.hermes/hermes-agent/venv/bin/python -m pytest tests/test_gateway_chat_bridge.py -q -o addopts= → 3 passed
  • GitHub Actions matrix is green for 3.11 / 3.12 / 3.13

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant