issue-agent prep-host: Get-CimInstance wedges in runner context on PC-user #162

Closed
opened 2026-04-29 00:31:47 -07:00 by romaine-life-app[bot] · 0 comments
romaine-life-app[bot] commented 2026-04-29 00:31:47 -07:00 (Migrated from github.com)

Paused for the night, picking up tomorrow. Captures everything we figured out so future-me / future-Claude doesn't re-do the diagnosis.

Symptom

Prepare issue-agent host step in the issue-agent workflow hangs on the nelsonpc-user runner inside Stop existing STS2 processes (the Get-CimInstance Win32_Process | … | Stop-Process block in .github/scripts/prepare-issue-agent-job.ps1). Step rides the timeout-minutes: 10 cap to the end and fails. Reproducible across at least three runs:

  • 25090457215 — 38 min before user-cancel (pre-observability)
  • 25093500782 — ~12 min before user-cancel
  • 25094309559 — exactly 10 min, hit the new step timeout. Last log line is the BEGIN of Stop existing STS2 processes, then ten minutes of silence. Game wasn't even running on the host — so the foreach iterates zero times and the only thing that can hang is Get-CimInstance Win32_Process itself.

What we ruled out

  • Not the Stop-Process call. Game wasn't running, so foreach is empty.
  • Not WMI fundamentally broken on the host. User ran Get-CimInstance Win32_Process interactively on PC-user; it returned fine.
  • Not introduced by my observability PR (#161). The Stop-Process block is unchanged code shape since 2fc2a67 (your commit, 2026-04-26). #161 just wrapped it in Invoke-LoggedStep.

Likely cause

Runner context vs interactive context difference. WMI / DCOM behaves differently when called from a service / Session 0 / non-interactive shell vs an interactive desktop. Some providers stall on impersonation / message-pump waits that don't exist in the runner's session. Endpoint-protection products sometimes inspect WMI calls from background processes with extra scrutiny that turns into a stall.

Important contributing factor: #159 migrated shell: powershell → shell: pwsh. Pre-#159, this exact code ran on Windows PowerShell 5.1 (DCOM transport, .NET Framework). Successful runs existed in that window (e.g. PR #155 Pocketwatch at 01:53Z on 2026-04-29). Post-#159, Get-CimInstance runs under PS 7 / .NET 7+ / different defaults — which exposed whatever runner-context fragility was already latent.

Open questions for tomorrow

  1. What user / context does the GH Actions runner run as on PC-user? If it's installed as a Windows service (services.msc → look for actions.runner.*), service-context WMI is a well-known stall source. This is the single biggest "what changed" answer.
  2. Does the same code shape hang on nelsonlaptop? (All the recent failures were on PC-user; laptop's pwsh-availability fix is separate.)

Proposed fix (~90% confidence)

Replace Get-CimInstance Win32_Process with Get-Process -Name 'SlayTheSpire2','crashpad_handler' in the kill block. Get-Process calls NtQuerySystemInformation directly — no WMI / DCOM / impersonation involved, behaves identically in interactive and service sessions. Same shape exists in .github/scripts/restart-sts2.ps1 (Get-Sts2Processes helper) — should get the same treatment in one PR.

Belt-and-suspenders for the kill itself: add WaitForExit(5000) per process and escalate to taskkill /F /T /PID if Stop-Process didn't terminate within the budget. Doesn't address the actual hang (which is in enumeration), but hardens the kill against legitimately wedged STS2 processes.

Sketch:

Invoke-LoggedStep -Name 'Stop existing STS2 processes' -Body {
    $procs = Get-Process -ErrorAction SilentlyContinue -Name 'SlayTheSpire2','crashpad_handler' |
        Where-Object {
            try { $_.MainModule.FileName.StartsWith($gameDir.TrimEnd('\') + '\', [System.StringComparison]::OrdinalIgnoreCase) }
            catch { $false }
        }
    foreach ($p in $procs) {
        Write-Host "Stopping $($p.Name) pid=$($p.Id)"
        try { Stop-Process -Id $p.Id -Force -ErrorAction Stop; $p.WaitForExit(5000) | Out-Null } catch {}
        if (-not $p.HasExited) {
            Write-Warning "Stop-Process didn't kill $($p.Name) pid=$($p.Id) within 5s; escalating to taskkill"
            & taskkill.exe /F /T /PID $p.Id 2>$null
        }
    }
    Start-Sleep -Seconds 2
}

What shipped today (already merged, no follow-up needed)

  • spirelens #161 — issue-agent observability: timeout-minutes on every step, BEGIN/END group logging in prep scripts, run-link comment on issue at claim-issue time, utf8NoBOM consistency.
  • tank-operator #34 — mcp-github write-surface redesign: dropped caller-supplied SHAs from create_branch / create_or_update_file / delete_file; added commit_to_branch. Eliminates the "stale base SHA" PR-revert footgun by resolving refs server-side at call time. Memory: never git push from session pods, all GitHub mutation via these MCP tools.
  • tank-operator #39 — mcp-github logs tooling: added list_workflow_run_jobs + get_workflow_job_logs. This is what let me read the prep-host log from chat instead of asking you to RDP and paste.

Pickup checklist for tomorrow

  • Confirm runner identity / session context on PC-user (the open-question #1 above).
  • Ship the Get-Process fix (single commit_to_branch call: prepare-issue-agent-job.ps1 + restart-sts2.ps1).
  • Re-trigger #142 Akabeko by labeling with issue-agent. Verify prep-host completes in seconds.
  • If still hangs: add wall-clock timeout via Start-ThreadJob + Wait-Job -Timeout 30 around the kill block.
Paused for the night, picking up tomorrow. Captures everything we figured out so future-me / future-Claude doesn't re-do the diagnosis. ## Symptom `Prepare issue-agent host` step in the issue-agent workflow hangs on the `nelsonpc-user` runner inside `Stop existing STS2 processes` (the `Get-CimInstance Win32_Process | … | Stop-Process` block in `.github/scripts/prepare-issue-agent-job.ps1`). Step rides the `timeout-minutes: 10` cap to the end and fails. Reproducible across at least three runs: - [25090457215](https://github.com/nelsong6/spirelens/actions/runs/25090457215) — 38 min before user-cancel (pre-observability) - [25093500782](https://github.com/nelsong6/spirelens/actions/runs/25093500782) — ~12 min before user-cancel - [25094309559](https://github.com/nelsong6/spirelens/actions/runs/25094309559/job/73527361164) — exactly 10 min, hit the new step timeout. Last log line is the BEGIN of `Stop existing STS2 processes`, then ten minutes of silence. **Game wasn't even running on the host** — so the foreach iterates zero times and the only thing that *can* hang is `Get-CimInstance Win32_Process` itself. ## What we ruled out - **Not the Stop-Process call.** Game wasn't running, so foreach is empty. - **Not WMI fundamentally broken on the host.** User ran `Get-CimInstance Win32_Process` interactively on PC-user; it returned fine. - **Not introduced by my observability PR (#161).** The Stop-Process block is unchanged code shape since `2fc2a67` (your commit, 2026-04-26). #161 just wrapped it in `Invoke-LoggedStep`. ## Likely cause **Runner context vs interactive context difference.** WMI / DCOM behaves differently when called from a service / Session 0 / non-interactive shell vs an interactive desktop. Some providers stall on impersonation / message-pump waits that don't exist in the runner's session. Endpoint-protection products sometimes inspect WMI calls from background processes with extra scrutiny that turns into a stall. Important contributing factor: **#159 migrated `shell: powershell` → `shell: pwsh`.** Pre-#159, this exact code ran on Windows PowerShell 5.1 (DCOM transport, .NET Framework). Successful runs existed in that window (e.g. PR #155 Pocketwatch at 01:53Z on 2026-04-29). Post-#159, `Get-CimInstance` runs under PS 7 / .NET 7+ / different defaults — which exposed whatever runner-context fragility was already latent. ## Open questions for tomorrow 1. **What user / context does the GH Actions runner run as on PC-user?** If it's installed as a Windows service (`services.msc` → look for `actions.runner.*`), service-context WMI is a well-known stall source. This is the single biggest "what changed" answer. 2. Does the same code shape hang on `nelsonlaptop`? (All the recent failures were on PC-user; laptop's pwsh-availability fix is separate.) ## Proposed fix (~90% confidence) Replace `Get-CimInstance Win32_Process` with `Get-Process -Name 'SlayTheSpire2','crashpad_handler'` in the kill block. `Get-Process` calls `NtQuerySystemInformation` directly — no WMI / DCOM / impersonation involved, behaves identically in interactive and service sessions. Same shape exists in `.github/scripts/restart-sts2.ps1` (`Get-Sts2Processes` helper) — should get the same treatment in one PR. Belt-and-suspenders for the kill itself: add `WaitForExit(5000)` per process and escalate to `taskkill /F /T /PID` if Stop-Process didn't terminate within the budget. Doesn't address the actual hang (which is in enumeration), but hardens the kill against legitimately wedged STS2 processes. Sketch: ```powershell Invoke-LoggedStep -Name 'Stop existing STS2 processes' -Body { $procs = Get-Process -ErrorAction SilentlyContinue -Name 'SlayTheSpire2','crashpad_handler' | Where-Object { try { $_.MainModule.FileName.StartsWith($gameDir.TrimEnd('\') + '\', [System.StringComparison]::OrdinalIgnoreCase) } catch { $false } } foreach ($p in $procs) { Write-Host "Stopping $($p.Name) pid=$($p.Id)" try { Stop-Process -Id $p.Id -Force -ErrorAction Stop; $p.WaitForExit(5000) | Out-Null } catch {} if (-not $p.HasExited) { Write-Warning "Stop-Process didn't kill $($p.Name) pid=$($p.Id) within 5s; escalating to taskkill" & taskkill.exe /F /T /PID $p.Id 2>$null } } Start-Sleep -Seconds 2 } ``` ## What shipped today (already merged, no follow-up needed) - spirelens **#161** — issue-agent observability: timeout-minutes on every step, BEGIN/END group logging in prep scripts, run-link comment on issue at claim-issue time, utf8NoBOM consistency. - tank-operator **#34** — mcp-github write-surface redesign: dropped caller-supplied SHAs from `create_branch` / `create_or_update_file` / `delete_file`; added `commit_to_branch`. Eliminates the "stale base SHA" PR-revert footgun by resolving refs server-side at call time. Memory: never `git push` from session pods, all GitHub mutation via these MCP tools. - tank-operator **#39** — mcp-github logs tooling: added `list_workflow_run_jobs` + `get_workflow_job_logs`. This is what let me read the prep-host log from chat instead of asking you to RDP and paste. ## Pickup checklist for tomorrow - [ ] Confirm runner identity / session context on PC-user (the open-question #1 above). - [ ] Ship the Get-Process fix (single `commit_to_branch` call: `prepare-issue-agent-job.ps1` + `restart-sts2.ps1`). - [ ] Re-trigger #142 Akabeko by labeling with `issue-agent`. Verify prep-host completes in seconds. - [ ] If still hangs: add wall-clock timeout via `Start-ThreadJob` + `Wait-Job -Timeout 30` around the kill block.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/spirelens#162
No description provided.