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:
yaml Assistant
Let me start by exploring the repository structure to understand the codebase.
Assistant
Let me make single commands at a time.
Assistant
Let me look at the relevant source files. Let me start with the hermes API and remote-related files.
Assistant
Let me view the full file with line numbers, focusing on the API parts.
Assistant
Interesting. The health checks use
/health. The backend exposesGET /health -> 200 OKANDGET /v1/health -> 200 OK. The chat completions use/v1/chat/completions. The models endpoint... let me look for the models list in remote mode. Let me look at the cronjobs and models.ts and where the remote model list comes from.Let me look at the section 260-530 to see the sendMessageViaApi and the probe.
Assistant
Let me look at the cronjobs and models files, which may have the "remote list" and model fetching.
Assistant
Let me look at the config.ts for connection config.
Assistant
Let me look at the models.ts and how remote models are fetched.
Assistant
Now let me look at how remote models are listed - search for "v1/models" in the whole src.
Assistant
Let me look at the index.ts IPC handlers related to remote and the Gateway screen.
Assistant
Let me look at the existing tests for hermes-api and remote-history to understand expected behavior.
Assistant
This test uses
getConnectionConfigreturningremoteUrl: "http://test-api.example.com". The chat URL becomeshttp://test-api.example.com/v1/chat/completions. Good.Now, if I normalize the URL to strip trailing
/v1, this test still passes (no /v1 in the URL).Let me check the remote-history.test.ts and connection-config-security.test.ts.
Assistant
Let me look at the gateway IPC handlers and the Gateway screen.
Assistant
The
start-gatewayIPC handler in remote mode (mode === "remote") would callstartGateway()which spawns the local Hermes. This is the bug! When in remote mode, the user should NOT be able to start a local gateway. The Gateway screen probably has a "Start Gateway" button that callsstart-gateway, which in remote mode spawns the local (stale) installation.Let me check the Gateway screen.
Assistant
The Gateway screen has a "Start" button that calls
startGateway. In remote mode, thestart-gatewayIPC handler still callsstartGateway()which spawns the local Hermes. This is the source of thespawn .../venv/bin/python ENOENTerror.Let me look at the env-update handler sections that restart the gateway.
Assistant
Let me look at the installer.ts to understand HERMES_REPO, HERMES_PYTHON, and the stale-state aspect.
Assistant
Now let me check tests referencing startGateway/restartGateway and the installer tests, to make sure my guards won't break them.
Assistant
The office-start test mocks
startGatewayso it won't be affected by my guard. The connection-config-security test uses a server returning 200 for any path with correct auth, so my multi-endpoint fallback still works. Let me look at the Welcome and Settings screens to see how the URL is stored and validated.Assistant
Now I understand the issue fully. Let me look at the exact lines to edit in hermes.ts.
Assistant
Now let me implement the URL normalization. First, I'll add a
normalizeRemoteUrlhelper and updategetApiUrl,resolveRemoteApiKey.Assistant
No python3. Let me use the editor's replace command directly. Let me open the file.
Assistant
Now let me make the edits. First the
getApiUrlremote branch:Assistant
Now add the
normalizeRemoteUrlhelper and updateresolveRemoteApiKey:Assistant
Now let me update
testRemoteConnectionto normalize the URL and try multiple health endpoints. Let me view the current function:Assistant
Now let me rewrite
testRemoteConnectionto normalize the URL and probe multiple health endpoints robustly:Assistant
The file window isn't showing those lines. Let me use goto to navigate there, then edit.
Assistant
Now let me add the guard for
startGatewayandrestartGatewayto not spawn a local gateway in remote-only mode. Let me viewstartGateway:Assistant
The replace command needs the file to be scrolled to those lines. Let me goto 881 first, then replace. Actually, replace should work regardless of the window. The error says "Text not found in displayed lines." Hmm — maybe it only searches within displayed lines? Let me goto 881 first then run replace.
Actually wait, the previous replace for
getApiUrlworked without goto. Let me re-read the error: "Text not found in displayed lines. However, we found the following occurrences of your search string in the file: - line 881". So it found the occurrence but says "not found in displayed lines" — meaning the replace tool only operates on displayed lines? That's odd. Let me goto 881 then replace.Assistant
Now update
restartGateway:Assistant
Now let me verify the changes compile. Let me run the typecheck for the node config.
Assistant
Typecheck passes. Now let me run the relevant tests.
Assistant
All relevant tests pass. Let me verify the URL normalization behavior with a temporary test simulating both URL forms. Let me check the vitest config first.
Assistant
I'll create a temporary test to verify the
/v1normalization prevents doubling, then remove it.Assistant
Let me fix the temp test with a cleaner mutable variable approach.
Assistant
Now let me test that
startGatewayandrestartGatewaydon't spawn in remote-only mode.Assistant
The mock needs a default export. Let me fix the child_process mock.
Assistant
I also used
afterAllwithout importing. Let me fix and run.Assistant
Both spawn guards work. Now let me remove the temp test files and run the full test suite.
Assistant
All 435 tests pass. Let me check how
gatewayStatusis used in the renderer to decide whether to also make remote gateway-status reflect the remote server.Assistant
gatewayStatusis only used in the Gateway screen. To address the "ignore stale local install state" concern, let me makegateway-statusin remote mode reflect the remote server's health rather than a stale local PID. First, exportisApiServerReady.Assistant
Now update the
gateway-statusIPC handler in index.ts to use remote health in remote mode:Assistant
Let me add
isApiServerReadyto the import and update the gateway-status handler.Assistant
Now update the
gateway-statushandler. Let me view it:Assistant
Let me update the
start-gateway,stop-gateway, andgateway-statushandlers for remote mode:Assistant
Now let me run typecheck and the full test suite again.
Assistant
All tests pass. Let me check the ipc-handlers test to ensure my gateway handler changes are compatible.
Assistant
The ipc-handlers test only checks channel names, which are intact. Let me run lint on the changed files to be safe.
Assistant
Only pre-existing prettier formatting warnings, no errors. Let me review the final diff.
Assistant
The diff is clean. Let me confirm no temp test files remain and run the full test suite once more.
Assistant
All tests pass and no temp files remain. Let me run the web typecheck to be thorough (preload types unchanged but the gateway-status handler went async).
Assistant
Both typechecks pass and all 435 tests pass. Let me do a final review of the complete changes in
hermes.tsaround the key sections to ensure correctness.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.