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 identify where the issue might be. Let's first get an overview.
- Assistant
Let me explore the repository structure more thoroughly.
- Assistant
Let me look at the repository structure and find the relevant files for remote mode connection.
- Assistant
Let me explore the source structure more thoroughly.
- Assistant
Let me examine the key files that likely handle remote mode connectivity. I'll start with the main hermes module and config.
- Assistant
Let me look at the
sendMessageViaApifunction and the models reading logic. - Assistant
Let me look at the
sendMessageViaApifunction and the cronjobs to understand the 404 issues. - Assistant
Let me continue reading the sendMessageViaApi function to see where the 404 error comes from.
- Assistant
Now let me look at the cronjobs file which is mentioned in the issue (the 404 for "remote list failed").
- Assistant
Now let me look at the models.ts file to see how models are fetched in remote mode.
- Assistant
Let me look at the config.ts file to understand connection configuration.
- Assistant
Now let me look at the main/index.ts to understand the IPC handlers related to remote mode.
- Assistant
Let me look at the relevant parts of index.ts for remote connection handling.
- Assistant
Now let me look at the renderer side to understand the welcome/setup screen for remote connection.
- Assistant
Let me check the installer.ts file to understand HERMES_HOME and HERMES_REPO paths.
- Assistant
Now let me search for all the remote API calls to understand which endpoints are being called in remote mode.
- Assistant
Let me also look at the renderer files related to remote mode and the setup/welcome screens.
- Assistant
Let me look at the App.tsx to see how the application initializes and handles the remote mode.
- Assistant
Now let me look at how the chat message is being sent and the exact URL being used. Let me check if there's an issue with the URL when the user enters
http://127.0.0.1:8642/v1. - Assistant
Let me look at the send-message handler.
- Assistant
Now I have a comprehensive understanding of the issues. Let me also look at the tests directory to understand what tests exist.
- Assistant
Let me look at the existing test files to understand patterns and see if there's already a relevant test.
- Assistant
Let me look at the remote-history test and connection-config-security test.
- Assistant
Now let me look at the connection-config-security test.
- Assistant
Now I have a comprehensive understanding of the issues. Let me analyze the problems:
-
URL normalization issue: When the user provides
http://127.0.0.1:8642/v1as the remote URL,getApiUrl()returnshttp://127.0.0.1:8642/v1, thensendMessageViaApiconstructshttp://127.0.0.1:8642/v1/v1/chat/completions(double/v1), causing 404. -
Cron jobs endpoint issue: The cron jobs code calls
/api/jobsbut the Hermes Agent API server only exposes/v1/*routes (OpenAI-compatible). The/api/jobsendpoint returns 404. -
Health check URL: The
testRemoteConnectionfunction appends/healthto the URL. If the user provideshttp://127.0.0.1:8642/v1, it checkshttp://127.0.0.1:8642/v1/healthwhich works, but then the chat URL becomeshttp://127.0.0.1:8642/v1/v1/chat/completionswhich returns 404. -
Spawn stale local install: The issue mentions
spawn /home/patrick/.hermes/hermes-agent/venv/bin/python ENOENT- this happens when the code tries to start a gateway even in remote mode.
Let me now check the installer code for the gateway spawn:
-
- Assistant
Now let me look at the relevant IPC handlers that try to start the gateway in remote mode.
- Assistant
Now I understand the issues clearly. Let me trace through all the problems:
-
URL normalization: When user provides
http://127.0.0.1:8642/v1,getApiUrl()returnshttp://127.0.0.1:8642/v1, then chat URL becomeshttp://127.0.0.1:8642/v1/v1/chat/completions→ 404. -
Cron jobs: The
/api/jobsendpoint doesn't exist on the Hermes Agent API server (only/v1/*OpenAI-compatible routes exist). -
start-gateway handler: When in remote mode, it still tries to start a local gateway.
Let me fix these issues. First, let me understand the
getApiUrlfunction: -
- Assistant
Now I have a complete understanding of the issues. Let me fix them one by one:
Issue 1: URL normalization - When user provides
http://127.0.0.1:8642/v1, thegetApiUrl()returns it as-is, thensendMessageViaApiconstructshttp://127.0.0.1:8642/v1/v1/chat/completions(double/v1).Issue 2: Cron jobs endpoint - The
/api/jobsendpoint doesn't exist on the Hermes Agent API server (only/v1/*OpenAI-compatible routes exist).Issue 3: start-gateway handler - When in remote mode, it still tries to start a local gateway.
Let me start fixing:
- Assistant
Now I have a clear understanding of all the issues. Let me create a plan and fix them:
Root causes:
- URL normalization:
getApiUrl()doesn't strip/v1suffix, so when user provideshttp://127.0.0.1:8642/v1, the chat URL becomeshttp://127.0.0.1:8642/v1/v1/chat/completions(double/v1→ 404) - Cron jobs endpoint: Uses
/api/jobswhich doesn't exist on Hermes Agent API server (only/v1/*routes exist) - start-gateway handler: In remote mode, still tries to spawn local gateway
Let me fix the
getApiUrl()function first to normalize URLs: - URL normalization:
- Assistant
Now let me apply the fix to
getApiUrl()in hermes.ts: - Assistant
Now let me fix the
getApiUrl()function to handle URLs with/v1suffix properly. The issue is that when a user entershttp://127.0.0.1:8642/v1, the code should strip the/v1suffix since it already appends/v1/chat/completionsto the URL. - Assistant
Good, the
getApiUrl()is fixed. Now I need to also fixresolveRemoteApiKeyto handle URL comparison with/v1suffix, and fixtestRemoteConnectionto try both/healthand/v1/health: - Assistant
Now let me update
resolveRemoteApiKeyto also strip/v1for URL comparison, and also fixstripTrailingSlashes: - Assistant
I notice there's a stray
}on line 96. Let me fix that: - Assistant
There's an extra
}on line 96. Let me remove it: - Assistant
Good, the stray
}is removed. Now let me also fix thetestRemoteConnectionfunction to also try/v1/healthif/healthdoesn't work. This will help when the remote server only exposes/v1/healthand not/health. - Assistant
Let me see the testRemoteConnection function:
- Assistant
Now I need to fix
testRemoteConnectionto also try/v1/healthas a fallback. The issue is that when a user entershttp://127.0.0.1:8642/v1, the health check trieshttp://127.0.0.1:8642/v1/healthwhich works, but with our URL normalization, it will tryhttp://127.0.0.1:8642/healthfirst, then we need a fallback: - Assistant
Something went wrong with the edit. Let me check the file around the end of the testRemoteConnection function:
- Assistant
It looks like the
restartGatewayfunction got mangled. Let me fix it: - Assistant
Good, the file looks correct now. Now let me fix the
isApiServerReadyfunction to also try/v1/healthas a fallback, since the current implementation only checks/health: - Assistant
Now let me fix the
start-gatewayhandler in index.ts to not spawn local gateway in remote mode: - Assistant
Now let me fix the
start-gatewayhandler to not spawn a local gateway when in remote mode: - Assistant
I see there's an extra
});on line 729. Let me fix that: - Assistant
There's a duplicate
});on line 729. Let me remove it: - Assistant
Good. Now let me also fix the
stop-gatewayandgateway-statushandlers to properly handle remote mode: - Assistant
Now let me fix the cron jobs issue. The
/api/jobsendpoint doesn't exist on the Hermes Agent API server. The Hermes Agent API server only exposes/v1/*routes. Let me update the cron jobs code to use/v1/jobsinstead: - Assistant
Let me look at all the
/api/paths in cronjobs.ts: - Assistant
Let me change all
/api/jobsto/v1/jobsin the cronjobs.ts file to match the OpenAI-compatible API pattern: - Assistant
Let me verify the changes:
- Assistant
Good. Now let me run the existing tests to make sure my changes don't break anything:
- Assistant
All 435 tests pass. Let me verify the key changes I made:
- Assistant
Good, the diff looks correct. Let me run the tests again to make sure everything is working:
- Assistant
All 435 tests pass. Let me now create a test script to verify the fix works correctly for the specific issue described:
- Assistant
The URL normalization is working correctly. Let me also check if there are any other files that might need similar fixes:
- Assistant
Let me check the installer.ts to see if there's a similar issue with the remote URL:
- Assistant
Good, installer.ts already handles remote mode correctly. Let me also check the sessions.ts for any remote mode issues:
- Assistant
Let me also check if there are any other places where the API URL is constructed directly without going through
getApiUrl(): - Assistant
Let me also check if there are any other places that might need similar fixes:
- Assistant
Good, all the places that use
getApiUrl()are correctly handling the URL. Let me also check if there are any other files that might need similar fixes: - Assistant
Let me now verify the final state of the key changes by looking at the modified files:
- Assistant
Let me run the tests one more time to make sure everything is working correctly:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.