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 then identify the issues mentioned in the bug report.
Assistant
Let me continue exploring the key files related to remote mode and API connections.
Assistant
Now let me look at the cronjobs and models files that are mentioned in the logs:
Assistant
Now let me look at the
index.tsto see how the IPC handlers are set up and how remote mode is handled:Assistant
Now let me look at the specific handlers for remote connection and model listing:
Assistant
Now let me look at the installer.ts to understand how the local Hermes installation paths are determined:
Assistant
Now let me look at the
getApiUrl()function and how remote connections are handled. The key issue is that when in remote mode, Hermes Desktop needs to:- Use the correct URL format for health checks
- Fetch models from the right endpoint
- Avoid trying to spawn a local Hermes installation
Let me look at the relevant parts more carefully:
Assistant
Let me look at the key areas: the
getApiUrlfunction, the health check, the model listing, and the gateway start functions:Assistant
Now I can see the issue. The
getApiUrl()function strips trailing slashes from the remote URL. So if the user entershttp://127.0.0.1:8642, it returns that, and health check hits/healthendpoint which works. But if the user entershttp://127.0.0.1:8642/v1, it strips the trailing slash tohttp://127.0.0.1:8642/v1, and then health check hits/v1/health.Now let me look at where the model listing happens in remote mode:
Assistant
I see the issue! The
list-modelshandler only checks for SSH mode, but not for remote mode. In remote mode, it still calls the locallistModels()function, which reads from a localmodels.jsonfile instead of fetching models from the remote API server.Let me also check the
send-messagehandler:Assistant
I see! Line 612-613 shows:
if (!isRemoteMode() && !isGatewayRunning()) { startGateway(profile); }- this is the gateway auto-start logic that tries to spawn a local installation even when the user may be in remote mode. Wait, actually it checks!isRemoteMode()first, so it should be fine.Let me look more carefully at the
ensureInitializedfunction and the health polling:Assistant
Now let me check the tests to understand the expected behavior:
Assistant
Let me check the sessions.ts and how they handle remote mode:
Assistant
Let me now check what routes the remote API uses:
Assistant
Now I need to understand the full picture. Let me look at what endpoints the remote Hermes API server exposes (from the issue description) and what Hermes Desktop tries to call:
Working API server routes:
GET /health→ 200 OKGET /v1/health→ 200 OKGET /v1/models→ 200 OKPOST /v1/chat/completions→ 200 OK
404 routes:
GET /models→ 404 Not FoundGET /api/health→ 404 Not Found
What Hermes Desktop tries:
- Health check:
${getApiUrl()}/health- This should work ✓ - Chat:
${getApiUrl()}/v1/chat/completions- This should work ✓ - Cron jobs:
${getApiUrl()}/api/jobs- This returns 404 (the log says[CRON] remote list failed: HTTP 404) - Model listing: Uses local
listModels()function even in remote mode - This is the bug!
The main issues are:
Assistant
No function exists to fetch remote models! Let me also check if the sessions module handles remote mode:
Assistant
Assistant
The command failed with exit code 1, which likely means no matches were found or the file doesn't exist. Let me check the ssh-remote.ts file more carefully.
Assistant
Now I understand the issue better. Let me summarize my findings:
Issues identified:
-
Model listing in remote mode: The
list-modelsIPC handler inindex.tsonly checks for SSH mode but not for plain remote HTTP mode. In remote mode, it should fetch models from the remote API server's/v1/modelsendpoint instead of reading from a localmodels.jsonfile. -
Cron jobs in remote mode: The cronjobs module tries to use
/api/jobsendpoints that don't exist on the Hermes Agent's OpenAI-compatible API server. These should either be disabled in remote mode or return a meaningful error. -
Health check with
/v1prefix: When the user entershttp://127.0.0.1:8642/v1as the URL, thegetApiUrl()strips trailing slashes, resulting inhttp://127.0.0.1:8642/v1. Then the health check hits/v1/healthwhich works, but the chat endpoint would be/v1/chat/completions→/v1/v1/chat/completionswhich fails!
Let me verify the third issue more carefully:
-
Assistant
Now let me check the chat URL construction and the sendMessageViaApi function:
Assistant
Now I can clearly see the problem. The
getApiUrl()function is used as a base URL, and endpoints like/v1/chat/completionsand/healthare appended to it. If the user entershttp://127.0.0.1:8642/v1as the URL,getApiUrl()returnshttp://127.0.0.1:8642/v1(after stripping trailing slashes), and then:- Health check:
http://127.0.0.1:8642/v1/health→ This works because the API server has/v1/health - Chat:
http://127.0.0.1:8642/v1/v1/chat/completions→ This fails! Double/v1
The fix should normalize the URL in
getApiUrl()to remove any/v1suffix since the code always appends/v1/...endpoints.Let me also look at the testRemoteConnection function to see what it does:
- Health check:
Assistant
Now let me run the existing tests to make sure I understand the baseline:
Assistant
All 435 tests pass. Now I have a clear understanding of the issues. Let me implement the fixes:
Issues identified:
getApiUrl()URL normalization: When user entershttp://127.0.0.1:8642/v1, appending/v1/chat/completionsresults in/v1/v1/chat/completions- Model listing in remote mode: The
list-modelsIPC handler doesn't handle remote HTTP mode - it reads local file instead of calling/v1/models - Cron jobs in remote mode: Uses
/api/jobsendpoints that don't exist on the OpenAI-compatible API server
Let me fix these issues:
Assistant
Now let me fix the
getApiUrl()function to normalize URLs by removing any/v1suffix:Assistant
I see the edit went wrong. Let me restore the file and try again:
Assistant
Let me use sed to do the replacement:
Assistant
Let me check if the sed command worked correctly:
Assistant
Good, the
getApiUrl()fix is in place. Now I need to also fix thetestRemoteConnectionfunction to use the same URL normalization, so that when the user tests a connection with/v1in the URL, it still works correctly:Assistant
The
testRemoteConnectionfunction also needs to normalize the URL. If the user entershttp://127.0.0.1:8642/v1, it would try/v1/healthwhich works, but to be consistent and avoid confusion, we should normalize it the same way:Assistant
Now let me verify the fix:
Assistant
Now I need to fix the second issue: Model listing in remote mode. The
list-modelsIPC handler should fetch models from the remote API when in remote mode.Let me create a function to fetch remote models and update the IPC handler:
Assistant
I need to add a function to fetch remote models from the API. Let me check what the API response looks like (from the issue description) and create the appropriate function.
The API returns:
{ "object": "list", "data": [ { "id": "hermes-agent", "object": "model", "owned_by": "hermes", "root": "hermes-agent" } ] }I need to add a function
listRemoteModels()tohermes.tsand update thelist-modelsIPC handler inindex.ts:Assistant
I need to import the
SavedModeltype and add a function to fetch remote models. Let me add this function tohermes.ts:Assistant
Now let me add the import for
SavedModeland the function to fetch remote models. I'll add it right before thetestRemoteConnectionfunction:Assistant
Let me find a good place to add the listRemoteModels function. I'll add it before testRemoteConnection.
Assistant
I need to add the SavedModel type import and create a listRemoteModels function. Let me use sed to add the import and then add the function.
Assistant
Now let me add the
listRemoteModelsfunction. I'll add it right afterisApiReady():Assistant
I'll insert the new function after line 975 (after
isApiReady).Assistant
Let me verify the function was added correctly:
Assistant
Now I need to update the
index.tsto export and uselistRemoteModelsin thelist-modelsIPC handler:Assistant
I need to add
listRemoteModelsto the imports from "./hermes" in index.ts. Let me find the exact import block.Assistant
I need to add
listRemoteModelsto the hermes import. Let me do that:Assistant
Now I need to update the
list-modelsIPC handler to uselistRemoteModelsin remote mode:Assistant
Let me use sed to update this handler.
Assistant
Now let me verify the change:
Assistant
Now I need to fix the third issue: Cron jobs in remote mode. The cronjobs module uses
/api/jobsendpoints that don't exist on the OpenAI-compatible API server. Let me check the current behavior and fix it to gracefully handle this:Assistant
There are a few approaches I could take:
- Simply return an empty array for cron jobs in remote-only mode (since the OpenAI-compatible API doesn't support cron jobs)
- Try the endpoint and silently fail with an empty array
Looking at the code, it already handles the error case by logging and returning an empty array. But the log message is noisy and confusing. Let me check if the issue is specifically about
isRemoteOnlyMode()vsisRemoteMode().Actually, looking more carefully at the code:
isRemoteMode()returns true for both "remote" and "ssh" modesisRemoteOnlyMode()returns true only for "remote" mode
For SSH mode, the remoteFetch would actually go through the SSH tunnel to the local Hermes API, which might have the /api/jobs endpoint. For remote HTTP mode, it goes directly to the remote server which may or may not have the /api/jobs endpoint.
Assistant
I'll add
isRemoteOnlyModeto the import and update the cron jobs logic to skip API calls for remote-only mode (since those endpoints don't exist on the OpenAI-compatible API server):Assistant
Now update
listCronJobsto skip remote API calls for remote-only mode (SSH mode has full local access):Assistant
Now I need to fix the other cron job functions that also try to call the
/api/jobsendpoint in remote mode. Let me find them:Assistant
Let me update all the remaining
isRemoteMode()checks in cronjobs.ts to use the same pattern:Assistant
Let me continue verifying the changes made to cronjobs.ts and then run the tests.
Assistant
The one-line
ifstatements still need to be fixed. Let me fix them too.Assistant
The previous sed command was executed but I need to verify it actually worked, since the
!isRemoteOnlyMode()pattern might have been affected by the shell's history expansion. Let me check the current state of the file.Assistant
All cron job checks are now updated. Let me run the tests to verify everything still works.
Assistant
All 435 tests pass. Let me now review all the changes I made and verify they're complete.
Assistant
Let me verify all my changes by looking at the full diff:
Assistant
Let me review all my changes and make sure they address the issues:
-
getApiUrl()URL normalization - Fixed: Now strips/v1suffix so bothhttp://host:8642andhttp://host:8642/v1work correctly. -
testRemoteConnection()URL normalization - Fixed: Same normalization asgetApiUrl()for consistency. -
Model listing in remote mode - Fixed: Added
listRemoteModels()function that fetches from/v1/modelsendpoint, and updated the IPC handler to use it when in remote mode. -
Cron jobs in remote-only mode - Fixed: Changed all
isRemoteMode()checks toisRemoteMode() && !isRemoteOnlyMode()so that pure remote HTTP mode doesn't try to call/api/jobsendpoints that don't exist on the OpenAI-compatible API server. SSH tunnel mode still works because it has full local access.
Let me also verify there are no TypeScript errors by running a type check:
-
Assistant
TypeScript compilation passes. Now let me run the tests once more to confirm everything still works:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.