From 5322a809e394ebd8985d5f8059bc0a948b3c829a Mon Sep 17 00:00:00 2001 From: webtecnica Date: Sun, 19 Jul 2026 17:06:20 -0300 Subject: [PATCH 1/2] fix(installer): preserve baseline-import traceback on Windows, add retry for transient failures (#67637) The Windows dependency stage's baseline-import gate discarded all Python output with 2>&1 | Out-Null, so when imports failed the log lost the actual ModuleNotFoundError/ImportError traceback and replaced it with a wrong-venv assertion that was often incorrect. Changes: - Capture stderr+stdout with Out-String instead of discarding with Out-Null so the real Python traceback is available in the error. - Retry the baseline import probe up to 3 times (800ms between attempts) so transient failures from file locks or antivirus scanning can self-heal before the gate aborts. - On persistent failure, report the exact interpreter path, module list, exit codes, and retained traceback in the error. - Only claim a sibling .venv when it actually exists on disk. - Apply the same output-preservation pattern to the web deps import/compile checks (fastapi/uvicorn, py_compile). --- scripts/install.ps1 | 56 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/scripts/install.ps1 b/scripts/install.ps1 index 746b5090faafb..eb24f294bb16a 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -2101,19 +2101,48 @@ except Exception: # throws even when the imports succeed. $LASTEXITCODE is the # reliable signal (it's 0 iff the python invocation exited 0, # regardless of what was written to stderr). + # + # Probe the exact managed venv\Scripts\python.exe in a bounded + # retry loop so short-lived transient failures (file locks during + # concurrent install, antivirus scanning, etc.) can clear before + # the gate aborts. Capture the combined stdout+stderr so the + # final error message includes the actual Python traceback rather + # than silently replacing it with a wrong-venv assertion (#67637). + $maxRetries = 3 + $importExitCode = 1 + $importOutput = "" + $importAttempt = 0 $prevEAP = $ErrorActionPreference $ErrorActionPreference = "Continue" - & $venvPython -c "import dotenv, openai, rich, prompt_toolkit" 2>&1 | Out-Null - $importExitCode = $LASTEXITCODE + while ($importAttempt -lt $maxRetries -and $importExitCode -ne 0) { + $importAttempt++ + $importOutput = & $venvPython -c "import dotenv, openai, rich, prompt_toolkit" 2>&1 | Out-String + $importExitCode = $LASTEXITCODE + if ($importExitCode -ne 0 -and $importAttempt -lt $maxRetries) { + Write-Warn "Baseline import attempt $importAttempt/$maxRetries failed (exit $importExitCode); retrying..." + Start-Sleep -Milliseconds 800 + } + } $ErrorActionPreference = $prevEAP if ($importExitCode -ne 0) { $sibling = "$InstallDir\.venv" - $hint = if (Test-Path $sibling) { - "Detected sibling .venv\ at $sibling -- uv synced there instead of venv\. Recover with: cd '$InstallDir'; Remove-Item -Recurse -Force venv; Move-Item .venv venv" + $siblingPresent = Test-Path $sibling + $diagnostic = @( + "", + "Python interpreter: $venvPython", + "Modules probed: dotenv, openai, rich, prompt_toolkit", + "Exit code: $importExitCode (after $importAttempt attempt(s))", + "Working directory: $InstallDir", + "Sibling .venv\ present: $siblingPresent", + "Last import output (traceback):", + "$importOutput" + ) -join "`n" + if ($siblingPresent) { + $diagnostic += "`nDetected sibling .venv\ at $sibling -- uv synced there instead of venv\. Recover with: cd '$InstallDir'; Remove-Item -Recurse -Force venv; Move-Item .venv venv" } else { - "Recover with: cd '$InstallDir'; `$env:UV_PROJECT_ENVIRONMENT='$InstallDir\venv'; uv sync --extra all --locked" + $diagnostic += "`nRecover with: cd '$InstallDir'; `$env:UV_PROJECT_ENVIRONMENT='$InstallDir\venv'; uv sync --extra all --locked" } - throw "Baseline imports failed in $InstallDir\venv (dotenv/openai/rich/prompt_toolkit). The install completed but dependencies are not in the venv. $hint" + throw "Baseline imports failed in $InstallDir\venv (dotenv/openai/rich/prompt_toolkit).$diagnostic" } Write-Success "Baseline imports verified in venv" } @@ -2175,17 +2204,22 @@ print(','.join(scripts)) # even when fastapi/uvicorn are actually installed. $prevEAP = $ErrorActionPreference $ErrorActionPreference = "Continue" + $webImportOutput = "" try { - & $pythonExe -c "import fastapi, uvicorn" 2>&1 | Out-Null + $webImportOutput = & $pythonExe -c "import fastapi, uvicorn" 2>&1 | Out-String if ($LASTEXITCODE -eq 0) { $webOk = $true } } catch { } + $webCompileOutput = "" try { - & $pythonExe -m py_compile "$InstallDir\hermes_cli\web_server.py" 2>&1 | Out-Null + $webCompileOutput = & $pythonExe -m py_compile "$InstallDir\hermes_cli\web_server.py" 2>&1 | Out-String if ($LASTEXITCODE -eq 0) { $webServerSyntaxOk = $true } } catch { } $ErrorActionPreference = $prevEAP if (-not $webOk) { Write-Warn "fastapi/uvicorn not importable -- `hermes dashboard` will not work." + if ($webImportOutput) { + Write-Info "Import output: $($webImportOutput.Trim())" + } Write-Info "Attempting targeted install of [web] extra as last resort..." & $UvCmd pip install -e ".[web]" if ($LASTEXITCODE -eq 0) { @@ -2195,7 +2229,11 @@ print(','.join(scripts)) } } if (-not $webServerSyntaxOk) { - throw "dashboard backend source failed syntax check: hermes_cli/web_server.py" + $diag = "dashboard backend source failed syntax check: hermes_cli/web_server.py" + if ($webCompileOutput) { + $diag += "`nSyntax check output: $($webCompileOutput.Trim())" + } + throw $diag } } From ac61907ef9cd87232fea46a42ad33dfcc433eceb Mon Sep 17 00:00:00 2001 From: webtecnica Date: Sun, 19 Jul 2026 19:20:36 -0300 Subject: [PATCH 2/2] fix(cron): add attach_to_session normalization to dashboard cron update (#67706) The dashboard adapter _normalize_dashboard_cron_updates was missing boolean normalization for attach_to_session, causing the field to be silently ignored or (after the upcoming whitelist PR #67660) rejected as unknown. Add explicit bool() coercion matching the agent tool path in cronjob_tools.py. Closes #67706 --- hermes_cli/web_server.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hermes_cli/web_server.py b/hermes_cli/web_server.py index 4ddb16487fda2..24c9f0f982137 100644 --- a/hermes_cli/web_server.py +++ b/hermes_cli/web_server.py @@ -11066,6 +11066,8 @@ def _normalize_dashboard_cron_updates( normalized["context_from"] = _cron_string_list(normalized["context_from"]) if "enabled_toolsets" in normalized: normalized["enabled_toolsets"] = _cron_string_list(normalized["enabled_toolsets"]) + if "attach_to_session" in normalized: + normalized["attach_to_session"] = bool(normalized["attach_to_session"]) return normalized