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 issues described.
- Assistant
Let me get a better view of the structure.
- Assistant
Let me look at the repository structure one step at a time.
- Assistant
Let me look at the key files -
hermes.tsis likely the main file handling remote connections. - Assistant
Let me see the rest of the file to understand
sendMessageViaApi: - Assistant
Let me look at the full file from the truncated part. The file is 1004 lines. Let me open it to see the sendMessageViaApi function.
- Assistant
Let me see the full sendMessageViaApi function.
- Assistant
Now let me see the rest of the file and check the model listing:
- Assistant
Let me look at models.ts, cronjobs.ts, and the index.ts (main process):
- Assistant
Let me check config.ts and cronjobs.ts to understand the connection configuration:
- Assistant
Now let me check the cronjobs.ts to understand the "remote list failed: HTTP 404" issue:
- Assistant
Let me now check the index.ts and other files that might have issues:
- Assistant
Let me look at index.ts to understand the gateway and remote mode interactions:
- Assistant
Let me check how
testRemoteConnectionis invoked from the renderer side and look at the installer to understand the HERMES_HOME/HERMES_REPO setup: - Assistant
Let me also look at the installer.ts to understand HERMES_HOME and HERMES_REPO.
- Assistant
Let me find where the "Could not reach Hermes" error message is defined:
- Assistant
Let me search for the error message in the renderer.
- Assistant
Let me look at the renderer source to find the remote connection UI:
- Assistant
Let me find the settings/welcome screen where remote mode is configured:
- Assistant
Let me check the Welcome and Setup screens for remote connection setup:
- Assistant
Let me check where
startGatewayis called to understand if it tries to spawn the gateway in remote mode: - Assistant
Let me check the contexts where startGateway is called:
- Assistant
Good, the
startGatewayis only called when!isRemoteMode(). So the gateway is not started in remote mode. Let me check line 726. - Assistant
Let me check the renderer code to see when it calls start-gateway:
- Assistant
Let me check the Gateway screen to see if it has remote mode protection:
- Assistant
Now let me look at the App.tsx and Settings.tsx to understand the navigation and how remote mode affects which screens are accessible:
- Assistant
Let me look at the full App.tsx to understand the flow:
- Assistant
Now let me look at the Layout to see how navigation works with remote mode:
- Assistant
Let me check what RemoteNotice shows:
- Assistant
Let me check the Settings screen for connection mode:
- Assistant
Let me look at the specific settings area where connection mode is tested and set:
- Assistant
Let me look at the full Settings.tsx around the connection save area:
- Assistant
Now let me check the sessions.ts to understand how sessions are fetched in remote mode:
- Assistant
Let me check the tests directory and look at the existing tests:
- Assistant
Let me look at the hermes-api.test.ts to understand the test structure:
- Assistant
Let me look at the remote-history test to understand test patterns:
- Assistant
Let me look at how the cron jobs are fetched in remote mode and find other
/api/calls: - Assistant
Let me look at the kanban.ts for remote mode usage:
- Assistant
Let me check memory.ts for remote mode usage:
- Assistant
Now let me look at the
send-messagehandler in index.ts: - Assistant
Let me look at the full send-message handler in index.ts:
- Assistant
Now I have a clear picture of the issues. Let me trace through the problems:
-
URL normalization: When user provides
http://127.0.0.1:8642/v1,getApiUrl()returnshttp://127.0.0.1:8642/v1, thensendMessageViaApicallshttp://127.0.0.1:8642/v1/v1/chat/completions→ 404. -
start-gatewayIPC handler: Doesn't check for remote mode, can try to spawn local gateway. -
testRemoteConnection: Doesn't normalize URLs with/v1suffix, so health check may succeed but subsequent API calls fail.
Let me check the tests directory:
-
- Assistant
Now let me run the existing tests to see the current state:
- Assistant
All 435 tests pass. Now let me implement the fixes. I'll start with the main issue - URL normalization in
hermes.ts: - Assistant
Now let me implement the fix. I'll modify the
getApiUrl()function to normalize the URL by stripping/v1suffix: - Assistant
Let me see the full context around the
testRemoteConnectionfunction: - Assistant
Let me now look at the
testRemoteConnectionfunction: - Assistant
Let me find the
testRemoteConnectionfunction: - Assistant
Let me see the full
testRemoteConnectionfunction: - Assistant
Let me also check the
startGatewayfunction to see if it checks for remote mode: - Assistant
Let me also check the
start-gatewayhandler in index.ts: - Assistant
Now I have a complete understanding. Let me implement the fixes. First, I'll add URL normalization to
getApiUrl(): - Assistant
Let me now implement the fix. First, I'll add URL normalization to
getApiUrl(): - Assistant
Now I need to modify
getApiUrl()to normalize the URL by stripping trailing/v1. Let me edit this function. - Assistant
Now let me implement the fix. I'll add URL normalization to handle the
/v1suffix issue: - Assistant
Now let me also fix the
resolveRemoteApiKeyfunction to use consistent URL normalization: - Assistant
Now let me fix the
testRemoteConnectionfunction to also normalize the URL: - Assistant
Let me see the full
testRemoteConnectionfunction: - Assistant
Now let me fix the
testRemoteConnectionfunction to normalize the URL: - Assistant
Good. Now let me fix the
start-gatewayIPC handler inindex.tsto check for remote mode: - Assistant
Now let me fix the
start-gatewayIPC handler to check for remote mode: - Assistant
Good. Now let me also check the
startGatewayfunction inhermes.tsto add a remote mode guard: - Assistant
Let me add a remote mode guard to
startGatewayas a defense-in-depth measure: - Assistant
Now let me also fix the cron jobs to suppress the 404 error for remote mode:
- Assistant
Let me fix the cron jobs code to suppress the 404 error for remote mode:
- Assistant
Let me check the full context around line 105 to make sure the edit was correct:
- Assistant
I see that my edit removed some lines that should have been kept. Let me fix this by looking at the full context and restoring the missing lines:
- Assistant
I see the issue - my edit removed the lines that process the jobs. Let me fix this properly:
- Assistant
Good. Now let me run the tests to make sure everything still passes:
- Assistant
All 435 tests pass. Now let me create a temporary test script to verify that the URL normalization works correctly:
- Assistant
The URL normalization works correctly. Now let me verify all the changes I made by looking at the git diff:
- Assistant
The changes look correct. Let me run the tests one more time to make sure everything passes:
- Assistant
All 435 tests pass. Let me clean up the temporary test file:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.