ISSUE DESCRIPTION Hermes Desktop 0.4.3 remote mode fails against working local Hermes…
- User
ISSUE DESCRIPTION
Hermes Desktop 0.4.3 remote mode fails against working local Hermes API server
Bug: Hermes Desktop 0.4.3 fails to connect reliably to existing local Hermes API server
Summary
Hermes Desktop 0.4.3 fails to work as a frontend for an already-running local Hermes Agent API server.
The Hermes Agent backend is installed separately under
/opt/hermes-agent, runs correctly with Python 3.12, exposes the API server on127.0.0.1:8642, and successfully handles OpenAI-compatible API requests viacurl.However, Hermes Desktop fails to connect or send messages in remote mode. It either reports that it cannot reach the server, returns
404: Not Found, or tries to spawn a removed/incorrect local Hermes installation under~/.hermes/hermes-agent.Environment
- OS: Ubuntu 24.04.3 LTS
- Kernel: Linux 6.17.0-14-generic x86_64
- Desktop: KDE/Plasma
- Hermes Agent version: 0.14.0
- Hermes Desktop version: 0.4.3
- Hermes Agent install path:
/opt/hermes-agent - Hermes config/home:
~/.hermes - Python used by working Hermes Agent: Python 3.12.3
- GPU: NVIDIA RTX 5060 Ti, 16 GB VRAM
- Model backend: Ollama
- Ollama model:
gemma4:e4b - Ollama API endpoint:
http://127.0.0.1:11434/v1 - Hermes API server:
http://127.0.0.1:8642
Working backend configuration
Hermes Agent works correctly from CLI/API with this model configuration:
model: default: gemma4:e4b provider: custom base_url: http://127.0.0.1:11434/v1 The Hermes API server is enabled: API_SERVER_ENABLED=true API_SERVER_HOST=127.0.0.1 API_SERVER_PORT=8642 API_SERVER_KEY=<redacted> The backend works correctly via curl: KEY="$(grep '^API_SERVER_KEY=' ~/.hermes/.env | cut -d= -f2- | tr -d '\"'\'' ')" curl -i http://127.0.0.1:8642/v1/models \ -H "Authorization: Bearer $KEY" Expected/actual result from curl: { "object": "list", "data": [ { "id": "hermes-agent", "object": "model", "owned_by": "hermes", "root": "hermes-agent" } ] } Chat completions also work: curl -sS http://127.0.0.1:8642/v1/chat/completions \ -H "Authorization: Bearer $KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "hermes-agent", "messages": [ {"role": "user", "content": "Respond exactly: ok"} ] }' This returns a valid response from Hermes Agent, and Ollama confirms that the local model is loaded on GPU: gemma4:e4b 11 GB 100% GPU CONTEXT 65536 Problem in Hermes Desktop When using Hermes Desktop 0.4.3 and selecting: Connect to Remote Hermes with: URL: http://127.0.0.1:8642 API key: <API_SERVER_KEY> or: URL: http://127.0.0.1:8642/v1 API key: <API_SERVER_KEY> the GUI does not connect reliably. Observed GUI errors include: Could not reach Hermes at this URL. Check the URL and API key. and: Error: API server returned 404: 404: Not Found and: Error: API request failed: connect ECONNREFUSED 127.0.0.1:8642 Logs Hermes Desktop log includes: [CRON] remote list failed: HTTP 404 Error occurred in handler for 'send-message': Error: API server returned 404: 404: Not Found At one point, Hermes Desktop also attempted to spawn an old local Hermes installation that no longer exists: [MAIN UNCAUGHT] Error: spawn /home/patrick/.hermes/hermes-agent/venv/bin/python ENOENT spawnargs: [ '/home/patrick/.hermes/hermes-agent/hermes', 'gateway' ] This suggests that even after choosing remote mode, Hermes Desktop may still retain or use stale local-install state under ~/.hermes/hermes-agent. Route testing The local Hermes API server exposes these routes successfully: GET /health -> 200 OK GET /v1/health -> 200 OK GET /v1/models -> 200 OK POST /v1/chat/completions -> 200 OK But these routes return 404: GET /models -> 404 Not Found GET /api/health -> 404 Not Found This may indicate that Hermes Desktop remote mode expects routes that are not provided by the Hermes Agent OpenAI-compatible API server. Expected behavior Hermes Desktop remote mode should work with an existing Hermes Agent API server when provided: URL: http://127.0.0.1:8642 API key: API_SERVER_KEY or clearly document whether the required URL should be: http://127.0.0.1:8642 or: http://127.0.0.1:8642/v1 It should then list the exposed remote model: hermes-agent and send chat requests through the existing Hermes API server. Actual behavior Hermes Desktop does not list hermes-agent, fails validation, returns 404, or tries to spawn a stale local Hermes installation under: ~/.hermes/hermes-agent even though the remote Hermes API server is alive and working via curl. Why this appears to be a Hermes Desktop issue The backend works outside Hermes Desktop: curl /v1/models succeeds. curl /v1/chat/completions succeeds. Hermes Agent CLI works. Ollama backend works. GPU model loading works. The only failing component is Hermes Desktop remote frontend mode. Request Please clarify or fix Hermes Desktop remote mode behavior: Which URL format is expected for remote Hermes? http://host:8642 or http://host:8642/v1 Which endpoint does Hermes Desktop use to validate remote connectivity? Should remote mode depend on routes like /models, /api/health, /cron, or local gateway-management endpoints? Can Hermes Desktop avoid trying to spawn ~/.hermes/hermes-agent/... when the user explicitly chooses remote mode? Can stale local install state be ignored or reset when using remote mode? thanks!!! ## Interface No new interfaces are introduced. # ADDITIONAL ADVICE Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use `git checkout <file>` to restore the file to its original state. You can also reset all changes in the repository using `git reset --hard` command. Additionally, you can use `git stash` and `git stash pop` to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call `submit`) using `git status` or `git diff` commands. However you don't need to use `git add` or `git commit` before submitting your changes. In fact, `submit` only submits currently unstaged changes because it uses `git diff` to get the changes that need to be submitted. # CHECKLIST Before submitting your solution, please go over the following checklist and make sure you've done everything: - [ ] If an error was reported in the issue description, I have successfully reproduced it. - [ ] If an error was reported in the issue description, I have confirmed that my fix resolves the error. - [ ] I have thought about edge cases and made sure my fix handles them as well. - [ ] I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to. Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue! (Current directory: /hermes-desktop, current file: none) bash-$ - Assistant
I’ll first map the Electron application’s remote/local connection code and test setup, then reproduce the URL/route behavior with the smallest relevant test or harness before changing it. I’ll pay particular attention to URL normalization, model/chat endpoint construction, mode persistence, cron calls, and any local process startup paths.
- Assistant
The repository already has focused API, remote-history, and IPC tests, so I’ll inspect those alongside all URL and remote-mode call sites. This should reveal the intended contract and let me distinguish the OpenAI-compatible API from gateway-only features such as cron/history.
- Assistant
rgis unavailable in the environment, so I’ll use recursivegrepand directly open the likely main-process modules and tests. - Assistant
The grep confirms plain remote mode is intended to skip installer checks and
send-messagealready guards local gateway startup with!isRemoteMode(). The likely primary defect is endpoint concatenation: I’ll now read the complete Hermes URL helpers, connection setup handlers, and setup UI submission path to see whether/v1input becomes/v1/v1/...and whether mode is saved before validation. - Assistant
Two concrete issues are visible already:
getApiUrl()preserves a user-supplied/v1, while health appends/healthand chat likely appends/v1/chat/completions; additionally, startup re-validation callstestRemoteConnection(conn.remoteUrl)without passing the key, relying on exact URL string matching. I’ll inspect those implementations and config normalization to design one canonical base-URL function shared by validation and runtime. - Assistant
The runtime chat path indeed hardcodes
/v1/chat/completions; accepting either documented URL form requires canonicalizing an optional terminal/v1to the server origin/base. I’ll retrieve the remainder ofhermes.tsand then create a temporary focused mock test (not a repository test, per constraints) to demonstrate current/v1/v1and/v1/healthrequests before editing. - Assistant
The code guarantees that remote mode never enters CLI fallback, so the reported stale spawn is most plausibly a consequence of remote validation/startup failure leaving or restoring local mode, not the chat branch itself. The best robust fix is canonical persistence plus canonical comparisons, and validation against routes the Agent actually guarantees. I’ll inspect current validation and security expectations before modifying.
- Assistant
I have reproduced the defect directly from the implementation: a configured
http://host:8642/v1produces validation at/v1/healthand chat at/v1/v1/chat/completions, both inconsistent with the reported server routes. Before editing, I’ll also inspect model selection because remote chat currently uses the local model configuration; an OpenAI-compatible remote must use its exposedhermes-agentmodel rather than a stale desktop-local model. - Assistant
Remote chat currently sends
mc.modelfrom the desktop’s local config, contradicting the expected remote modelhermes-agent; andstartGateway()itself lacks a remote-mode guard, so any UI/IPC caller other thansend-messagecan still spawn the stale local path. I’ll address all three at the main-process boundary: canonical API base URL, remote model ID, and an unconditional no-spawn guard in gateway startup/restart. This avoids relying on every renderer call site behaving correctly. - Assistant
I’ll implement normalization in
config.tsso both newly saved and legacy-loaded settings converge, while preserving path-prefixed deployments (e.g./hermes/v1becomes/hermes). Invalid/non-HTTP URLs will fail validation rather than accidentally target local Hermes. I’ll then wire it into API calls, force the gateway’s OpenAI model ID in remote/SSH mode, and hard-stop local gateway lifecycle methods in plain remote mode. - Assistant
To satisfy model discovery rather than merely making chat route correctly, I’ll add an internal
GET /v1/modelsadapter for plain HTTP remote mode and expose those entries through the existinglist-modelsIPC interface (no new public interface). The remoteget-model-configwill identify the gateway model ashermes-agent, preventing stale local config from appearing in chat. SSH mode remains unchanged because it has full remote config access. - Assistant
Python is not installed in this container, so no files were changed. I’ll apply the same deterministic transformations with the repository’s Node runtime, then inspect the diff before proceeding.
- Assistant
The core diff is in place. I’ll now add remote model discovery using the same normalized base and bearer header, returning an empty list on unsupported/error responses so optional model listing cannot break chat connectivity. Then I’ll update existing IPC handlers to avoid local config/model file access in plain remote mode.
- Assistant
Prettier reformatted a few pre-existing long lines in
index.ts; I’ll minimize the patch later if needed. First I’ll run focused tests and typechecking to catch design/type issues. The existing Hermes API tests should also verify that root URLs remain unchanged and session behavior is unaffected. - Assistant
Focused tests exposed a mock-compatibility issue, not a runtime logic issue:
hermes.tsimported a newly added export from a fully mockedconfigmodule. I won’t alter tests. Instead I’ll move URL normalization into a small dependency-free main-process utility imported by both config and Hermes; this keeps existing module mocks stable and cleanly separates URL policy. - Assistant
Focused tests (50) and Node typechecking pass. I’ll now review the exact patch for unintended formatting and edge cases. One important safety edge case is an invalid legacy remote URL: remote mode must not silently fall back to
127.0.0.1:8642, because that could contact/spawn local state. I’ll makegetApiUrlfail closed for remote mode and ensure IPC gateway status/start are explicitly remote-safe. - Assistant
The review shows whole-file Prettier touched unrelated pre-existing formatting in three files. I’ll revert only those tracked files and reapply the functional edits surgically without formatting the entire files. This keeps the final diff focused and easier to audit.
- Assistant
The minimized diff is clean. I’ll strengthen the remote boundary in the existing gateway IPC handlers so start, stop, and status never inspect or manipulate local gateway state in plain remote mode. I’ll also make remote model selection non-mutating locally, since the remote API—not
~/.hermes/config.yaml—owns that model. - Assistant
The direct reproduction now confirms both accepted inputs resolve to exactly
/v1/chat/completions(and a reverse-proxy prefix is preserved). My IPC edit script had invalid Python-style triple quotes, so it made no changes; subsequent checks still passed on the prior patch. I’ll reapply those small IPC guards with JavaScript template literals. - Assistant
The remote safety guards pass all focused tests and Node typechecking. I’ll run the complete repository test suite, both TypeScript projects, and lint the changed files. Afterward I’ll inspect the final diff and verify no temporary artifacts or test changes exist.
- Assistant
All 435 tests pass, both TypeScript projects pass, and ESLint reports zero errors. Its 10 warnings are pre-existing whole-file Prettier disagreements (none in the new utility and unrelated to changed lines). I’ll do a final semantic review of the patch and repository status, including confirming no test files were modified.
- Assistant
One final semantic improvement follows from the report: validating only
/healthmay accept a server even when the API key is wrong, because health endpoints are often public. Since remote mode requires the OpenAI-compatible API and model discovery, validation should probe authenticatedGET /v1/models. This both verifies the key and confirms the exact API contract chat needs. I’ll switch that target and rerun the directly affected security/API tests. - Assistant
Final verification is complete:
- If an error was reported, I reproduced it: Yes. Direct execution of the production URL normalizer demonstrated that the old concatenation would treat
/v1as part of the server base; the code inspection confirmed requests became/v1/healthand/v1/v1/chat/completions. The production normalizer now maps bothhttp://host:8642andhttp://host:8642/v1to one canonical base and exactly/v1/chat/completions. - I confirmed the fix resolves it: Yes. Direct runtime checks covered root,
/v1, trailing slash, and reverse-proxy-prefix forms. Validation now targets authenticated/v1/models, chat uses/v1/chat/completions, remote model discovery exposeshermes-agent, and remote gateway IPC paths cannot spawn local Python.
- If an error was reported, I reproduced it: Yes. Direct execution of the production URL normalizer demonstrated that the old concatenation would treat
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.