Skip to content

fix(windows): stop background processes from opening blank console windows - #5018

Merged
kovtcharov-amd merged 1 commit into
mainfrom
fix/windows-hidden-console
Oct 12, 2026
Merged

kovtcharov-amd merged 1 commit into
mainfrom
fix/windows-hidden-console

Conversation

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

On Windows, GAIA's daemon and its embedded Lemonade server were started with no console at all, so every console program they later started (a sidecar, tasklist/taskkill, an MCP server, ngrok) got its own visible, empty console window. They now start with a hidden console that everything beneath them inherits, and the spawn sites that can run under a console-less parent pass the same hidden-console flag, so no blank windows appear.

🔍 Technical details
  • DETACHED_PROCESS (daemon in daemon/client.py, lemond in lemonade_embedded.py) replaced by CREATE_NO_WINDOW | CREATE_NEW_PROCESS_GROUP via background_popen_kwargs(); the two flags are mutually exclusive, and only the latter gives descendants a console to inherit. Sidecars and the supervised Lemonade use the same helper.
  • One-shot/stdio children (MCP stdio servers, native hub agents, gaia init from the setup runner, Agent UI MCP server, ngrok, tasklist/taskkill, lemonade backends install) use windows_hidden_popen_kwargs(). The user-requested background="terminal" Lemonade launch keeps CREATE_NEW_CONSOLE; opening Explorer is untouched.
  • Measured on Windows 11: a console-less parent starting a console child with no flags opens a visible Windows Terminal window; with the new flags the child's GetConsoleWindow() is 0 and no window appears. A daemon started from this branch in an isolated GAIA_HOME has a windowless console (the currently shipped daemon has none), and so does the lemond it starts.
  • Lemond 2026.39.1/2026.40.0 already starts llama-server/koko/whisper-server with their own windowless conhost, so those conhost.exe entries in a process tree are expected and are not windows.
  • Go TUI unchanged: it runs in a visible terminal, so its children share that console instead of getting a new one.

Test plan

  • python -m pytest tests/unit/test_windows_hidden_console.py (per-site flag checks, plus an AST guard that fails any new spawn in these modules without the helper)
  • python -m pytest tests/unit/test_daemon*.py tests/unit/test_lemonade_embedded.py tests/unit/test_lemonade_supervisor.py tests/unit/test_agent_sidecar_manager.py tests/unit/test_native_launcher.py tests/unit/chat/ui tests/unit/mcp
  • On Windows: gaia daemon restart, use voice and chat, confirm no empty console windows appear

…sole windows

The daemon and the embedded Lemonade server were started with
DETACHED_PROCESS, which leaves them with no console at all. Windows then
gives every console program they start - a sidecar, tasklist, taskkill, an
MCP server, ngrok - a new, visible, empty console window.

Background servers now start with CREATE_NO_WINDOW | CREATE_NEW_PROCESS_GROUP:
a console of their own with no window, inherited by everything they start.
Spawns that can run under a console-less parent (the daemon, the Agent UI
backend, a sidecar) pass CREATE_NO_WINDOW too. Both come from two helpers in
gaia.utils.terminal so every site uses the same flags; a test fails any new
spawn in those modules that skips them. The user-requested "terminal"
Lemonade launch keeps its visible console.

Also narrows three swallowed `except Exception` blocks in the touched tunnel
and MCP stdio code to the errors they expect, logged.
@github-actions github-actions Bot added mcp MCP integration changes llm LLM backend changes tests Test changes performance Performance-critical changes daemon Daemon supervisor / sidecar control plane sidecar Agent sidecar contract / harness labels Oct 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

On Windows, GAIA's daemon and embedded Lemonade used to start with no console at all, so every console program they launched later popped up its own empty window. This PR starts them with a hidden console instead, which every child inherits. It also puts the same hidden-console flag on the spawn sites that can run under a console-less parent. The fix is sound and well tested, and nothing in it blocks merge. The Windows behaviour itself was only measured by the author and was not seen in CI, so the manual Windows check in the test plan is still the step that proves it.

One small follow-up: the ngrok polling loop now catches a narrower set of errors. If ngrok's local API ever returns an unexpected JSON shape, Mobile Access setup would crash where it used to keep polling.

Real-world evidence

The evidence stage ran on Linux. Every spawn path it could reach still works there, and Windows-only behaviour could not be observed. From the bundle:

$ gaia daemon start
daemon: started pid=2687 port=51323
✅ GAIA daemon running (pid 2687, port 51323)

$ ps -o pid,ppid,pgid,sid,cmd -p 2687
    PID    PPID    PGID     SID CMD
   2687       1    2687    2687 python -m gaia.daemon
$ curl -X POST -H 'X-Gaia-UI: 1' http://127.0.0.1:4200/api/mcp/agent-server/start -d '{}'
{"status":"started","port":8766,"pid":2834,"url":"http://localhost:8766/mcp"}
HTTP 200
$ curl -X POST -H 'X-Gaia-UI: 1' http://127.0.0.1:4200/api/mcp/agent-server/stop
{"status":"stopped","pid":2834}
HTTP 200
$ curl -H 'X-Gaia-UI: 1' 'http://127.0.0.1:4200/api/setup/check?skip_chat_model=true'
{"ready":false,"stage":"setup","reasons":["GAIA's Lemonade Server is not installed"], ...}
HTTP 200   (1.1 s)
StdioTransport(command="python", args=["-c", "...stderr.write('planted-stderr violet-otter-92'); sys.exit(3)"]).connect()
RuntimeError: MCP server process died (exit code: 3)
Server stderr:
planted-stderr violet-otter-92
  • Passed: daemon start/status/stop, the Agent UI MCP server start/stop routes, setup check, the stdio MCP client (including the rewritten stderr read), and a spot regression of sibling routes and CLI commands.
  • Not exercised: tunnel/ngrok (needs an auth token), the supervisor, the LemonadeClient server start, native hub agents, and sidecar spawn (all need Lemonade or an agent binary). The verdict on those rests on static review plus the faked-platform unit tests.
  • Can't be run here: the Windows "no blank window" behaviour needs a Windows machine. Agent UI rendering is pending the strix-halo lane.
🔍 Technical details

Issues

🟢 Narrowed ngrok poll handler no longer covers malformed JSON (src/gaia/ui/tunnel.py:658). except (httpx.HTTPError, ValueError) handles network and decode errors. But data.get(...) / tunnel.get(...) raise AttributeError if the 4040 API returns a list, or a tunnel entry that isn't a dict. The old except Exception treated that as "not ready yet". Removing the silent pass is right; a cheap fix is to add AttributeError to the tuple:

            except (httpx.HTTPError, ValueError, AttributeError) as e:

🟢 The AST guard covers only the 10 listed modules. That's fine as long as the daemon and lemond own a hidden console, because anything spawned beneath them (e.g. ports.py, sidecars/ledger.py taskkill) inherits it. It's worth one line in the test docstring saying the list is "spawn sites that can run under a console-less parent". Then nobody later "completes" it with every subprocess caller in the tree, or assumes modules outside it are unprotected.

Checked and fine

  • background == "terminal" still passes only CREATE_NEW_CONSOLE (no duplicate creationflags kwarg). hidden is added only to the silent and foreground branches.
  • Nothing in src/ or hub/ sends CTRL_BREAK_EVENT / GenerateConsoleCtrlEvent to sidecars. So giving each sidecar its own hidden console, instead of sharing the daemon's, doesn't break any signal path. Tree-kill uses taskkill /T.
  • DETACHED_PROCESS → CREATE_NO_WINDOW | CREATE_NEW_PROCESS_GROUP keeps the "outlive the launcher" property. Job-object breakaway behaviour is unchanged (neither old nor new sets CREATE_BREAKAWAY_FROM_JOB).
  • The stdio.py stderr rewrite keeps the same return contract. UnicodeDecodeError is a ValueError, so it's still handled.
  • I couldn't run the new tests locally (pytest isn't installed in the review environment). CI was still pending at review time.

Strengths

  • One helper pair in gaia/utils/terminal.py replaces five hand-rolled creationflags blocks that had drifted: one used DETACHED_PROCESS, one CREATE_NO_WINDOW, one neither.
  • Per-site tests drive the real spawn functions with a faked platform. The AST guard makes the regression hard to reintroduce in the guarded modules.
  • It fixes two pre-existing except Exception: pass blocks in touched files, as CLAUDE.md asks.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 12, 2026
Merged via the queue into main with commit ab889bc Oct 12, 2026
@kovtcharov-amd
kovtcharov-amd deleted the fix/windows-hidden-console branch October 12, 2026 03:02
kovtcharov pushed a commit to kovtcharov/gaia that referenced this pull request Oct 30, 2026
…er (amd#5404)

The proactive Claude reviews were failing about half the time, and each
failure was lost. The code and security audits failed 5 of the last 10
nights, and the doc walkthrough failed 4 of its last 5 runs. Running
three audits every night used up both Claude accounts' weekly limit by
mid-week, so most of those runs stopped before reviewing anything and
blamed a missing file. The next run never went back for the missed work.
Now one audit runs each night between 2 and 4am Pacific, so each audit
runs every third night. Each run checks Claude is available before
starting, and says plainly when it isn't. It picks up everything since
its last successful run, starts from what merged since then, and checks
against the bug types past audits missed. The dedup pass no longer
re-files duplicates that were already closed: 34 of them were closed
alongside this change.

## Test plan

- [ ] `python -m pytest tests/unit/test_audit_synthesis_prep.py
tests/unit/test_audit_history.py tests/unit/test_audit_rotation.py
tests/unit/test_require_claude.py tests/unit/test_recent_changes.py
tests/unit/test_miss_analysis.py
tests/unit/test_claude_audit_workflow_contract.py
tests/unit/test_closed_duplicates.py -q` passes (277 tests)
- [ ] After merge: `gh workflow run claude-audit-rotation.yml -R
amd/gaia -f dry_run=true`. The summary names tonight's audit and the
next five nights, and nothing is dispatched.
- [ ] After merge: `gh workflow run claude-nightly-audit.yml -R amd/gaia
-f dry_run=true`. Check the preflight summary: the mode, a window
reading "since this audit's last successful run", the Claude probe
passing, and "Recent changes read first". At the end, "Dry run
confirmed: no issue created".
- [ ] After merge: `gh workflow run claude-weekly-doc-walkthrough.yml -R
amd/gaia -f doc_filter=docs/quickstart.mdx -f dry_run=true`. The guide
is walked, "Using bash.exe from …" appears, and the dry-run watermark
step passes (it crashed before this change).
- [ ] After merge: `gh workflow run claude-security-audit.yml -R
amd/gaia`. Semgrep scans `tui`, `installer` and `.github/workflows`, and
the SARIF uploads.
- [ ] First scheduled night (10:13 UTC): the dispatched run is titled "…
rotation night N", files at most what's new, and an issue it files
carries `audit-cluster` / `audit-key` markers.

<details>
<summary>🔍 Technical details</summary>

**Root causes (last ~2 weeks)**
- Code and security audits, Oct 7/10/12/13/14/17: every lens returned
`is_error` in under a second with "You've hit your weekly limit". The
primary account ran out on Oct 10, the secondary on Oct 12–14, both on
Oct 17. The account switch fired correctly; both accounts were spent.
- Walkthrough Oct 12: same weekly limit on every guide, queued over 57
hours on the Strix Point pool. Oct 5 and Oct 19: the `xsj-aimlab-stxp`
images have no Git for Windows (only WSL's `bash.exe`). Also on Oct 5,
the executor step's `GITHUB_OUTPUT` got UTF-16 appended by
`start-lemonade.ps1` under PowerShell 5.1 `>>`. Sep 21–28: Application
Control blocked `LemonadeServer.exe` and the job landed on Strix Halo
machines; both were fixed by the move to the `xsj-dispatch` pool on Oct
1.
- The walkthrough's two dry-run steps had a literal `\n` mid-command, so
`dry_run=true` always failed.

**Schedule.** One cron, `13 10 * * *` = 03:13 PDT / 02:13 PST. Only
10:00–11:00 UTC is inside 2–4am Pacific in both seasons. Slot = days
since epoch mod 3 → code audit, security audit, doc walkthrough. The
audits lost their own crons; `workflow_dispatch` still runs any of them
on demand. Deep code sweep: whenever the last successful one is over 8
days old (every third turn, retried on the next turn if it fails).

**Dedup bug.** The 2026-09-07 burst (78 issues) predates the dedup pass:
the run checked out main 7 hours before amd#3310 merged. Three duplicate
pairs still got through after amd#3310 (amd#3832/amd#3471, amd#3825/amd#3414,
amd#5199/amd#4875). Backlog matching compared findings against issue titles
only, so a same-section duplicate worded differently scored 0.05–0.15,
below the 0.18 threshold. Now matching includes each audit issue's own
markers (all 13 known pairs rank 1st–2nd). Closed duplicates hand their
keys to the open canonical, so consolidating into amd#1077/amd#4331 does not
trigger re-filing. Both syntheses share the `claude-audit-issue-filing`
concurrency group. The security audit files to private code scanning,
not issues, so it cannot duplicate the other two.

**Closed as duplicates (34):** into amd#4331: amd#3204 amd#3413 amd#3422 amd#3439 amd#3466
amd#3476. Into amd#1077: amd#3173 amd#3412 amd#3418 amd#3426 amd#3429 amd#3430 amd#3433 amd#3437 amd#3442
amd#3449 amd#3454 amd#3455 amd#3464 amd#3468 amd#3475 amd#3477 amd#3482. Into amd#3198: amd#3436
amd#3462. Others: amd#3425→amd#3169, amd#3457→amd#3195, amd#3440→amd#3180, amd#3486→amd#3064,
amd#3471→amd#3832, amd#3414→amd#3825, amd#3434 amd#3485→amd#3219, amd#5199→amd#4875.

**Miss-analysis (merged `fix` PRs, Jun 21–Oct 19).** 29 of 1005 (3%)
closed an issue an audit filed first. Missed, by title: no deadline 90
(amd#5346 amd#5384 amd#5380), release/CI ordering 71 (amd#5127 amd#5147), Windows
behaviour 38 (amd#5018 amd#5377), dishonest status 36 (amd#5112 amd#5317), shared
state across processes 34 (amd#5337 amd#5282 amd#5378), model output handling 27
(amd#4973 amd#5103), doc drift 27, cold start / non-default setup 26 (amd#4951
amd#5130). About 380 more were Agent UI/TUI or agent-behaviour fixes, which
a static read rarely catches. Noise: of the audit issues closed as
duplicate or not planned, 31 were duplicates of amd#1077, 12 of the
test-coverage umbrella amd#2988, and 6 each of amd#4331, amd#3149, amd#3308 and
amd#2922. What changed: `scripts/audit/missed_bug_classes.md` has a
checklist per class and a "Don't report" list, and all three prompts
read it at run time. The code audit gets a deterministic list of calls
with no deadline. The security audit's semgrep run and worklist now
cover TypeScript, Go, the installer and the workflows.
`scripts/audit/miss_analysis.py` refreshes the evidence monthly.

**Recent changes.** Each audit's first job writes `recent-changes.md`:
first-parent commits since the commit its last successful run checked
out, read from the run history, with PR title, a short body excerpt and
the paths each touched, capped at 30 KB. If that commit is unknown it
covers 3 days and says so.
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

daemon Daemon supervisor / sidecar control plane llm LLM backend changes mcp MCP integration changes performance Performance-critical changes sidecar Agent sidecar contract / harness tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant