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 how Hermes Desktop works and find the relevant code for remote mode connectivity.
Assistant
Let me look at the source code structure, excluding node_modules.
Assistant
Now let me look at the key files related to remote connectivity. Let me start with the main hermes management file and the constants file.
Assistant
Let me now look at how models are fetched and where the 404 errors could be coming from:
Assistant
Now let me look at the cronjobs file to understand the "remote list failed" 404 error:
Assistant
Now I can see the issue! The
listCronJobsfunction in remote mode calls/api/jobswhich returns 404 because the Hermes Agent API server only exposes OpenAI-compatible routes (/v1/*), not the custom/api/*routes.Let me also check where models are fetched from and look at the installer and config to understand the stale local installation issue.
Assistant
Now let me look at the main index.ts to understand the IPC handlers:
Assistant
Let me see more of the IPC handlers, specifically the remote connection test and listModels:
Assistant
Now let me check the Models screen to understand how models are fetched:
Assistant
Now let me look at the Welcome screen to see how remote connection is validated:
<tool_call> <function=bash_terminal> <parameter=command> cat /hermes-desktop/src/renderer/src/screens/Welcome/Welcome.tsx </tool_call>
Assistant
The user is asking me to run a command. Let me continue investigating the code to understand the remote connection validation and how it fails. I need to look at the Welcome screen and the remote connection logic.
Assistant
Now let me look at the
sendMessageViaApifunction which is the key function that sends chat messages:Assistant
Let me see the sendMessageViaApi function:
Assistant
Now I understand the issue. Let me trace through the code to identify the root cause.
Assistant
Assistant
Let me continue my investigation. I need to find where chatUrl is constructed in the hermes.ts file.
Assistant
Good, now I have a clear picture of the issue. Let me look at the relevant parts of the hermes.ts file to confirm the chat URL construction:
Assistant
Now I have a complete understanding of the issue. Let me summarize the problems and fix them:
Problems identified:
- URL normalization: When user enters URL with
/v1suffix (e.g.,http://127.0.0.1:8642/v1), it's stored as-is. ThensendMessageViaApiconstructs${getApiUrl()}/v1/chat/completionsresulting inhttp://127.0.0.1:8642/v1/v1/chat/completions→ 404. - Gateway spawn in remote mode:
startGateway()doesn't check for remote mode and could try to spawn the local Hermes gateway even when in remote mode. - URL comparison in
resolveRemoteApiKey: URLs without normalization may not match when the user enters a URL with different trailing paths.
Let me implement the fix:
- URL normalization: When user enters URL with
Assistant
Now I have a complete understanding of the issue. Let me summarize:
Problem Summary
-
URL normalization: When user enters
http://127.0.0.1:8642/v1as the remote URL:testRemoteConnectioncheckshttp://127.0.0.1:8642/v1/health→ 200 OK ✓getApiUrl()returnshttp://127.0.0.1:8642/v1sendMessageViaApiconstructshttp://127.0.0.1:8642/v1/v1/chat/completions→ 404!
-
Gateway spawn in remote mode:
startGateway()doesn't check for remote mode, could try to spawn the local Hermes gateway even when in remote mode.
Let me now implement the fix:
-
Assistant
Now I have a complete understanding of the issue. Let me implement the fix.
The root cause is that when a user enters
http://127.0.0.1:8642/v1as the remote URL:testRemoteConnectioncheckshttp://127.0.0.1:8642/v1/health→ 200 OK ✓- But then
getApiUrl()returnshttp://127.0.0.1:8642/v1 - And
sendMessageViaApiconstructshttp://127.0.0.1:8642/v1/v1/chat/completions→ 404!
The fix should normalize URLs by stripping
/v1suffix. I also need to fixstartGateway()to skip spawning in remote mode.Assistant
Let me look at the
resolveRemoteApiKeyfunction andtestRemoteConnection:Assistant
Now I have a complete understanding of the issue. Let me summarize my findings and then implement the fix.
Root cause analysis:
-
URL normalization problem (404 on chat completions): When user enters
http://127.0.0.1:8642/v1:testRemoteConnectioncheckshttp://127.0.0.1:8642/v1/health→ 200 OK ✓getApiUrl()returnshttp://127.0.0.1:8642/v1sendMessageViaApiconstructs${getApiUrl()}/v1/chat/completions=http://127.0.0.1:8642/v1/v1/chat/completions→ 404!
-
resolveRemoteApiKeycomparison issue: Uses onlystripTrailingSlasheswhich doesn't normalize/v1suffix, so URL comparison may fail to match the API key. -
Gateway spawn in remote mode:
startGateway()doesn't check for remote mode and could try to spawn the local Hermes gateway even when in remote mode.
Fix plan:
-
Assistant
Now I have a complete understanding of the issue. Let me summarize the root causes and implement the fix.
Root Cause Analysis
-
URL normalization problem (main issue causing 404): When user enters
http://127.0.0.1:8642/v1:testRemoteConnectioncheckshttp://127.0.0.1:8642/v1/health→ 200 OK ✓getApiUrl()returnshttp://127.0.0.1:8642/v1(only strips trailing slashes)sendMessageViaApiconstructs${getApiUrl()}/v1/chat/completions=http://127.0.0.1:8642/v1/v1/chat/completions→ 404!
-
resolveRemoteApiKeycomparison issue: Uses onlystripTrailingSlasheswhich doesn't normalize/v1suffix, so API key may not be matched. -
startGateway()in remote mode: Doesn't check for remote mode, could try to spawn local Hermes gateway even in remote mode.
Let me implement the fix:
-
Assistant
I need to be more careful with the tool call format. Let me use the correct syntax.
Assistant
The tool call format seems to be causing issues. Let me try a different approach - maybe the issue is with the special characters or formatting in the replacement text.
Assistant
Let me try using a heredoc approach with the edit command to avoid issues with special characters.
Assistant
Let me try using sed or a different approach to make the edits.
Assistant
Let me try using sed or another approach. Let me check what's available.
Assistant
Good, I have perl and node available. Let me use perl to make the edits.
Assistant
The perl command seems to have executed but I'm not sure if it worked correctly. Let me check the file to see if the changes were applied properly.
Assistant
The
normaliseUrlfunction was added successfully. But I need to also updategetApiUrlto use it. Let me fix that line.Assistant
Let me verify the change was applied correctly:
Assistant
The perl command didn't work. Let me try a different approach - use sed which is simpler for this replacement.
Assistant
I need to fix line 51 to use
normaliseUrl(conn.remoteUrl)instead ofconn.remoteUrl.replace(/\/+$/, ""). Let me use sed for this specific line replacement.Assistant
Let me check if the sed command worked correctly:
Assistant
The first fix is done. Now I need to continue with the remaining fixes:
- Update
testRemoteConnectionto normalize the URL - Update
resolveRemoteApiKeyto normalize URLs before comparison - Add a check in
startGatewayto skip spawning in remote mode
Let me find and fix these remaining issues:
- Update
Assistant
Let me look at the resolveRemoteApiKey function and the startGateway function to understand how they need to be fixed.
resolveRemoteApiKey(line 90) - needs to use normaliseUrl instead of stripTrailingSlashesstartGateway(line 873) - needs to check for remote mode and return false earlytestRemoteConnection(line 983) - needs to use normaliseUrl for the URL
Let me look at each of these functions more carefully.
Assistant
Let me continue with the fixes. I'll use sed to make targeted replacements:
Assistant
Now let me continue fixing the remaining issues. I'll fix each one systematically:
Fix 2: Update
resolveRemoteApiKeyto usenormaliseUrlinstead ofstripTrailingSlashesAssistant
Good, now let me fix the
testRemoteConnectionfunction:Assistant
Good. Now I need to fix
testRemoteConnectionto usenormaliseUrland also fixstartGatewayto skip spawning in remote mode. Let me also fixisApiServerReadyto usenormaliseUrlfor the health check URL.Assistant
I see the issue - my previous
sedcommand only fixed one occurrence. Let me verify what's changed and then make the remaining fixes.Assistant
Let me continue with the remaining fixes. I need to fix
testRemoteConnectionto usenormaliseUrland also add a remote mode check tostartGateway:Assistant
Let me verify the testRemoteConnection fix was applied and then fix startGateway:
Assistant
Good,
testRemoteConnectionis now usingnormaliseUrl. Now let me fix thestartGatewayfunction to skip spawning in remote mode.Assistant
The
startGatewayfunction doesn't check for remote mode before trying to spawn the gateway process. I need to add a check at the beginning ofstartGatewayto return false early when in remote mode.Let me find the exact line to add the check after.
Assistant
I need to add a check for remote mode at the beginning of the startGateway function. The fix should be added after line 875 (after
if (isGatewayRunning()) return false;) to skip spawning the gateway when in remote mode.Assistant
Let me check if the fix was applied correctly:
Assistant
The fix was applied correctly. Let me verify all changes and check if there are any other issues to fix.
Assistant
Let me verify all the changes and check if there are any other places that need fixing:
Assistant
Let me review the complete set of changes I've made and verify they're correct. Let me check the full file to make sure everything is in order:
Assistant
The changes look correct. Let me now run the existing tests to verify I haven't broken anything:
Assistant
All 435 tests pass. Now let me check if the
stripTrailingSlashesfunction is used anywhere else in the codebase:Assistant
All 435 tests pass. Let me verify there are no other places in the codebase that might be affected by similar URL issues:
Assistant
All the URL construction in
hermes.tsnow goes throughgetApiUrl()which properly normalizes the URL. Let me also check the cronjobs issue mentioned in the bug report - the/api/jobsendpoint returns 404 in remote mode because the Hermes Agent API server doesn't expose those routes.Assistant
Let me also check the cronjobs issue more carefully. The
/api/jobsendpoints return 404 in remote mode, but the code already handles this gracefully. Let me verify:Assistant
Good. The cronjobs issue is expected - the Hermes Agent API server only exposes OpenAI-compatible routes (
/v1/*), not custom/api/*routes. The code already handles the 404 gracefully by logging an error and returning an empty array. This isn't a bug - it's a design limitation where cron functionality only works in local/SSH mode.Let me verify that my changes compile correctly and there are no TypeScript errors:
Assistant
TypeScript compiles with no errors. Now let me write a quick verification script to test the URL normalization logic works correctly for the various URL formats:
Assistant
The test shows one edge case failed:
http://127.0.0.1:8642/v1/(with trailing slash after /v1) doesn't get normalized correctly. The issue is that my regex/\/v1$/only matches/v1at the end, but when there's a trailing slash like/v1/, it doesn't match.I need to fix the order: first strip trailing slashes, then strip the
/v1suffix. Let me update the function:Assistant
Let me verify the fix was applied correctly:
Assistant
I see the sed command created a duplicate comment. Let me fix this:
Assistant
Let me fix the duplicate comment issue:
Assistant
Let me check the current state of the file:
Assistant
The file is now corrupted. Let me restore it and apply the changes properly:
Assistant
Let me re-apply the fixes using a more reliable method - a Node.js script:
Assistant
Let me verify the changes are correct:
Assistant
All four fixes are correctly applied. Let me verify:
- The tests still pass
- TypeScript compiles
- The normaliseUrl function handles all edge cases correctly
Assistant
All 435 tests pass. Let me now verify TypeScript compilation and test the normaliseUrl function with all edge cases:
Assistant
TypeScript compiles successfully. Now let me update and re-run the normaliseUrl test to verify all edge cases:
Assistant
All 12 test cases pass, including the critical edge cases:
- Basic URLs without paths
- URLs with trailing slashes
- URLs with
/v1suffix - URLs with
/v1/(trailing slash after v1) - URLs with whitespace
- HTTPS URLs
- Edge cases like double
/v1and other path prefixes
Now let me verify the final state of my changes:
Assistant
Let me do a final comprehensive review of the changes:
Assistant
I've completed the fix for the Hermes Desktop remote mode connectivity issue. Let me provide a summary of the changes I made:
Summary of Changes
Root Cause: When users entered
http://127.0.0.1:8642/v1as the remote URL, it was stored as-is. When the app later constructed API URLs by appending/v1/chat/completions, it resulted inhttp://127.0.0.1:8642/v1/v1/chat/completions→ 404 Not Found.Fix Applied in
/hermes-desktop/src/main/hermes.ts:-
Added
normaliseUrl()function (lines 31-42): Normalizes URLs by:- Stripping trailing slashes first
- Then stripping the
/v1OpenAI base-path suffix if present
-
Updated (line 51): Now uses instead of just , so → , and chat URLs are correctly constructed as .
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.