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 related to remote mode connectivity.
Assistant
Let me look at the remote mode related files. The issue mentions remote mode and connecting to a Hermes API server. Let me look at the models.ts, hermes.ts, and other files that handle remote connections.
Assistant
I need to make only one tool call at a time. Let me search for the relevant files.
Assistant
The key file is
hermes.ts. Let me look at it in detail.Assistant
The output was truncated. Let me look at the
sendMessageViaApifunction and the parts related to models listing.Assistant
Now I understand the key structure. Let me look at the models listing and how remote mode fetches models, plus the cronjobs endpoint issue.
Assistant
Let me look at the index.ts handlers and the cronjobs.ts to understand the full picture.
Assistant
Let me look at the index.ts to understand the remote connection flow and gateway management.
Assistant
Let me look at the connection mode handling and test-remote-connection flow.
Assistant
Let me look at the renderer side to understand how the connection test and validation are done in the UI.
Assistant
Let me look at the Welcome screen which has the "Connect to Remote Hermes" option.
Assistant
Let me look at where the gateway might be auto-started, and the App.tsx for startup logic.
Assistant
I see — the
start-gatewayhandler doesn't checkisRemoteOnlyMode(). If the user clicks "start gateway" in remote mode, it would callstartGateway()which spawns the local Hermes Python. Let me check the App.tsx and Layout.tsx to see if there's any auto-start gateway logic that runs in remote mode.Let me look at the App.tsx for any auto gateway start.
Assistant
Let me look at the Layout.tsx for gateway auto-start logic that might run in remote mode.
Assistant
Let me look at the main process startup and shutdown code.
Assistant
Let me look at the existing tests to understand the test setup.
Assistant
Let me look at the existing hermes-api test and remote-history test to understand how they test the remote functions.
Assistant
Let me run the existing tests first to ensure they pass before making changes.
Assistant
Now let me create a reproduction test that demonstrates the double
/v1bug.Assistant
I've reproduced the core bug — the doubled
/v1path. Now let me examine the rest of the relevant code. Let me check the Gateway screen and wherestart-gatewayis called from the renderer.Assistant
Let me look at the
set-envand related handlers that callrestartGateway.Assistant
Let me look at the config.ts to understand
getModelConfigandgetConnectionConfig.Assistant
Let me look at
getModelConfigin config.ts.Assistant
Let me look at how the model is selected and passed in the chat flow.
Assistant
Let me view the key functions in hermes.ts with line numbers.
Assistant
Let me view the
testRemoteConnection,startGateway, andrestartGatewayfunctions.Assistant
Now I have a full understanding. Let me make the fixes. First, let me update
getApiUrl()and add anormalizeBaseUrlhelper that strips trailing slashes and a trailing/v1segment.Assistant
Now let me update the
getApiUrl()function and the helper functions:Assistant
I need to provide both SEARCH and REPLACE. Let me redo this.
Assistant
Now let me replace the
stripTrailingSlashesandresolveRemoteApiKeyfunctions with thenormalizeBaseUrlhelper and updated key resolution:Assistant
Now let me update
testRemoteConnectionto use the OpenAI/v1/modelsendpoint (the endpoint the chat actually relies on) after normalizing the URL.Assistant
Let me navigate to the line and use the edit command with a line range.
Assistant
Now let me add guards to
startGatewayandrestartGatewayto prevent spawning a local gateway in remote-only mode. Let me viewstartGateway.Assistant
Now let me add the remote-only guard to
startGateway:Assistant
Now let me add the guard to
restartGateway:Assistant
Now let me address the model sent to the remote server. In remote-only mode, the local model config (e.g.
gemma4:e4b) shouldn't be sent to the remote Hermes Agent server, which expectshermes-agent. Let me view thesendMessageViaApibody construction.Assistant
Let me check whether
mcis used elsewhere insendMessageViaApibeyond the model field.Assistant
In
sendMessageViaApi,mcis only used for the model field. Let me add achatModelvariable that useshermes-agentin remote-only mode (since the Hermes Agent API server only exposes that model id), and update both usages.Assistant
Now let me replace the two
mc.model || "hermes-agent"usages withchatModel:Assistant
Now let me handle the cron jobs 404 noise. In remote-only (pure HTTP) mode, the OpenAI-compatible API server doesn't expose
/api/jobs. Let me update the cronjobs to gracefully handle this. First, let me view the imports and the list function.Assistant
Let me update the cronjobs to gracefully handle the 404 from the OpenAI-only server. First, update the import:
Assistant
Now let me update
listCronJobsto gracefully handle the 404 (the OpenAI-only server doesn't expose/api/jobs):Assistant
Now let me update the cron mutation functions to return a clear "not supported" message on 404 in remote-only mode. Let me view them.
Assistant
Let me add a helper for the friendly "not supported" message and update the mutation functions. First, add the helper after
remoteJsonError:Assistant
Now let me update the three cron mutation functions to use the helper. Let me view them with current line numbers:
Assistant
Let me update the cron mutation functions. First the create and remove (6-space indent):
Assistant
Now the
remoteJobAction(4-space indent):Assistant
Now let me verify the changes compile correctly by running the typecheck:
Assistant
The typecheck passes. Now let me update my reproduction test to properly verify the fix, including the
testRemoteConnectionURL. Let me fix the test mock to handle the response callback:Assistant
The mock needs a more complete response object for the chat path. Let me update the test mock:
Assistant
All 5 tests pass. Now let me verify the gateway spawn guard — that
startGatewaydoes NOT spawn a local process in remote-only mode. Let me add a test for that:Assistant
The
child_processmock needs proper handling. Let me remove the appended tests and create a separate, clean test file for the gateway guard.Assistant
Hmm, the head -193 cut off the last test. Let me check the line count and the end of the file.
Assistant
The file got truncated. Let me recreate it cleanly, and look at how existing tests mock
child_process:Assistant
Let me recreate the repro test file cleanly:
Assistant
Now let me create a separate test for the gateway spawn guard using
importOriginalto properly mockchild_process:Assistant
Both gateway guard tests pass. Now let me run the existing
hermes-api.test.tsand the broader test suite to ensure I didn't break anything:Assistant
Let me check what
remote-history.test.tstests to ensure my changes are consistent with it:Assistant
The
remote-history.test.tsinspects source via regex and my changes don't affect those patterns. Let me run the full test suite to confirm nothing breaks:Assistant
All 442 tests pass. Now let me check the UI hints to clarify the URL format question raised in the issue. Let me look at the i18n hint strings:
Assistant
I found the relevant hint. The
settings.remoteUrlHintmentions/healthwhich I've replaced with/v1/modelsfor validation. Let me update the English hints to clarify the URL format (answering the issue's question) and the validation endpoint. Let me update the settings hint:Assistant
Now let me update the welcome hint to clarify the URL format:
Assistant
Let me run the typecheck to ensure all changes are valid:
Assistant
Typecheck passes. Let me verify there are no other places that build
/v1/URLs that might need the same normalization, and check thegetApiUrlusages:Assistant
All
getApiUrl()usages go through the normalized URL. Let me review the complete diff of my changes:Assistant
The diff looks clean. Let me verify there are no remaining references to the removed
stripTrailingSlashesfunction, and run the linter:Assistant
There are a couple of prettier warnings from my changes. Let me fix the formatting. First the
chatModelline in hermes.ts:Assistant
The file currently open is welcome.ts, not hermes.ts. Let me open hermes.ts first, then use the edit command with line range.
Assistant
Now let me fix the cronjobs import formatting:
Assistant
Now let me run the linter again to confirm the warnings I introduced are resolved (the line 24:9 Attachment warning is pre-existing):
Assistant
Let me check whether these remaining warnings are pre-existing (not from my changes) by comparing with the original:
Assistant
The hermes.ts:24 and welcome.ts:22 warnings are pre-existing. Only my
connectRemoteSubtitle(welcome.ts:16) is new. Let me fix that formatting:Assistant
Only the 2 pre-existing warnings remain — my changes add no new lint issues. Let me re-run the repro and existing tests after the formatting changes, then clean up:
Assistant
All tests pass. Now let me remove the temporary repro test files (per the instructions, I must not add new tests to the repository):
Assistant
Repro files removed. Now let me run the full test suite one final time to confirm everything passes cleanly:
Assistant
All 435 tests pass. Let me run the typecheck one final time and confirm the final diff:
Assistant
Everything is clean. Let me do a final review of the complete diff:
Assistant
The diff is complete and clean. Let me provide a final summary and verify the complete test suite + typecheck pass one final time before submitting:
Assistant
Typecheck passes and all 435 tests pass. Let me submit the solution.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.