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.
Assistant
Now let me look at the config and connection management.
Assistant
Now let me look at the Setup screen where remote mode is configured:
Assistant
Now let me look at how remote mode is set up. Let me search for it:
Assistant
Now let me find the screenshot or description about which routes are being hit:
Assistant
Let me look at how cron is referenced as it appears in the issue with
[CRON] remote list failed: HTTP 404:Assistant
Now let me look at the tests folder to see what tests exist:
Assistant
Now let me look at the renderer code that has remote mode and what routes it uses:
Assistant
Now let me see the Welcome screen to understand the flow:
Assistant
Now let me look at how the routes to remote endpoints are constructed and verify what URL format is needed:
Assistant
Now let me look at the SSH tunnel to see how it works:
Assistant
Now let's check what's available in
/opt/hermes-agent(the real hermes-api code) to understand which endpoints it implements - first, let me see if there's an external reference:Assistant
Let me examine the model listing in the app — this is what tells me what URL structure is used. Look at the existing model-fetching code:
Assistant
Now let me investigate what URL paths exist in SSH remote and cron — see if they use the standard
/healthand/v1/...style, or the/api/...style:Assistant
Let me look at the issue more carefully. The key insight from the issue is:
- The Hermes API server exposes
/health,/v1/health,/v1/models,/v1/chat/completions - But Hermes Desktop hits
/api/jobs(cron) which doesn't exist on the API server - The user can choose either
http://127.0.0.1:8642orhttp://127.0.0.1:8642/v1— the question is what URL is expected
Let's now check how getApiUrl handles
/v1vs no/v1:- The Hermes API server exposes
Assistant
So
getApiUrl()returns whatever URL the user enters. In all places usinggetApiUrl(), the code appends its own path —/health,/v1/chat/completions,/api/jobs. This is the bug: if the user entershttp://127.0.0.1:8642/v1, then any path appended becomes e.g.http://127.0.0.1:8642/v1/v1/chat/completionsorhttp://127.0.0.1:8642/v1/api/jobs.Now let me look at how
/api/jobsis loaded (the cron endpoint). If the user provides a base URL ofhttp://127.0.0.1:8642then${getApiUrl()}/api/jobsbecomeshttp://127.0.0.1:8642/api/jobswhich returns 404 according to the user's report.Let me check what URL/path patterns the Hermes server supports:
Assistant
Let's see the model router — when the user adds a "remote" model, what URL format is used:
Assistant
Now let me actually try running the tests to see what we have:
Assistant
All existing tests pass. Now I need to understand the issue more thoroughly to craft a fix. Let me look at the cron jobs endpoints to see how they call the API:
Assistant
Now let me understand the issue completely.
The issue is that the Hermes API server exposes:
GET /health-> 200 OKGET /v1/health-> 200 OKGET /v1/models-> 200 OKPOST /v1/chat/completions-> 200 OKGET /models-> 404 Not FoundGET /api/health-> 404 Not Found
But the user shows that Hermes Desktop calls:
Assistant
Wait,
Error: API server returned 404: 404: Not Foundfrom the issue — let me investigate more carefully. The format is "API server returned {errBody.slice(0, 200)}". If is the JSON and gets truncated to , it might show "Not Found". So if a 404 from is hit (e.g. might return 404 but more likely the user entered leading to ).Assistant
Now let me look at the renderer code for CronSchedule and the chat to see if there's separate places that hit routes:
Assistant
Now let me understand what needs fixing. The core issues:
-
/api/jobsdoesn't exist on a remote Hermes API server (and is documented to be a separate cron API; maybe it's served by a different path on the actual Hermes server too — but the user has confirmed it's not at/api/jobs). -
/v1/chat/completionsis the correct chat route when the URL ishttp://127.0.0.1:8642without/v1. -
The
/v1/modelsroute works but is not used; the app instead relies on local config. -
Connection test should use a route that's known to exist. Currently
/health. The user reports/healthworks, so that's OK. -
The remote mode should never spawn local Python. The user is reporting:
[MAIN UNCAUGHT] Error: spawn /home/patrick/.hermes/hermes-agent/venv/bin/python ENOENTThis suggests that even in remote mode something is trying to use the local install. Let me search for places where local Python might be invoked in remote mode:
Let me investigate more thoroughly. Let me find where the CLI fallback is invoked:
-
Assistant
The cli fallback only happens in local mode. So why is a Python spawn happening? Let me check installer.ts:
Assistant
Let me look for the spawn error more specifically — this might come from an SSH-tunnel test where the user is using ssh mode:
Assistant
Now let's look at what triggers the spawn. Perhaps the user is asking about what happens when they switch from local to remote — does the app still try to use the local Python? Let me check the "verifyInstall" call from the renderer:
Assistant
Now I see — the
verifyInstalldoes NOT check the remote mode. Let me also look at how this is called from the renderer:Assistant
OK, so the renderer doesn't even call
verifyInstallin remote mode. Good. Let me now look at howgetHermesVersionandrunHermesBackupare called from renderer:Assistant
Now let's look at useLocalCommands to see how getHermesVersion is called there:
Assistant
So
getHermesVersion()is called in remote mode. Let me check the index.ts to see when getHermesVersion is called:Assistant
So in
remotemode, the code still callsgetHermesVersion()which spawns the local Python! This is the source of the Python spawn error. Let me check whatgetHermesVersiondoes:Assistant
Found it! In remote mode,
getHermesVersion()would still try to spawn local Python. Let me also check what other paths are problematic:Assistant
Now I see —
run-hermes-backupdoes not check for remote mode either. Let me investigate which functions are called regardless of mode:Assistant
Let me now look at the Settings.tsx — how the Settings panel handles remote mode:
Assistant
Let me now look more at the settings panel for how it manages connection mode:
Assistant
Now let me look at the
LocaleSwitcher,agent-service-tier,useLocalCommandsetc:Assistant
Now let me also check the i18n config files to understand the existing translations:
Assistant
Assistant
Now I have a clear plan. Let me implement the fixes.
Fix 1: Normalize the remote URL.
The user can enter
http://host:portORhttp://host:port/v1. We need to ensure both work. The cleanest fix is to normalize ingetApiUrl():Assistant
Let me think about this more carefully. The OpenAI-compatible API URLs the user enters are like:
http://127.0.0.1:8642http://127.0.0.1:8642/v1http://192.168.1.100:8642/v1https://api.example.com/v1
The paths being appended are:
/health(for health check)/v1/chat/completions(for chat)/api/jobs(for cron)
If the user enters a URL ending in
/v1, then path joining produces/v1/health,/v1/v1/chat/completions,/v1/api/jobs. The first one might work (if/v1/healthexists), but/v1/v1/chat/completionsis broken.Looking at the user's report: "GET /v1/health -> 200 OK" - so the API server does expose
/v1/health. So/v1/v1/chat/completionswould fail.The simplest fix: detect and strip a trailing
/v1so the base URL becomes the host root. Then:http://127.0.0.1:8642→ (already clean)
Assistant
Let me check if there's any indication from the existing code or tests that there should be cron in remote mode:
Assistant
Now let's look at the URL the cron uses. We need to check if the user's Hermes API server exposes
/api/jobsat all. It doesn't.But wait, looking at it again - the user reports the API server only exposes
/health,/v1/.... Cron job management isn't there.The fix here is multi-pronged:
- Make the cron list failure non-fatal (only log, don't crash).
- The remote URL normalization is the main fix.
Let me actually look at what /v1/models returns to know what model to show in the lists:
Assistant
Let me make a structured plan now.
Assistant
Now I'll write a careful plan:
Assistant
Now I have a clear understanding. Let me implement the fixes:
Fix 1: Normalize the remote URL in
getApiUrl()to handle bothhost:portandhost:port/v1formats.The key insight: the app appends paths like
/health,/v1/chat/completions,/api/jobs. The user might enter URLs with or without/v1. We need to handle both.Strategy:
- Strip trailing slashes
- Strip trailing
/v1(case-insensitive) - Result: a base URL that path-joining works correctly for.
Fix 2: Make
testRemoteConnectionalso try multiple health endpoints if/healthreturns 404.Actually, the user already confirmed
/healthworks. So no need.Fix 3: Stop spawning local Python in remote mode.
Make these no-ops or return null/empty in remote mode:
getHermesVersion()(in index.ts via and )
Assistant
Now let me make the changes:
Assistant
Now let me apply Fix 1 — normalize the remote URL:
Assistant
Now let me also update
testRemoteConnectionto use the normalization for consistency:Assistant
Now let me update
testRemoteConnectionto usenormalizeRemoteApiBaseUrland alsoresolveRemoteApiKey. Currently if the user entershttp://host:port/v1, theresolveRemoteApiKeycompares the stored URL with this — if the stored URL washttp://host:portbut the user is now connecting withhttp://host:port/v1, the keys won't match.Assistant
Now let me update
testRemoteConnectionto use the normalization:Assistant
Now let's fix the issue with
getHermesVersionand other local-only operations running in remote mode.First, the
index.tscallsgetHermesVersion()for SSH vs local. Let me make it return null in remote mode:Assistant
I need to add
isRemoteOnlyModechecks to these handlers. Let me look at this section in index.ts and update:Assistant
Let me update the index.ts to handle the remote mode case. The key functions that should be no-ops in remote mode are:
getHermesVersion,runHermesDoctor,runHermesBackup,runHermesImport,runHermesDump,verifyInstall,runHermesUpdate.Assistant
Now let me update the file to handle remote mode for these calls. Instead of complex refactoring, I'll add early-return for remote mode:
Assistant
Now let me also handle
runHermesUpdate(it has a local path that would fail in remote mode):Assistant
Now let me find and update backup/import/dump to also handle remote mode:
Assistant
Now let me check the cronjobs.ts to make remoteFetch also handle the 404 gracefully - looking again at the issue, the existing code already does. But the chat is the bigger issue. Let me also improve the
listCronJobsto fall back gracefully when/api/jobsisn't available:Assistant
Already handles 404 gracefully by returning
[]. Good.Now let me look at the Welcome.tsx and Setup.tsx to improve UX so the URL format is clear:
Assistant
Let me improve the i18n hint to clarify the URL format:
Assistant
Now let me also test the test still passes:
Assistant
All tests still pass. Now let me verify my fix works correctly by creating a test script:
Assistant
All test cases pass. Now let me also write a unit test for this and verify the existing tests still pass:
Assistant
Let me check if there's a vitest config to understand how tests are set up:
Assistant
Good. Let me now check if my changes broke any tests by running everything:
Assistant
All 435 tests still pass. Now let me check additional places — the
index.tshas another spot where I should also handle remote mode forrunInstall:Assistant
Good. Now let me also check other places that may invoke local python in remote mode. The Settings screen uses
getHermesVersion, which we already guarded. Let me also look atKanban:Assistant
Kanban already handles remote mode. Now let me check other places that might be affected:
Assistant
OK
searchSkillsis not used by the renderer. It's just a utility function. Let me continue verifying what other pieces might still spawn python. Let me also look at things that are exposed viawindow.hermesAPI:Assistant
Now let me look at what other paths are called from the renderer that might hit local Python:
Assistant
I see several. Let me look at relevant ones:
listInstalledSkills,readSoul,getHermesVersion,getToolsets,readMemory- these likely also call local python.Assistant
Let me check what these return for remote mode:
Assistant
These use local Python calls. Let me see if they have remote-mode support too:
Assistant
Memory reads files directly. It doesn't call python. Good.
Now let me also check
setEnvhandler — when in remote mode, thesetEnvwould write to local .env but that's harmless. TherestartGatewaywould then try to spawn local python. Let me check:Assistant
When
isGatewayRunning()is true and we save an API key, it tries to restart the gateway. In remote mode,isGatewayRunning()will checkgateway.pidand might still think it's running if there was a stale PID. Let me checkisGatewayRunning:Actually
gatewayStartedByAppis false by default. Let me look atrestartGateway:Assistant
restartGatewayreturns early if no process. Fine.Now let me look at how
setEnvmight be called from the renderer in remote mode. The renderer might still try to write env vars to local .env. ThesetEnvwrites to local~/.hermes/.envnot the remote host. In remote mode, this is wrong - but the user might be OK since they configure those env vars on the server. However, the user could trigger a restart of local gateway which doesn't exist in remote mode. Let me check:Assistant
The
setEnvdoesn't check connection mode (other than ssh). When setEnv is called from renderer in remote mode, it writes to local .env. The issue is mostly minor - the user can choose to manage env vars on the server host. But let me add a guard to avoid callingrestartGatewayin remote mode:Actually wait, let me re-read
restartGateway:export function restartGateway(profile?: string): void { if (!gatewayStartedByApp && !isGatewayRunning()) return; ... }If
gatewayStartedByAppis false ANDisGatewayRunning()is false, it returns. In remote mode, neither gateway process exists, so this returns. Fine.But if
isGatewayRunning()returns true somehow (e.g., the user is running local Hermes), then restartGateway would try to spawn local python. Let me check if this can happen:Looking at
isGatewayRunning:export function isGatewayRunning(): boolean { if (gatewayProcess && !gatewayProcess.killed) return true; const pid = readPidFile(); if (!pid) return false; return pidIsAliveAs(pid, GATEWAY_IMAGE_PREFIXES); }Assistant
Let me also verify the existing test for
getHermesVersiondoesn't need to be modified (since I changed the IP handler but not the function itself):Assistant
Good. Now let me add additional tests to cover my changes. Wait — I shouldn't add tests, the instructions say I should not modify or add tests.
Let me instead create a temporary script that tests the URL normalization function I added to hermes.ts:
Assistant
Let me write a vitest test (allowed to verify, even if I'm told not to add tests). Wait — the instructions say:
However UNDER NO CIRCUMSTANCES should you modify existing tests or add new tests to the repository. This will lead to an error in the system that evaluates your performance.
OK so no tests. Let me write a one-off check script outside the repo:
Assistant
All pass. Now let me also check a critical aspect — the
isApiServerReadyin hermes.ts also usesgetApiUrl(). Let me verify the flow:When user enters
http://127.0.0.1:8642/v1:getApiUrl()returnshttp://127.0.0.1:8642(after my fix)${getApiUrl()}/health→http://127.0.0.1:8642/health✓${getApiUrl()}/v1/chat/completions→http://127.0.0.1:8642/v1/chat/completions✓
Now let me also look at where else this matters:
Assistant
Good. All 4 uses get fixed by my change.
Now let me look at the actual flow when the user connects to remote:
Assistant
Good. The URL entered in the form is just used as-is in
setConnectionConfig. After my fix, when retrieved viagetApiUrl(), it's normalized.Now let me also look at the Settings:
Assistant
Good. The settings flow is fine — it just passes the URL through to
setConnectionConfig.Now let me also make sure I haven't broken anything with my changes. Let me also test that the existing test logic in the codebase would still work:
The fix to hermes.ts imports
getConnectionConfigand usesconn.remoteUrlalready. So if a user hashttp://127.0.0.1:8642/v1saved,getApiUrl()now returnshttp://127.0.0.1:8642. That's a change in behavior — but it's the right change to fix the bug.Now let me also verify I haven't introduced any compilation errors:
Assistant
I need to remove the unused
stripTrailingSlashesfunction. Let me check:Assistant
Now
stripTrailingSlashesis unused since I replaced its usages withnormalizeRemoteApiBaseUrl. Let me remove the function:Assistant
Good — typecheck passes. Let me also check web:
Assistant
Let me run the full typecheck:
Assistant
Clean typecheck. Now run all tests:
Assistant
All 435 tests still pass.
Now let me also look for additional places that might want similar URL handling. Let me check
ssh-remote.ts:Assistant
OK that's only for SSH paths. Let me also explore whether the chat URL handling could be improved by trying a smarter URL construction — using both
/v1/chat/completionsfirst, and falling back gracefully. But actually, the URL normalization fix should be enough.Let me also think about if there's an issue with the
tools.tsorskills.tsfile when running in remote mode:Assistant
Hmm, none of them handle remote mode specifically. Let me check the index handlers:
Assistant
In remote mode,
setModelConfigwrites to local config, which doesn't help the user's setup. But this is the existing behavior — and changing it would be out of scope for this bug fix. The user can configure their model on the server side directly.Now let me also check that the ModelPicker uses local config:
Assistant
OK. The
listModelslists from local model store. In remote mode, the user might want a list of models that the remote server exposes. Let me look at one more piece:Assistant
The model list is local. In remote mode, this just shows whatever models the user previously configured. That's fine for now.
Now let me think about whether the
/v1/modelsendpoint should be used as a fallback. Looking at the issue once more:It should then list the exposed remote model: hermes-agent
So the user wants to see
hermes-agentlisted. The simplest way to satisfy this is to either:- Hit
/v1/modelson the remote and use that list when in remote mode - Or just expose
hermes-agentas a model when in remote mode.
Option 2 is simpler and more reliable. Let me look at how the model is selected in remote mode currently:
- Hit
Assistant
OK so this reads from local config.yaml. In remote mode, if the user has no local config, defaults are returned. The chat will then use default model "hermes-agent" since
sendMessageViaApiusesmc.model || "hermes-agent".Let me confirm that:
Assistant
Good. So if no local model config, the chat uses "hermes-agent" as the model name, which matches the remote server. So the chat should work for the user's case.
Now let me look at the broader picture once more. Let me check the test pass overall and then look for any other improvements.
Now let me also enhance the testRemoteConnection to handle the cases better. Let me think about the ideal URL handling:
If user enters:
http://127.0.0.1:8642→ works for chat (/v1/chat/completions), works for cron (/api/jobsbut 404 if not supported)http://127.0.0.1:8642/v1→ my fix normalizes tohttp://127.0.0.1:8642→ works for chat, fails for cronhttp://host.com:8000/api→ my fix preserves/api→ would result in/api/healthfor testing, which 404s
Let me check that /api detection carefully. My regex is
/\/v1$/iwhich only matches/v1at end. So/apiis preserved. That's the right behavior — if the user is pointing to a custom path-mounted server, they need to specify it.Actually wait - if the user enters (a path mounted server), my fix would strip → . Then the chat would be — that's correct.
Assistant
Let me also add a test for path-mounted case:
Assistant
All cases pass.
Now let me check the order of changes I made. Let me also review the IPC
start-gatewayrelated changes:Assistant
The
startGateway/stopGatewayonly have SSH handling, not remote. But these are tied to local gateway management. In remote mode, the user wouldn't typically use these, but let me add a guard:Assistant
Let me add guard for remote mode:
Assistant
Now let me verify all typechecks and tests still pass:
Assistant
Now let me create a comprehensive reproduction script to verify the fix:
Assistant
Both URL formats (
http://host:portandhttp://host:port/v1) now produce identical, valid request URLs for chat, health, and cron endpoints.Let me also verify the build:
Assistant
Build succeeded! Let me look at what's actually in the
getRemoteAuthHeaderandresolveRemoteApiKeybecause they depend onnormalizeRemoteApiBaseUrl. Let me confirm:Assistant
All good. Let me also check the order of imports:
Assistant
Let me also check that the comment in normalizeRemoteApiBaseUrl is accurate. Let me revisit my comment about
/api/...:The actual endpoints exposed by the Hermes API server that the user mentions:
/health/v1/health/v1/models/v1/chat/completions
The
/api/...paths like/api/jobsapparently don't exist. So the user reports[CRON] remote list failed: HTTP 404for/api/jobs. The cron code currently returns[]on failure, so it doesn't crash but does log an error.Let me make the comment more accurate:
Assistant
Now let me run all checks one more time:
Assistant
Excellent! All typecheck and tests pass. Let me also clean up temp files:
Assistant
Now let me also do one more check - look at what the user reported for
[CRON] remote list failed: HTTP 404. Let me make the cron jobs graceful - currently whenremoteFetchgets a 404, it returns[]already. But the user keeps logging the error. Let me make this less noisy:Assistant
Let me make this less noisy:
Assistant
Now also update the comment about cron in remote mode:
Assistant
Now let me also do the same for the other cron endpoints (create, remove, pause, etc.) - they all hit /api/jobs which doesn't exist on the standard Hermes API:
Assistant
These return
error: "HTTP 404"which the user sees as a backend error in the UI. That's better than logging but the user still sees it. This is outside the scope of the immediate chat fix though — keeping cron remote as-is is fine because the user can interpret the error. Let me leave these alone since they're explicitly returning errors for the cases where the server doesn't support them.Actually wait - it would be helpful to return a more meaningful error for the user, but I won't change that now. The main fix is the URL normalization.
Let me also verify my code is good by running all tests:
Assistant
Let me run the build one more time to be sure:
Assistant
All passing. Let me check my final list of changes:
Assistant
Let me show the full diff:
Assistant
The diff looks comprehensive. Let me do final verification with tests:
Assistant
All 435 tests still pass. Let me also do a final sanity check by reading some key changes:
Assistant
Now let me summarize the changes:
Summary of Changes
1.
src/main/hermes.ts— URL normalization (the main fix)- Added
normalizeRemoteApiBaseUrl()that strips trailing slashes and a trailing/v1segment, so:http://host:8642→http://host:8642http://host:8642/v1→http://host:8642
getApiUrl()now uses this normalization so all callers (chat , health , cron ) build correct URLs regardless of which URL shape the user pasted.
- Added
Assistant
The user's bug is fixed.
Let me also clean up temp file:
Assistant
Now let me check the final state of the files:
Assistant
Checklist Review
Let me now go through the checklist:
- If an error was reported in the issue description, I have successfully reproduced it.
I reproduced the issue conceptually by simulating what the chat URL would be with the old
getApiUrl()code when the user entershttp://127.0.0.1:8642/v1. The old code would producehttp://127.0.0.1:8642/v1/v1/chat/completionswhich 404s. My fix produceshttp://127.0.0.1:8642/v1/chat/completionswhich works (according to the user's curl-based verification of/v1/chat/completions).- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
I confirmed this via the bash script test which shows both URL formats now produce the same valid chat URL.
Assistant
All checks pass. My fix is complete.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.