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 start by exploring the repository structure to understand the codebase and find the relevant files for the remote mode connection logic.
Assistant
Let me explore the main source files, particularly around remote mode and API connection.
Assistant
The
opencommand doesn't take afileparameter. Let me check its usage again - it seems I need to just pass the file path as a positional argument.Assistant
Let me try with the correct format for the open command:
Assistant
Now let me look at the config file and models file to understand the connection logic:
Assistant
Now let me look at the cronjobs.ts file, since the issue mentions
[CRON] remote list failed: HTTP 404:Assistant
Now I can see a key issue. The cronjobs module is calling
/api/jobsendpoints which return 404 on the Hermes API server. Let me also check the models.ts and index.ts files to understand the full picture:Assistant
Now let me look at the index.ts file to understand the IPC handlers and how remote connections are managed:
Assistant
Let me see the middle portion of the index.ts file, specifically the IPC handlers for remote connection and send-message:
Assistant
Now let me look at the sessions.ts to understand how sessions are listed in remote mode:
Assistant
Now let me look at the installer.ts to understand the HERMES_HOME path and how the local installation is handled:
Assistant
Now let me look at the key issue areas. The problem description mentions:
404: Not Founderrors when Hermes Desktop tries to connect to remote API- The
/modelsendpoint returning 404 (Hermes Desktop expects it but it doesn't exist) - Stale local install state being used even in remote mode
Let me look at the
hermes.tsfile more carefully, especially how API requests are made:Assistant
Now let me look at the tests directory and understand the expected behavior:
Assistant
Let me look at the hermes-api.test.ts to understand the expected API behavior:
Assistant
Let me also look at the remote-history.test.ts and check the ipc-handlers.test.ts:
Assistant
Let me look at the
remote-history.test.tsand also check how the/api/jobsand other API routes are used in the codebase:Assistant
Now let me search more broadly for all API endpoints that are being called in remote mode:
Assistant
Now let me look at the kanban.ts which may also have similar API calls:
Assistant
Good. Now let me understand the full scope of the problem. Let me also check where sessions and other data are accessed in remote mode:
Assistant
Let me look at how the send-message handler starts the gateway and how it relates to the issue about spawning stale local install:
Assistant
Now let me look at the issue more closely. The key issues are:
- 404 errors on
/api/jobs- The cronjobs module tries to access/api/jobswhich doesn't exist in the Hermes API server - Stale local gateway spawn attempt - In remote mode, it should NOT try to spawn local gateway
- The
/healthendpoint being used for health checks
Let me look at the
isApiServerReadyfunction andstartGatewaymore closely:- 404 errors on
Assistant
I see that
isApiServerReady()hits${getApiUrl()}/health. According to the issue, the Hermes API server has/healthreturning 200 OK, so this should work fine.Now let me trace the actual issues:
-
The
/api/jobsendpoints returning 404 - this is the cronjobs module trying to call endpoints that don't exist on the remote API server. -
The "spawn ENOENT" error - the code tries to spawn the local hermes-agent even in remote mode.
Let me check the
ensureInitializedfunction andstartHealthPolling:-
Assistant
...
Assistant
Now let me see the
ensureInitializedfunction andstartGatewayfunction:Assistant
Now I understand the codebase. Let me summarize the issues:
-
Cronjobs
/api/jobsreturning 404: Thecronjobs.tsmodule tries to use/api/jobsendpoints in remote mode, but the Hermes API server doesn't expose these endpoints. It only exposes/health,/v1/health,/v1/models, and/v1/chat/completions. -
The spawn ENOENT error: This happens when the
startHealthPolling()function runsisApiServerReady()even in remote mode. WhilestartHealthPollingis always started, the issue is thatstartGatewayis called without checking remote mode in certain scenarios.
Let me check the index.ts for any place that starts the gateway in remote mode:
-
Assistant
Let me see those lines where
startGatewayis called to check if remote mode is properly guarded:Assistant
Now I see there are places where
restartGatewayis called without checking if we're in remote mode. Let me also look at wherestartGatewayis called in send-message handler:Assistant
Good - the
send-messagehandler properly checks!isRemoteMode()before starting gateway. Let me check thestart-gatewayIPC handler:Assistant
I see the issue! The
start-gatewayIPC handler at line 720 does NOT check for remote mode - it checks for SSH mode, but if the mode is "remote" (not SSH), it will callstartGateway()which tries to spawn the local hermes-agent that may not exist.Now let me also check the
restartGatewayfunction:Assistant
Now let me check the
set-envandset-model-confighandlers that callrestartGateway:Assistant
Now let me run the existing tests to understand the current state:
Assistant
All tests pass. Now let me analyze the issues more carefully and create a fix plan:
Issues identified:
-
/api/jobsendpoints returning 404: Thecronjobs.tsmodule calls/api/jobs,/api/jobs/{id},/api/jobs/{id}/pause, etc. These endpoints don't exist on the Hermes API server, causing 404 errors. -
start-gatewayIPC handler doesn't check remote mode: Line 720-727 inindex.tsonly checks for SSH mode, but when in "remote" mode, it still callsstartGateway()which tries to spawn the local hermes-agent. -
restartGatewaycalls inset-envandset-model-configdon't check remote mode: Lines ~424 and ~498 callrestartGateway()without checking if we're in remote mode first. -
startHealthPolling()runs in remote mode but shouldn't affect local gateway: This is actually OK sinceisApiServerReady()usesgetApiUrl()which returns the remote URL in remote mode. -
setPlatformEnabledrestarts gateway without checking remote mode: Line ~761 calls without remote mode check.
-
Assistant
Now let me fix the issues one by one. First, let's fix the cronjobs to handle the 404 gracefully (since
/api/jobsendpoints don't exist on the API server):Assistant
Let me use the bash approach to edit files:
Assistant
The key issue is that in pure remote mode (not SSH), cron jobs and other local features can't work through the API server. The fix should be:
- In remote mode (HTTP-only), cron jobs should return empty/unavailable since there's no API endpoint for them
- The 404 errors should be suppressed (not logged as errors) since they're expected
- The gateway management functions should check for remote mode before trying to spawn the local gateway
Let me now implement the fixes:
Assistant
Let me use the proper edit syntax:
Assistant
The
editcommand seems to be having trouble with the syntax. Let me try using sed to make the changes instead.Assistant
Now I need to add the
isRemoteOnlyModeimport. Let me check the current import:Assistant
I need to add
isRemoteOnlyModeto the import:Assistant
Now let me fix the other cron job functions that also try to use
/api/jobsendpoints. Let me check the rest of the file:Assistant
I need to fix all the cron functions to return early for remote-only mode. Let me fix
createCronJob:Assistant
Let me use a Python script to make all the necessary changes to the cronjobs.ts file:
Assistant
Now let me also fix the
pauseCronJob,resumeCronJob, andtriggerCronJobfunctions:Assistant
I need to fix the pauseCronJob, resumeCronJob, and triggerCronJob functions to also check for remote-only mode before trying to use the /api/jobs endpoints.
Assistant
Now let's fix the
index.tsfile to prevent spawning local gateway in remote mode. There are several places to fix:start-gatewayIPC handler - should not start local gateway in remote moderestartGatewaycalls inset-envandset-model-config- should not restart in remote moderestartGatewaycall inset-platform-enabled- should not restart in remote mode
Assistant
Let me look at each occurrence:
Assistant
Now let me fix these issues. I need to:
- Add
!isRemoteMode()check to restartGateway calls - Fix
start-gatewayhandler to return false for remote mode - Fix
stop-gatewayhandler to return false for remote mode - Check if
gateway-statushandler needs fixing
- Add
Assistant
Now let me verify the changes:
Assistant
Let me verify the specific fixes:
Assistant
I see a logic issue with the parenthesis in the
set-envhandler. The!isRemoteMode() &&check should wrap the entire condition:Assistant
The logic is wrong. The original condition was:
(isGatewayRunning() && key.endsWith("_API_KEY")) || key.endsWith("_TOKEN") || key === "HF_TOKEN"Now with
!isRemoteMode() &&at the start without proper parentheses, the logic becomes:(!isRemoteMode() && (isGatewayRunning() && key.endsWith("_API_KEY"))) || key.endsWith("_TOKEN") || key === "HF_TOKEN"This means
_TOKENandHF_TOKENkeys would still trigger restart even in remote mode. Let me fix this:Assistant
Now let me verify the start-gateway and stop-gateway handlers:
Assistant
Good! Let me also check the set-model-config and set-platform-enabled handlers:
Assistant
All the fixes look correct. Now let me also verify the cronjobs.ts changes:
Assistant
All the cron job functions now check for remote-only mode. Now let me run the tests to make sure nothing is broken:
Assistant
All 435 tests pass. Now let me think about whether there are any other edge cases or issues I should address:
- Health check in remote mode: The
isApiServerReady()function uses/healthendpoint which the issue confirms works. However, let me verify thatstartHealthPolling()doesn't cause issues in remote mode.
Looking back at the code,
startHealthPolling()callsisApiServerReady()which usesgetApiUrl()- in remote mode this returns the remote URL, so the health check will hit the remote server, not the local one. This is correct behavior.-
The
ensureApiServerConfig()call: This is already guarded by!isRemoteMode()inensureInitialized(). -
What about when switching from local to remote mode? Let me check if there's cleanup needed.
- Health check in remote mode: The
Assistant
I notice there's no explicit cleanup when switching to remote mode. The
apiServerAvailablecache and health polling should be reset. Let me check if that's needed:Assistant
I need to continue my work on the issue. Let me check the current state of the code and ensure all changes are in place.
Assistant
I made it to the repository. Let me check what's here and understand the codebase.
Assistant
I'm in the hermes-desktop repository root. Let me understand the issue better and then explore the codebase to find and fix the problems.
The issue is about Hermes Desktop 0.4.3 failing to connect to a remote Hermes API server. The key problems are:
- 404 errors when trying to use certain endpoints
- The app tries to spawn a local hermes-agent even in remote mode
- Routes like
/modelsand/api/healthreturn 404 (the server only supports/health,/v1/health,/v1/models,/v1/chat/completions)
Let me explore the source code to understand the architecture.
Assistant
Looking at the issue, I need to understand the key problems:
- 404 errors - Hermes Desktop is hitting endpoints that don't exist on the Hermes API server (like
/models,/api/health,/api/jobs) - Stale local spawn - Even in remote mode, the app tries to spawn
~/.hermes/hermes-agent/venv/bin/pythonwhich doesn't exist - Health check issues - The app may be using wrong endpoints
Let me look at the key files:
hermes.ts- Main API communication logicconfig.ts- Connection configuration (local/remote/ssh modes)index.ts- IPC handlerscronjobs.ts- The log shows[CRON] remote list failed: HTTP 404installer.ts- Where HERMES_HOME and spawn logic lives
Let me start by examining the key files to understand the remote mode flow.
Let me examine the key files to understand how remote mode works and where the bugs are.
- 404 errors - Hermes Desktop is hitting endpoints that don't exist on the Hermes API server (like
Assistant
I see the issue. The
hermes.tsfile has already been modified based on my earlier session - it now hasisRemoteOnlyMode()function which was added. Let me check the full diff to see what changes were already made, and then continue to verify and complete the fixes.Actually wait - looking at the output, this is the ORIGINAL file content (showing
isRemoteOnlyModewhich already exists). Let me check the git status to see what changes have already been made.Assistant
Wait, I notice that this is the first session (not a continuation). Let me look at what git diff shows - it seems like changes were already made in a previous session but the session got interrupted. Let me check the current state of the files and verify all changes are correct.
Actually, looking at the git diff output, I can see that changes to
cronjobs.tsandindex.tshave already been made. Let me verify theindex.tschanges are also in place.Assistant
Good, the changes look correct. Let me run the tests to confirm everything passes, and then verify the changes address all the issues mentioned in the bug report.
Assistant
All 435 tests pass. Let me now verify the changes are comprehensive by reviewing them one more time:
Assistant
Assistant
The submit command doesn't seem to work as a tool call. Let me try using it as a bash command instead.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.