diff --git a/scripts/e2e/parallels/windows-smoke.ts b/scripts/e2e/parallels/windows-smoke.ts index 80542da8dad..9d92ccf1efa 100755 --- a/scripts/e2e/parallels/windows-smoke.ts +++ b/scripts/e2e/parallels/windows-smoke.ts @@ -33,7 +33,7 @@ import { WindowsGuest } from "./guest-transports.ts"; import { runSmokeLane, type SmokeLane, type SmokeLaneStatus } from "./lane-runner.ts"; import { waitForVmStatus } from "./parallels-vm.ts"; import { PhaseRunner } from "./phase-runner.ts"; -import { encodePowerShell, psArray, psSingleQuote, windowsOpenClawResolver } from "./powershell.ts"; +import { encodePowerShell, psSingleQuote, windowsOpenClawResolver } from "./powershell.ts"; import { ensureGuestGit, prepareMinGitZip } from "./windows-git.ts"; interface WindowsOptions { @@ -891,27 +891,40 @@ Invoke-OpenClaw config set agents.defaults.skipBootstrap true --strict-json if ($LASTEXITCODE -ne 0) { throw "config set failed" } Invoke-OpenClaw config set tools.profile minimal if ($LASTEXITCODE -ne 0) { throw "tools profile config set failed" } -$sessionPath = Join-Path $env:USERPROFILE '.openclaw\\agents\\main\\sessions\\parallels-windows-smoke.jsonl' -Remove-Item $sessionPath -Force -ErrorAction SilentlyContinue ${windowsAgentWorkspaceScript("Parallels Windows smoke test assistant.")} Set-Item -Path ('Env:' + ${psSingleQuote(this.auth.apiKeyEnv)}) -Value ${psSingleQuote(this.auth.apiKeyValue)} -$args = ${psArray([ - "agent", - "--local", - "--agent", - "main", - "--session-id", - "parallels-windows-smoke", - "--message", - "Reply with exact ASCII text OK only.", - "--thinking", - "minimal", - "--json", - ])} -$output = Invoke-OpenClaw @args 2>&1 -if ($null -ne $output) { $output | ForEach-Object { $_ } } -if ($LASTEXITCODE -ne 0) { throw "agent failed with exit code $LASTEXITCODE" } -if (($output | Out-String) -notmatch '"finalAssistant(Raw|Visible)Text":\\s*"OK"') { throw 'openclaw agent finished without OK response' }`, +$agentOk = $false +for ($attempt = 1; $attempt -le 2; $attempt++) { + $sessionId = if ($attempt -eq 1) { 'parallels-windows-smoke' } else { "parallels-windows-smoke-retry-$attempt" } + $sessionsDir = Join-Path $env:USERPROFILE '.openclaw\\agents\\main\\sessions' + $sessionPath = Join-Path $sessionsDir "$sessionId.jsonl" + Remove-Item $sessionPath -Force -ErrorAction SilentlyContinue + $args = @( + 'agent', + '--local', + '--agent', + 'main', + '--session-id', + $sessionId, + '--message', + 'Reply with exact ASCII text OK only.', + '--thinking', + 'minimal', + '--json' + ) + $output = Invoke-OpenClaw @args 2>&1 + if ($null -ne $output) { $output | ForEach-Object { $_ } } + if ($LASTEXITCODE -ne 0) { throw "agent failed with exit code $LASTEXITCODE" } + if (($output | Out-String) -match '"finalAssistant(Raw|Visible)Text":\\s*"OK"') { + $agentOk = $true + break + } + if ($attempt -lt 2) { + Write-Host "agent turn attempt $attempt finished without OK response; retrying" + Start-Sleep -Seconds 3 + } +} +if (-not $agentOk) { throw 'openclaw agent finished without OK response' }`, Number(process.env.OPENCLAW_PARALLELS_WINDOWS_AGENT_TIMEOUT_S || 900) * 1000, ); } diff --git a/test/scripts/parallels-smoke-model.test.ts b/test/scripts/parallels-smoke-model.test.ts index 65b5166a53a..4b1d9d9b500 100644 --- a/test/scripts/parallels-smoke-model.test.ts +++ b/test/scripts/parallels-smoke-model.test.ts @@ -452,9 +452,10 @@ console.log(JSON.stringify(result)); expect(script).toContain('guestPowerShellBackground(\n "agent-turn"'); expect(script).toContain("OPENCLAW_PARALLELS_WINDOWS_AGENT_TIMEOUT_S"); expect(script).toContain("finalAssistant(Raw|Visible)Text"); + expect(script).toContain("parallels-windows-smoke-retry-$attempt"); expect(script).not.toContain("$config.models.providers"); expect(script).not.toContain("timeoutSeconds = 300"); - expect(script).toContain("parallels-windows-smoke.jsonl"); + expect(script).toContain('"$sessionId.jsonl"'); }); it("waits through transient Windows restoring state before VM operations", () => {