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:
yaml - Assistant
I'll start by exploring the repository structure to understand the codebase and locate relevant files for the remote mode issue. Let me first see what's in the current directory.
- Assistant
Let me explore the source directory structure to understand the codebase better.
- Assistant
Let me explore the codebase more to understand the remote mode implementation and where the API endpoints are defined.
- Assistant
Let me examine the key files that are likely responsible for remote connections: hermes.ts, config.ts, and maybe models.ts.
- Assistant
Now let me look at the config file to understand connection configuration:
- Assistant
Now let me search for where API calls are made, particularly for listing models and chat completions:
- Assistant
Let me search for cron-related code and remote list functionality:
- Assistant
Let me examine the cronjobs.ts file to understand the remote list failure:
- Assistant
Now I can see the issue! The cronjobs.ts file is trying to fetch from
/api/jobsendpoint when in remote mode, but the Hermes Agent API server doesn't expose this endpoint. Let me examine thesendMessageViaApifunction to see if it has similar issues: - Assistant
Let me look at the models.ts file to understand how models are listed:
- Assistant
Let me examine the installer.ts file to understand the spawn error:
- Assistant
Let me check the index.ts file to understand how the testRemoteConnection function is used:
- Assistant
Let me look at the sendMessageViaApi function more closely to understand the exact URL construction:
- Assistant
Let me examine the hermes.ts file more thoroughly to see the sendMessageViaApi function and how the URL is being used:
- Assistant
Let me check the test file to see if there are existing tests:
- Assistant
Let me examine the hermes-api.test.ts file to understand how remote mode is tested:
- Assistant
Now I need to search for all places where remote API calls are made to understand what endpoints are being accessed:
- Assistant
Let me search for where models are listed remotely and check if there are other endpoint issues:
- Assistant
Let me check the index.ts file to see how listModels is used and if there's a remote mode check:
- Assistant
Let me look at the cronjobs.ts file more carefully to see what endpoints it's trying to access:
- Assistant
Now I need to check if there are other files that might have similar issues. Let me search for other places where remote API calls are made:
- Assistant
Let me also check the hermes.ts file more carefully to see if there are any other issues:
- Assistant
- Assistant
Now I have a clear understanding of the issues. Let me create a plan to fix them:
-
URL normalization issue: When user provides URL with
/v1suffix (e.g.,http://127.0.0.1:8642/v1), the code strips trailing slashes but doesn't handle the/v1suffix properly, leading to double/v1/v1/chat/completionsURLs. -
cronjobs.ts is trying to access
/api/jobswhich doesn't exist: The Hermes Agent API server doesn't have/api/jobsendpoint, causing 404 errors. -
Spawn error: The code might be trying to use local CLI fallback even in remote mode.
Let me first run the existing tests to see what passes:
-
- Assistant
Good, all tests pass. Now let me fix the issues I've identified:
-
URL normalization issue: When user provides URL with
/v1suffix (e.g.,http://127.0.0.1:8642/v1), the code should strip the/v1suffix to avoid double/v1/v1/URLs. -
cronjobs.ts is trying to access
/api/jobswhich doesn't exist: The Hermes Agent API server doesn't have/api/jobsendpoint. We need to gracefully handle missing endpoints. -
Spawn error: The code might be trying to use local CLI fallback even in remote mode.
Let me start by fixing the URL normalization issue in hermes.ts:
-
- Assistant
Now I'll fix the URL normalization issue. The problem is that when a user provides
http://127.0.0.1:8642/v1, the code strips trailing slashes but doesn't handle the/v1suffix properly. Let me update thegetApiUrl()function: - Assistant
I see the edit command didn't work as expected. Let me check what happened and fix it:
- Assistant
The getApiUrl function was removed. Let me check the file and add it back:
- Assistant
I need to add the getApiUrl function back. Let me add it after the LOCAL_API_URL constant:
- Assistant
I see there's a duplicate line. Let me fix that:
- Assistant
Good! Now I've fixed the URL normalization issue. Now I need to fix the cronjobs.ts file to gracefully handle missing
/api/jobsendpoint. Let me examine the cronjobs.ts file more carefully: - Assistant
Now I need to fix the cronjobs.ts file to gracefully handle missing
/api/jobsendpoint. Let me update it to handle 404 responses gracefully: - Assistant
The edit command seems to have inserted the new code in the wrong place. Let me check the current state of the file:
- Assistant
The file is seriously corrupted. Let me revert to the original state and start over:
- Assistant
Good, I've reverted the file. Now let me try again more carefully. Let me open the file and make the changes:
- Assistant
Let me try using the replace command instead which is safer for single-line changes:
- Assistant
Good! I've successfully fixed the URL normalization issue in hermes.ts. Now I need to fix the
testRemoteConnectionfunction as well to be consistent. Let me check it: - Assistant
Let me also check the
resolveRemoteApiKeyfunction to ensure consistency: - Assistant
I need to update the
resolveRemoteApiKeyfunction to also strip the/v1suffix for consistency: - Assistant
Now I need to update the
testRemoteConnectionfunction to also strip the/v1suffix for consistency: - Assistant
Let me navigate to the correct location and try again:
- Assistant
Let me try using
sedto make the change directly: - Assistant
Let me check if the sed command worked correctly:
- Assistant
Perfect! The sed command worked correctly. Now I need to fix the cronjobs.ts file to gracefully handle missing
/api/jobsendpoint. Let me open the cronjobs.ts file: - Assistant
Now I need to update the
listCronJobsfunction to gracefully handle missing/api/jobsendpoint. Let me update it: - Assistant
Now I need to update the other functions in cronjobs.ts that try to access
/api/jobsendpoint to handle 404 errors gracefully. Let me check the other functions: - Assistant
Let me check the createCronJob function and update it to handle 404 errors gracefully:
- Assistant
Now I need to update the createCronJob function to handle 404 errors gracefully. Let me update it:
- Assistant
Let me navigate to the correct location and try again:
- Assistant
Let me use sed to make the changes more efficiently for all the functions that need to handle 404 errors:
- Assistant
Let me check if the sed command worked correctly:
- Assistant
Now let me update the removeCronJob function as well:
- Assistant
Let me update the removeCronJob function to handle 404 errors gracefully:
- Assistant
Let me check if the sed command worked correctly:
- Assistant
Now let me also update the remoteJobAction function to handle 404 errors gracefully:
- Assistant
Let me update the remoteJobAction function to handle 404 errors gracefully:
- Assistant
Let me check if the sed command worked correctly:
- Assistant
Good! Now I need to also handle the case where the user explicitly chose remote mode but the desktop app still tries to spawn a stale local Hermes installation. Let me check the gateway management code:
- Assistant
Let me check where
startGatewayis called to see if it's being called in remote mode: - Assistant
Let me check the
sendMessagefunction to see if it's trying to spawn the CLI when in remote mode: - Assistant
Let me continue looking at the sendMessage function to see if it properly handles remote mode:
- Assistant
The
sendMessagefunction properly handles remote mode. Now let me check if there are any other issues. Let me look at thestartGatewayfunction more closely to see if it's being called when it shouldn't be: - Assistant
I see the issue! The
startGatewayfunction doesn't check if we're in remote mode before spawning the gateway process. This could be causing the spawn error when the user is in remote mode but the code still tries to spawn a local Hermes installation. Let me add a guard to prevent this: - Assistant
The edit failed because the file context doesn't show the exact text. Let me navigate to that line first.
- Assistant
Now I can see the exact text. Let me use the replace command again:
- Assistant
Good! Now I've added a guard to prevent spawning the gateway in remote mode. Let me run the tests again to see if my changes break anything:
- Assistant
All tests pass. Now let me also check the
restartGatewayfunction to make sure it doesn't try to restart the gateway in remote mode: - Assistant
Let me also check the
ensureInitializedfunction to see if it's trying to configure the API server when in remote mode: - Assistant
Good! The
ensureInitializedfunction already checks if we're in remote mode before callingensureApiServerConfig. Now let me also check if there are any other issues that need to be fixed. Let me also check theisApiServerReadyfunction to see if it's working correctly with the URL normalization fix: - Assistant
Good! The
isApiServerReadyfunction usesgetApiUrl()which now properly handles the URL normalization. Now let me also check if there are any other issues that need to be fixed. Let me also check if there are any other files that might be affected by my changes: - Assistant
Good! All the places that use
getApiUrlwill now benefit from the URL normalization fix. Now let me also check if there are any other issues that need to be fixed. Let me also check thesendMessageViaApifunction to make sure it's working correctly with the URL normalization fix: - Assistant
Let me find the correct section of the sendMessageViaApi function that constructs the chat URL:
- Assistant
Good! The
sendMessageViaApifunction usesgetApiUrl()which now properly handles the URL normalization. Now let me also check if there are any other issues that need to be fixed. Let me also check if there are any other files that might be affected by my changes.Let me run the tests one more time to make sure everything is working correctly:
- Assistant
All tests pass. Now let me review the changes I've made to ensure they're complete and correct. Let me check the git diff to see all the changes:
- Assistant
Let me also check the full diff to make sure everything looks correct:
- Assistant
The changes look good. Now let me also check if there are any other issues that need to be fixed. Let me also check if there are any other files that might be affected by my changes. Let me also check if there are any other tests that might be affected by my changes.
Let me also check if there are any other issues that might be causing the spawn error. Let me check the
runCronCommandfunction to see if it's trying to spawn a local process when in remote mode: - Assistant
The
runCronCommandfunction is only called from the non-remote-mode path. Let me now also check thesendMessageViaClifunction to make sure it's not being called in remote mode: - Assistant
Good! The
sendMessageViaClifunction is only called from thesendMessagefunction when not in remote mode and the API server is not available. This is correct.Now let me also check if there are any other issues that need to be fixed. Let me also check if there are any other files that might be affected by my changes. Let me also check if there are any other tests that might be affected by my changes.
Let me also check if there are any other issues that might be causing the spawn error. Let me check the
sendMessageViaClifunction to see if it's spawning the correct process: - Assistant
Now let me run the tests one final 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.