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 the codebase and then identify the relevant files for the issue.
- Assistant
Let me explore more of the structure to understand the codebase better.
- Assistant
Let me explore the key files to understand the remote mode functionality and the issue.
- Assistant
Let me look at the package.json to understand the project better and then examine the hermes.ts file which seems relevant.
- Assistant
Now let me look at the hermes.ts file which seems to be the core of the Hermes agent functionality.
- Assistant
Good, I'm starting to understand the structure. Let me continue reading the hermes.ts file to understand how API requests are made and where the URL handling issues might be.
- Assistant
Let me look at the full hermes.ts file to understand the API request flow better.
- Assistant
Let me continue reading the hermes.ts file to see the health check implementation.
- Assistant
Let me search for where the models endpoint is used.
- Assistant
Let me search for where models are fetched from the API.
- Assistant
Let me search in all TypeScript files for "/models" to see where models are fetched.
- Assistant
Let me search more broadly for the endpoint patterns used.
- Assistant
Let me look at the remote validation and the
send-messagehandler mentioned in the issue. - Assistant
Let me search more broadly.
- Assistant
Let me look at the index.ts file to see how the send-message handler works.
- Assistant
Let me look at the send-message handler and the test-remote-connection handler more closely.
- Assistant
Let me continue reading to see the send-message handler implementation. before_error:
- Assistant
I apologize for the multiple calls. I'll try again with a single call.
- Assistant
Let me look at the testRemoteConnection function and the remote connection validation flow.
- Assistant
Let me look at the testRemoteConnection function.
- 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 the issue! The cron jobs are trying to fetch from
/api/jobsendpoint, which returns 404 because the Hermes Agent API server doesn't have that endpoint. Let me also check the installer.ts file to understand the spawn issue. - Assistant
Let me look at how the
sendMessagefunction works in remote mode. - Assistant
Let me look at the main sendMessage function.
- Assistant
Let me look at the
sendMessageViaApifunction. - Assistant
Let me look at the
config.tsto understand the connection configuration. - Assistant
Let me look at the config.ts file to see how the connection configuration is stored.
- Assistant
Let me look at the full hermes.ts file to understand the issue better.
- Assistant
Let me continue reading from line 400 to see the rest of the sendMessageViaApi function.
- Assistant
Let me look at the frontend code to see how the remote connection is tested and validated.
- Assistant
Let me look at the renderer code to understand how the remote connection is tested.
- Assistant
Let me look at the Welcome screen to understand how the remote connection is configured.
- Assistant
Let me look at the Welcome screen.
- Assistant
Let me look at the index.ts to see how the send-message handler works and what happens when in remote mode.
- Assistant
Let me look at the test-remote-connection handler to see how it works.
- Assistant
Now I understand the issue. Let me look at how cron jobs are being loaded and called.
- Assistant
Let me search for all API paths used in remote mode.
- Assistant
Let me also check if there are other files that might be affected.
- Assistant
Let me also check the kanban.ts and memory.ts files for remote mode API calls.
- Assistant
Let me also look at
sessions.tsand other files for remote mode API calls. - Assistant
Let me check the
isGatewayRunningfunction and look atstartGatewaymore carefully. - Assistant
Let me now look at the
isGatewayRunningfunction and see if it's being called in remote mode. - Assistant
Let me check the sessions.ts and memory.ts to see if they also have remote mode issues.
- Assistant
Let me now look at the memory.ts to see if there's any issue in remote mode.
- Assistant
Now I have a clear picture of the issues. Let me look at the existing tests to understand the test structure.
- Assistant
Let me look at all the test files.
- Assistant
Let me look at the hermes-api.test.ts to understand how the API is tested.
- Assistant
Let me look at where cron jobs are automatically loaded in the UI.
- Assistant
Now I understand the full picture. Let me look at the connection-config-security test to understand more.
- Assistant
Now I have a clear understanding of the issues. Let me trace through the code to confirm the problems:
Issue 1: Double
/v1in URL paths - When user provideshttp://127.0.0.1:8642/v1:getApiUrl()returnshttp://127.0.0.1:8642/v1sendMessageViaApi()builds${getApiUrl()}/v1/chat/completions=http://127.0.0.1:8642/v1/v1/chat/completions→ 404
Issue 2: Cron jobs use
/api/jobswhich doesn't exist on the Hermes Agent API server (it only exposes/v1/...and/health).Let me look at the
getApiUrlfunction more carefully and implement the fix. - Assistant
Now I understand the fix needed. The
getApiUrl()function should strip the/v1suffix from the remote URL since all the API paths already include/v1/when needed. Let me implement the fix. - Assistant
I need to strip
/v1from the end of the URL as well. The regex should strip trailing slashes and optionally a trailing/v1. - Assistant
Now let me understand the full scope of the fix needed. Let me also look at how
testRemoteConnectionnormalizes the URL. - Assistant
Now I have the complete picture. Let me implement the fix. The core issue is:
- When user provides
http://127.0.0.1:8642/v1,getApiUrl()returnshttp://127.0.0.1:8642/v1, and then the code appends/v1/chat/completions→http://127.0.0.1:8642/v1/v1/chat/completions→ 404 testRemoteConnection()testsurl/healthwhich works, masking the double-/v1issue- Cron jobs use
/api/jobswhich doesn't exist on the Hermes API server
Let me fix
getApiUrl()to normalize URLs properly: - When user provides
- Assistant
Now let me implement the fix. I'll modify
getApiUrl()to strip trailing/v1from the remote URL, and also fixtestRemoteConnection()for consistency: - Assistant
Now let me implement the fix. I need to:
- Fix
getApiUrl()to strip/v1suffix from remote URLs - Fix
testRemoteConnection()similarly for consistency
- Fix
- Assistant
Let me look at the full context around
stripTrailingSlashesand all its usages. - Assistant
Now I have a clear understanding of all the issues. Let me implement the fix. I'll create a
normalizeRemoteUrlhelper function and update the relevant code: - Assistant
Now let me implement the fix. I'll modify
stripTrailingSlashesto also strip trailing/v1: - Assistant
Let me first look at the full hermes.ts to understand the context around the
getApiUrlandtestRemoteConnectionfunctions: - Assistant
Now let me implement the fix. I'll update the
stripTrailingSlashesfunction to also strip trailing/v1: - Assistant
Now I have the full picture. Let me implement the fix. The core change is to normalize remote URLs by stripping
/v1suffix. I'll updatestripTrailingSlashesto also handle this, and updategetApiUrl()to use it: - Assistant
Now let me make the edits. First, I'll update
stripTrailingSlashesto also strip trailing/v1: - Assistant
Let me undo that and use the edit tool instead:
- Assistant
Now let me open the file and make the edits properly:
- Assistant
Now let me update the
stripTrailingSlashesfunction to also strip trailing/v1: - Assistant
Now let me update
getApiUrl()to usestripTrailingSlashes: - Assistant
Good. Now let me verify the
testRemoteConnectionfunction which also usesstripTrailingSlashes: - Assistant
Good, the
testRemoteConnectionfunction already usesstripTrailingSlashes, so it will automatically benefit from the fix. Now let me also check if the cronjobs module needs the same fix. Let me look at how it constructs URLs: - Assistant
Good, the
remoteFetchfunction usesgetApiUrl()which we've already fixed. Now let me run the existing tests to make sure my changes don't break anything: - Assistant
All 435 tests pass. Now let me verify the changes I made are correct:
- Assistant
The changes look correct. Now let me verify that the fix works correctly for the reported scenarios. Let me create a simple test script to verify:
- Assistant
All test cases pass. Now let me also verify the downstream URL construction:
- Assistant
All URLs are constructed correctly. Now let me also check if there are other files that might need similar URL normalization:
- Assistant
All uses of
getApiUrl()are correct now. Let me run the tests one more time to confirm everything passes: - Assistant
All 435 tests pass. Let me now verify the complete diff of my changes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.