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
Let me start by exploring the repository structure to understand the codebase and then figure out how to fix the issue with Hermes Desktop remote mode.
The issue is about:
- Hermes Desktop failing to connect to a remote Hermes Agent API server
- Incorrect route expectations (e.g., /models vs /v1/models)
- Stale local installation state being used even in remote mode
- The desktop app trying to spawn local installation even when remote mode is selected
Let me explore the repository first.
Assistant
Let me explore more of the source structure to understand the architecture.
Assistant
Let me look at files that likely handle remote connections — the main hermes.ts, models, config, and the renderer.
Assistant
Now let me look at the key files that handle remote connections. Starting with
src/main/hermes.ts:Assistant
The open command needs to be run in the bash terminal. Let me just use cat instead.
Assistant
Let me also check the models.ts, config.ts, and more of the hermes.ts file (it was truncated):
Assistant
Let me read config.ts and the full hermes.ts:
Assistant
Let me read the rest of hermes.ts and then installer.ts:
Assistant
Let me read the rest of hermes.ts, especially the sendMessageViaApi function and remote-related functions.
Assistant
Let me continue reading the rest of hermes.ts.
Assistant
Let me read installer.ts and the renderer-side remote connection code
Assistant
Now let me look at the renderer-side code for remote connections and the gateway setup:
Assistant
Let me search for the IPC handlers related to remote connection testing and model listing in the index.ts
Assistant
Let me see the list-models handler and surrounding context:
Assistant
Now let me look at the renderer-side code for remote connection - the Setup and Settings screens:
Assistant
Let me look at the Settings screen to understand remote mode configuration:
Assistant
Let me look at cronjobs.ts and search for remote-related model listing and cron job code
Assistant
Let me search for all the places where
startGatewayandensureApiServerConfigare called:Assistant
Let me check the critical section at line 612 in index.ts and also the office-start.ts
Assistant
Let me look at the Gateway screen code to see if it calls startGateway without checking remote mode:
Assistant
Let me check the
start-gatewayIPC handler:Assistant
Let me look at the ModelPicker and the Models screen to understand how models are handled:
Assistant
Let me look at
useModelConfighook:Assistant
Let me search for all API endpoint paths to find potential mismatches:
Assistant
Let me search for the error messages mentioned in the issue
Assistant
Let me look at the Welcome screen and App.tsx to understand the connectivity check flow:
Assistant
Let me look at App.tsx to understand the startup flow and remote connectivity check:
Assistant
Let me look at the
set-connection-configIPC handler and theget-connection-confighandler:Assistant
Let me look at the set-connection-config handler:
Assistant
Now I have a comprehensive understanding of the codebase. Let me summarize the issues and plan my fixes:
Issues Found:
-
Model listing in remote mode:
list-modelsIPC handler reads localmodels.jsoneven in remote mode. It should fetch models from the remote API at/v1/models. -
Gateway management in remote mode:
start-gateway/stop-gatewayIPC handlers don't check for remote mode — they fall through tostartGateway()which spawns local hermes-agent processes. -
startGatewayfunction: No remote mode guard before spawning local processes. -
Cron jobs in remote mode: Uses
/api/jobsendpoint which may not exist on the Hermes Agent API server.
Let me now implement fixes. Let me start by reading the full hermes.ts to understand all the functions I need to modify.
-
Assistant
Let me check the preload index to see the API surface exposed to renderer
Assistant
Now I have a thorough understanding. Let me implement the fixes. I'll start with the core changes:
Key fixes needed:
- Add remote model fetching function in
hermes.ts - Fix
startGateway/stopGateway/restartGatewayto guard against remote mode - Fix
list-models,start-gateway,stop-gateway,gateway-statusIPC handlers for remote mode
Let me start:
- Add remote model fetching function in
Assistant
Let me check the current imports in hermes.ts and make my edits
Assistant
Now let me implement the changes. First, I'll add the
randomUUIDimport andSavedModeltype to hermes.ts:Assistant
Let me add the needed imports. First, update the import from
"./models"to includeSavedModeland addrandomUUIDfrom `"crypto"Assistant
Let me use replace to add the import
Assistant
Let me use the bash terminal directly for the
Assistant
Now update the models import to also include
SavedModelAssistant
Now let me add the
fetchRemoteModelsfunction. I'll add it aftertestRemoteConnection:Assistant
Let me see the end of the
testRemoteConnectionfunction and therestartGatewayfunction to find where to add the new functionAssistant
Now let me add the
fetchRemoteModelsfunction betweentestRemoteConnectionandrestartGateway. I'll use sed to insert after line 996 (the closing}oftestRemoteConnection):Assistant
Now let me insert the
fetchRemoteModelsfunction aftertestRemoteConnection:Assistant
Now let me add remote mode guards. First, let me fix
startGateway:Assistant
Let me look at the startGateway function and add the remote mode guard
Assistant
Now add the remote mode guard to
startGateway. I'll add it right afterensureInitialized():Assistant
Now fix
stopGatewayto add remote mode guard:Assistant
Add remote mode guard to stopGateway.
Assistant
Add the remote mode guard to stopGateway.
Assistant
Now fix
restartGatewayto add remote mode guard.Assistant
Add remote mode check to restart
Assistant
Add remote mode check to restart
Assistant
Now let me fix
index.ts. First, importfetchRemoteModelsand fix the IPC handlers:Assistant
Let me check what's imported from hermes.ts in index
Assistant
Add
fetchRemoteModelsto the import from hermesAssistant
Let me verify the import looks right
Assistant
Now let me fix the
list-modelsIPC handlerAssistant
See the current list-models handler
Assistant
Fix the list-models handler to fetch from remote API in remote mode
Assistant
Now let me fix the
start-gatewayhandlerAssistant
See the current start-gateway handler
Assistant
Fix start-gateway handler for remote mode
Assistant
Now fix the
stop-gatewayhandlerAssistant
See and fix stop-gateway handler
Assistant
Fix stop-gateway handler for remote mode
Assistant
Now fix the
gateway-statushandlerAssistant
See and fix gateway-status handler
Assistant
Fix gateway-status for remote mode
Assistant
Let me verify my changes compile correctly. Let me check the diff first:
Assistant
I see there's an extra closing brace
}after thefetchRemoteModelsfunction. Let me fix that:Assistant
Let me see the area around the
Assistant
Remove the extra closing brace
Assistant
Now let me check the diff for index.ts
Assistant
Good. Now let me check if the TypeScript compiles:
Assistant
TypeScript compiles successfully. Let me now run the existing tests:
Assistant
There's a syntax error. Let me look at the file to understand the issue:
Assistant
Let me look at lines 996-1006 to understand the structure:
Assistant
Let me check the full structure of
testRemoteConnectionand the inserted code:Assistant
Let me check line by line:
Assistant
I see - the closing brace for
testRemoteConnectionfunction is missing. Let me check the original file:Assistant
Let me find where the closing brace
}for testRemoteConnection went:Assistant
Let me look at what's at those line numbers:
Assistant
I see the issue - the closing
}fortestRemoteConnectionis missing because it got pushed below the inserted code. Let me add it back:Assistant
Let me verify the fix:
Assistant
Let me check the end of fetchRemoteModels and
Assistant
Now let me re-run the TypeScript compiler:
Assistant
TypeScript compiles. Let me run the tests now:
Assistant
All tests pass. Now let me check for any other places where local process spawning might happen in remote mode:
Assistant
Let me check the
getModelConfigfunction to understand how models work in remote mode:Assistant
Let me check
getModelConfig:Assistant
I found a critical issue! When users enter the URL as
http://127.0.0.1:8642/v1, thegetApiUrl()keeps the/v1suffix, leading to double/v1in API paths like/v1/v1/chat/completions. Let me fixgetApiUrl()to strip trailing/v1:Assistant
See the getApiUrl function:
Assistant
I need to also strip trailing
/v1so we don't get double/v1/v1/...paths. Let me fixgetApiUrl():Assistant
Let me verify the change:
Assistant
Now let me also check
testRemoteConnection- it usesstripTrailingSlashesinstead ofgetApiUrl. If the user enters/v1-suffixed URL, it would test/v1/healthwhich is correct. But for consistency, let me also updatetestRemoteConnectionto strip/v1:Actually,
testRemoteConnectiontests${stripTrailingSlashes(url)}/health. If user entershttp://127.0.0.1:8642/v1, it tests/v1/healthwhich IS correct (the server has/v1/health). So this is fine.Now let me run the tests again:
Assistant
All tests pass, TypeScript compiles. Let me now review the final diff:
Assistant
The diff looks correct. Let me now also think about whether there are edge cases I might have missed:
-
isApiServerReadyin remote mode: It now usesgetApiUrl()+/healthwhich correctly handles the/v1stripping. This is fine - it polls the remote server health. -
sendMessageViaApichat URL: Uses${getApiUrl()}/v1/chat/completionswhich now correctly forms URLs likehttp://127.0.0.1:8642/v1/chat/completions(nothttp://127.0.0.1:8642/v1/v1/chat/completions). -
testRemoteConnectionuses its ownstripTrailingSlashes(url) + /health. If user entershttp://127.0.0.1:8642/v1, it tests/v1/healthwhich is correct.
Let me run the full test suite one final time to confirm:
-
Assistant
All 435 tests pass. Let me verify TypeScript one final time:
Assistant
Let me check if there are any other places that construct URLs to the API server without using
getApiUrl():Assistant
Let me check installer.ts line 301 which uses
conn.remoteUrl:Assistant
Let me also check
resolveRemoteApiKey- it compares URLs. I should make sure it handles/v1suffix consistently:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.