fix(ui): kill orphaned backend before upgrade to free gaia.exe on Windows#1392
fix(ui): kill orphaned backend before upgrade to free gaia.exe on Windows#1392kovtcharov-amd wants to merge 4 commits into
Conversation
Most agents capped at max_steps=10 (some 5/6) and the Agent UI hardcoded 10 in four more places, so multi-step agents (e.g. the browser agent) ran out of steps mid-task while the CLI used 100 and background ticks 20 — the limit was both too low and inconsistent across entry points. Introduce default_max_steps() in base/agent.py as the single source of truth (DEFAULT_MAX_STEPS=50, overridable at runtime via GAIA_AGENT_MAX_STEPS) and have every agent config inherit it via field(default_factory=...), plus the base Agent, the UI chat paths, and the autonomous-tick loop. Agents that intentionally need more keep their explicit override (CodeAgent=100, EMR=50). A present-but-invalid env value raises instead of silently capping.
The CLI's shared --max-steps defaulted to 100 and was always passed explicitly, so the new global default and GAIA_AGENT_MAX_STEPS were ignored for gaia chat/browse/analyze/blender — the env override silently no-op'd on the primary launch path. Default the flag to None so it falls through to default_max_steps() in Agent.__init__, making the env var work everywhere. Document the knob (default 50, env override, fail-loud) in the CLI reference.
The Code Quality (Lint) job runs pylint over all of src/gaia and was already failing on main: #1355 left a mutable-default (W0102) in quality_metrics.py and several Protocol-parity unused-argument signatures (W0613) in the Outlook/email-MCP backends. Fix the mutable default with a None sentinel and annotate the interface-parity stubs, so the gate is green for this PR and every other open PR.
…dows On Windows an upgrade failed at startup with `os error 32` (file in use) when a previous `gaia chat --ui` process was still running: it held an open handle on gaia.exe, so the installer's `uv pip install --refresh` could not replace it and the app refused to open (issue #1388). The orphan cleanup that kills the leftover backend only ran inside startBackend(), AFTER the installer. It also had no Windows branch in its process-identity probe, so even on the right ordering it couldn't confirm the orphan was a GAIA backend and skipped the kill. - Extract the cleanup into cleanupOrphanedBackend() and run it BEFORE bootstrapBackend(), so the lock is released before pip refreshes. - Add a win32 identity probe (PowerShell Win32_Process CommandLine), keeping the conservative match so unrelated processes are never killed. - As defense-in-depth, detect the os-error-32 lock signature in the pip step and raise an actionable error pointing the user at the live process instead of the generic manual-install hint.
Review —
|
Why this matters
On Windows, GAIA could fail to open after an auto-upgrade. If a previous
gaia chat --uibackend was still running (the app was double-clicked again or had crashed without cleanup), it kept an open handle ongaia.exe. The installer'suv pip install --refreshthen couldn't replace the executable and aborted withos error 32: The process cannot access the file because it is being used by another process— the user saw an install-failed dialog instead of the app (issue #1388).The orphan-cleanup logic that kills the leftover backend only ran inside
startBackend(), after the installer had already tried (and failed) to refresh the package. It also had no Windows branch in its process-identity probe, so even with the right ordering it could not confirm the orphan was a GAIA backend and skipped the kill entirely. After this change the orphaned backend is identified and terminated before the upgrade runs, so the file lock is released and the upgrade completes.What changed
bootstrapBackend()(the install/refresh step), not just before spawning the new backend.Win32_ProcessCommandLine), keeping the existing conservative match so unrelated user processes are never signalled (issue [Bug]: AppImage not working on Ubuntu 24.04 LTS #782 TOCTOU mitigation).os error 32lock signature and raises an actionable error ("close GAIA completely, including any leftover gaia.exe in Task Manager, then relaunch") instead of the generic manual-install hint.Test plan
cd tests/electron && npx jest— full suite green (577 tests), including newbackend-orphan.test.cjs(win32/linux/darwin identity probe) andbackend-installer-lock.test.cjs(os-error-32 detection).gaia.exeis killed before the pip step and the upgrade completes.Fixes #1388