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 first map the Electron app’s remote/local connection paths and endpoint construction, then reproduce the URL mismatch with the existing tests or a small temporary harness. After implementing the fix, I’ll run the focused and broader test suites and inspect the final diff.
- Assistant
The relevant code is concentrated in the main-process API client, cron integration, connection settings, and startup lifecycle. I’ll inspect those modules plus their tests to determine whether remote mode is incorrectly targeting gateway-only routes and whether startup can race or overwrite the selected mode.
- Assistant
The chat client already references
/v1/chat/completions, but I need to verify howgetApiUrl()normalizes a user-entered/v1suffix and what connectivity validation probes. I’ll also inspect cron behavior because an OpenAI-compatible server does not necessarily expose Hermes gateway management routes; such optional failures should not break chat. - Assistant
A concrete mismatch is visible:
getApiUrl()only strips trailing slashes, so enteringhttp://host:8642/v1produces/v1/v1/chat/completions; meanwhile readiness appends/health, yielding/v1/health(valid here, but inconsistent for root input only accidentally). I’ll isolate all request construction and validation, then inspect initial app routing to ensure remote selection is persisted before any installer/gateway action. - Assistant
Startup itself does not auto-spawn local mode; the likely stale spawn occurs through a gateway IPC exposed to the main UI. More importantly, remote validation’s exact behavior remains central. I’ll inspect that implementation, mode-aware gateway handlers, and model listing—remote mode should get
/v1/modelsrather than reading local~/.hermes/models.json. - Assistant
Validation currently probes only
/health; that should succeed for the reported root URL, but the/v1form succeeds by coincidence while chat then doubles the prefix. The model UI likely remains local-only, explaining failure to listhermes-agent. I’ll read the compact config and models code directly and search for unguarded calls tostartGateway()from renderer lifecycle. - Assistant
The cron 404 is non-fatal and correctly returns an empty list, so it is noise rather than the send failure. The stale spawn can still be prevented defensively: gateway IPC handlers currently treat plain remote as local, so any renderer gateway-status/start action can inspect or spawn the stale install. I’ll change those handlers and the underlying
startGateway()guard, normalize remote URLs centrally, and make validation probe the OpenAI-compatible/v1/modelsendpoint with auth (with health fallback only for compatibility). First I’ll check current test conventions and whether model catalog semantics should change in this scope. - Assistant
The existing security test’s mock server accepts every path, so it did not catch doubled
/v1. I’ll implement a reusable normalizer that accepts either documented form and always stores/uses the API origin without/v1; compare normalized URLs when retaining secrets; validate/v1/modelsso the test confirms both route compatibility and authentication. I’ll also return a remote model entry from/v1/modelsinlist-models, since the issue explicitly expectshermes-agentto be listed, while keeping model mutations local-disabled rather than silently editing stale files. - Assistant
One additional root cause is likely the request’s
modelfield: remote chat currently reads the desktop’s local model config, which may name an Ollama/provider model rather than the remote API’s exposedhermes-agent. I’ll inspect payload construction and make remote mode select the server-advertised model (falling back to the OpenAI-compatible conventionalhermes-agent) without changing local or SSH behavior. - Assistant
I’ll now make the targeted source changes: canonicalize root/
/v1URLs (including old persisted values), useGET /v1/modelsfor authenticated validation and model discovery, force pure HTTP remote chat to the exposedhermes-agentmodel, and make local gateway management a no-op in explicit remote mode. This keeps SSH’s richer management behavior intact. - Assistant
The environment lacks
python3, so none of the intended edits applied; only Prettier reformatted unrelated existing lines. I’ll revert those formatting-only changes and reapply the same transformations with Node.js, then format only the edited ranges indirectly by keeping the repository’s existing style. - Assistant
The diff now directly addresses each reported symptom without touching tests. I’ll run type checking and the focused API/config/IPC/remote-history tests first. These will also reveal whether Node’s
fetchtyping and the type predicate for OpenAI model entries are compatible with the project’s TypeScript configuration. - Assistant
Type checking passed; the focused failure is a test-mocking compatibility issue because
hermes.tsimported a newly added symbol from a fully mocked config module. Rather than modifying tests, I’ll move URL normalization into a dependency-free utility module imported by both config and Hermes. This improves separation and preserves all existing mocks. - Assistant
Focused tests now pass. Reviewing edge paths found one more defensive gap:
restartGateway()can inspect and forcibly stop a PID from stale local state before eventually hitting the newstartGateway()guard. I’ll guard restart itself in remote mode, then use a temporary (non-repository) script to demonstrate both accepted URL forms canonicalize to the same/v1/modelsand/v1/chat/completionsroutes. - Assistant
The guard edit applied, but
npxattempted an interactive package install forvite-nodeand timed out; no repository files were affected by that attempt. I’ll avoid installing anything: compile the tiny utility to/tmpwith the existing TypeScript compiler, execute it with Node, and clean all temporary output. - Assistant
The reproduction confirms root,
/v1, and/v1/inputs all produce exactly one version prefix for validation and chat. I’ll now run the complete test suite and lint, then inspect any failures to distinguish genuine regressions from pre-existing tooling issues. - Assistant
All 435 tests pass. Repository-wide lint fails on 56 pre-existing errors across unrelated files (including
.agents, build scripts, tests, and existing React components); none are introduced by this patch. I’ll run ESLint only on changed files, review the final diff for accidental changes, and rerun typecheck after the final gateway guard. - Assistant
Changed-file ESLint has zero errors (only formatting warnings already present in the surrounding source); typecheck passes. I’ll clean the one new formatting warning in model parsing, verify the new utility is included and no temporary files remain, then perform the final checklist review before submission.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.