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 to understand the codebase structure and locate relevant files. Let's first get an overview.
- Assistant
Let me check the project structure more thoroughly and locate the remote connection logic.
- Assistant
Let me understand the project structure better. This is a Hermes Desktop app (likely Electron-based) that needs to connect to a remote Hermes API server. Let me look at the source code structure.
- Assistant
Let me look at the key files that deal with remote connections and API interactions. I'll start with the hermes.ts file and models.ts since they seem most relevant.
- Assistant
Let me continue reading this file and also look at other key files.
- Assistant
Let me continue reading to see the HTTP API request functions and see how they handle URLs.
- Assistant
The issue is clear. The health check in
isApiServerReady()checks${getApiUrl()}/health, but when in remote mode withremoteUrl = "http://127.0.0.1:8642", this would becomehttp://127.0.0.1:8642/healthwhich should work according to the issue (GET /health -> 200 OK).But wait, looking more carefully at the issue:
- "Could not reach Hermes at this URL" - This suggests the validation endpoint is wrong
- "Error: API server returned 404: 404: Not Found" - This suggests some endpoint is being called at the wrong path
- "remote list failed: HTTP 404" - This suggests a list endpoint is returning 404
Let me look more carefully at the code. I need to find:
- Where the remote validation/check happens
- Where the URL for model listing and chat completions is constructed
- Where the cron/remote list endpoint is called
Let me continue reading the file.
- Assistant
Let me look at more of the file to understand the remote validation and model listing logic.
- Assistant
Let me search for specific patterns related to the issue - model listing, health checks, connection validation.
- Assistant
Let me look at the validation function around line 976.
- Assistant
Now let me check the cronjobs file where the "remote list failed" error occurs.
- Assistant
I can see the issue now! The cronjobs.ts file is trying to fetch
/api/jobsfrom the remote API server, but the Hermes API server doesn't have an/api/jobsendpoint. The Hermes Agent API server uses OpenAI-compatible routes like/v1/models,/v1/chat/completions, etc., not/api/jobs.Let me also check what other endpoints are being called. Let me look at the
sendMessageViaApifunction to see where it sends the chat completions request - I saw it at line 432 using/v1/chat/completionswhich should be correct.The main issues are:
- Cronjobs.ts is calling
/api/jobswhich doesn't exist on the Hermes Agent API server - There might be other endpoints being called incorrectly
Let me also check if there are other files that make API calls to understand the full picture.
- Cronjobs.ts is calling
- Assistant
Now let me look at the other relevant files - models.ts, sessions.ts, and also the setup/welcome screens where the remote connection UI is.
- Assistant
Now let me look at the
sessions.tsto see if there are any API calls there that might fail. - Assistant
Let me check the main index.ts file which likely registers IPC handlers.
- Assistant
Let me look at the test-remote-connection handler and the send-message handler in more detail.
- Assistant
Let me look at the
send-messagehandler more carefully. - Assistant
Let me look at how
sendMessageis imported and used. Let me also check for the cronjobs.ts in detail to understand the/api/jobsendpoint issue. - Assistant
Let me see the imports:
- Assistant
Let me look at the
sendMessagefunction in hermes.ts to see how it decides to use the API or the gateway. - Assistant
Let me look at the main sendMessage function to understand the logic flow:
- Assistant
Now I understand the architecture. The issue is:
- The
isApiServerReady()function checks${getApiUrl()}/health- which for remote mode withhttp://127.0.0.1:8642would becomehttp://127.0.0.1:8642/health✓ (works) - The
sendMessageViaApi()function uses${getApiUrl()}/v1/chat/completions- which would becomehttp://127.0.0.1:8642/v1/chat/completions✓ (works) - The
testRemoteConnection()function checks${stripTrailingSlashes(url)}/health- which would becomehttp://127.0.0.1:8642/health✓ (works)
But wait, the issue says the user is entering:
- URL:
http://127.0.0.1:8642 - or URL:
http://127.0.0.1:8642/v1
The
getApiUrl()function strips trailing slashes. So if the user entershttp://127.0.0.1:8642/v1, then: - The
- Assistant
Now let me understand the full picture. Let me look at the remote mode issues more carefully:
- Assistant
Let me look at the installer.ts file to see if there are any issues with spawning in remote mode.
- Assistant
Let me look at the gateway spawning logic and how remote mode is handled.
- Assistant
Now let me look at the renderer side to see how remote connection validation works in the UI.
- Assistant
Let me look at the Setup and Settings screens where remote connection is configured.
- Assistant
Let me look at the Welcome.tsx screen, which is likely where the remote connection setup happens.
- Assistant
Now let me look at the Schedules screen to see how it handles cronjobs in remote mode.
- Assistant
Let me now look at how models are listed in remote mode. Let me check the list-models handler:
- Assistant
Let me look at the listModels function in hermes.ts:
- Assistant
Let me look for the listModels function in models.ts instead.
- Assistant
Let me look at what listModels returns and how it's used.
- Assistant
Let me look at the cronjobs.ts file more thoroughly to understand the remote API endpoint structure:
- Assistant
Let me check if there are any other files that make remote API calls and look at the Gateway screen:
- Assistant
Let me look at the Gateway.tsx to see if there are any other endpoints being called:
- Assistant
Let me look at the Gateway screen to see if there are any other endpoints being called:
- Assistant
Now let me understand the full issue. Let me look at the
getApiUrl()function more carefully and see how URLs are being constructed for the remote API: - Assistant
Now I have a clear understanding of the issues. Let me also look at the tests directory to understand the test structure:
- Assistant
Let me look at the hermes-api test file to see what tests already exist:
- Assistant
Let me continue reading the test file.
- Assistant
Let me look at the other test files related to remote connection:
- Assistant
Now I have a clear understanding of the issues. Let me also check the remote-history test to see if there are any other relevant tests:
- Assistant
Now I have a clear understanding of all the issues. Let me create a plan to fix them:
Issues to fix:
Issue 1: URL Path Handling for
/v1suffixWhen user enters
http://127.0.0.1:8642/v1as remote URL:getApiUrl()returnshttp://127.0.0.1:8642/v1- Chat endpoint becomes
http://127.0.0.1:8642/v1/v1/chat/completions→ 404 - The
/v1suffix should be stripped from the URL since all API endpoints already include/v1
Issue 2: Cron Jobs API Endpoints
The cronjobs.ts uses
/api/jobsendpoints which don't exist on the Hermes Agent API server. The Hermes Agent API server uses OpenAI-compatible routes like/v1/models,/v1/chat/completions, etc.The fix should:
- Strip
/v1from the remote URL ingetApiUrl()to avoid double/v1paths - For cronjobs, the remote API endpoints should use
/v1/jobsor the code should handle the 404 gracefully - The health check should work correctly for both URL formats
Let me now implement the fixes.
First, let me fix the
getApiUrl()function to strip/v1from the remote URL. - Assistant
Now let me run the existing tests to establish a baseline:
- Assistant
All 435 tests pass. Now let me plan my fix:
- Fix
getApiUrl()- Normalize the remote URL to strip trailing/v1to avoid double/v1in API paths - Fix
testRemoteConnection()- Also normalize the URL before testing - Fix cron jobs remote endpoints - The
/api/jobsendpoints don't exist on the Hermes Agent API server, need to use/v1/jobsor handle gracefully
Let me start implementing:
- Fix
- Assistant
Now let me implement the fix. The key change is to normalize the remote URL by stripping
/v1from the end. This way, when the code appends/v1/chat/completions, it will correctly producehttp://127.0.0.1:8642/v1/chat/completions. - Assistant
Let me use the proper edit command syntax:
- Assistant
Good, the
getApiUrlfunction is updated. Now I need to update thetestRemoteConnectionfunction to also normalize the URL, and update theresolveRemoteApiKeyfunction to usenormalizeRemoteUrlfor comparison instead ofstripTrailingSlashes: - Assistant
Now I need to update the
testRemoteConnectionfunction to also normalize the URL. Let me find and update it: - Assistant
Let me look at the testRemoteConnection function:
- Assistant
I need to update the
testRemoteConnectionfunction to usenormalizeRemoteUrlinstead ofstripTrailingSlashesto properly handle URLs with/v1suffix. This way, when a user entershttp://127.0.0.1:8642/v1, it will correctly testhttp://127.0.0.1:8642/healthinstead ofhttp://127.0.0.1:8642/v1/health. - Assistant
It seems the replacement messed up the end of the file. The
restartGatewayfunction got cut off. Let me check the file to see what happened. - Assistant
I see - the
restartGatewayfunction declaration was removed. Let me fix this. - Assistant
Now let me check if there are other files that need to be updated. Let me also look at the cronjobs.ts more carefully to understand the
/api/jobsendpoint issue: - Assistant
Let me look at all the cron job operations in remote mode:
- Assistant
Let me look at the rest of the cronjobs.ts to see the other remote operations:
- Assistant
Now let me also check the
isApiServerReadyfunction to see how it constructs the URL: - Assistant
Good. The
isApiServerReadyfunction uses${getApiUrl()}/healthwhich with my fix will correctly normalize the URL. Now let me also look at thesendMessageViaApifunction to see how it constructs the URL: - Assistant
Let me find the chat URL construction:
- Assistant
The
sendMessageViaApifunction uses${getApiUrl()}/v1/chat/completionswhich with my fix will correctly normalize the URL. Now let me also check if there are any other places where the URL is constructed without usinggetApiUrl(). Let me also look at theprobeRealErrorfunction: - Assistant
Good, all the API endpoints use
getApiUrl()which now correctly normalizes the URL. Now let me also look at thelist-modelshandler to see if it usesgetApiUrl()or some other method: - Assistant
Now let me run the tests to make sure my changes don't break anything:
- Assistant
All 435 tests pass. Now let me also look at the other issues mentioned in the bug report. Let me check if there are any other places where the gateway might be spawned in remote mode:
- Assistant
Let me check each of these to see if any of them might spawn the gateway in remote mode:
- Assistant
Good. The
send-messagehandler correctly checks!isRemoteMode()before starting the gateway. Now let me also check if there's a validation issue in the Settings screen where the user can change the remote URL: - Assistant
Let me also check the Settings screen to see how the remote URL is validated and saved:
- Assistant
Good. Now let me also check the
setConnectionConfighandler in index.ts to see how the remote URL is stored: - Assistant
Now let me check the config.ts to see how the connection config is stored and retrieved:
- Assistant
Let me also check the
resolveConnectionApiKeyUpdatefunction to see how it handles the remote URL: - Assistant
Good. Now let me also look at the
listCronJobsfunction to see if we should change the endpoint to/v1/jobsinstead of/api/jobs: - Assistant
Now let me run the tests again to make sure everything passes:
- Assistant
All 435 tests pass. Now let me also look at the Welcome.tsx to see if there are any issues with how the remote URL is validated in the UI. The issue says:
"Could not reach Hermes at this URL. Check the URL and API key."
This error message is shown when
testRemoteConnectionreturns false. With my fix, the URL normalization should make the health check work correctly.Let me also check if there are any other issues with the Welcome.tsx or Settings.tsx that might cause problems:
- Assistant
Let me now check if there are any other issues with remote mode handling. Let me look at the Layout.tsx and App.tsx:
- Assistant
Let me look at the App.tsx to see if there are any other issues with remote mode handling:
- Assistant
Now let me look at where the stale spawn issue occurs. The issue reports that Hermes Desktop tried to spawn
/home/patrick/.hermes/hermes-agent/venv/bin/pythoneven in remote mode. Let me check ifcheckInstallStatusor similar functions are called unconditionally: - Assistant
Let me look at how checkInstallStatus is called and whether it's called unconditionally:
- Assistant
Let me check the installer.ts to see if it's spawning the gateway in remote mode:
- Assistant
Let me now check if there's any code that spawns the gateway process in remote mode. Let me also look at the
startGatewayfunction more carefully to see if it checks for remote mode: - Assistant
Let me look at the
sendMessagefunction to check how it handles remote mode: - Assistant
Let me also look at the
ensureInitializedfunction to see if there's anything that might cause gateway spawning in remote mode: - Assistant
Now let me look at the issue description again to understand all the problems:
- "Could not reach Hermes at this URL" - when user enters
http://127.0.0.1:8642orhttp://127.0.0.1:8642/v1 - "Error: API server returned 404: 404: Not Found" - when sending messages
- "Error: API request failed: connect ECONNREFUSED 127.0.0.1:8642" - when trying to connect
- "[CRON] remote list failed: HTTP 404" - when listing cron jobs
- "spawn /home/patrick/.hermes/hermes-agent/venv/bin/python ENOENT" - when trying to spawn local gateway
My fixes address:
- URL normalization -
getApiUrl()now strips/v1suffix from remote URLs - Health check URL -
testRemoteConnection()now usesnormalizeRemoteUrl()for the URL - API key comparison -
resolveRemoteApiKey()now usesnormalizeRemoteUrl()for comparing URLs
The cron jobs issue (using
/api/jobswhich doesn't exist on the Hermes Agent API server) is a known limitation - the code already handles this gracefully by returning an empty array when the endpoint returns 404. - "Could not reach Hermes at this URL" - when user enters
- Assistant
Let me check those specific lines where restartGateway is called to see if there's a remote mode guard:
- Assistant
Let me check the context around line 498:
- Assistant
Let me also look at the
restartGatewayfunction to see if it guards against remote mode: - Assistant
Let me also check the context around line 761:
- Assistant
Let me check the startGateway function at line 726:
- Assistant
Let me check the Layout.tsx to see if the Gateway screen is hidden in remote mode:
- Assistant
Let me look at the
RemoteNoticecomponent to see if there are any other issues: - Assistant
Now let me verify the changes I've made by looking at the git diff:
- Assistant
Good. The diff shows the changes I've made. Let me run the tests one more time to make sure everything passes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.