Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. Reviewed September 9, 2026, 8:19 PM ET / September 10, 2026, 00:19 UTC (Revision 6). ClawSweeper reviewWhat this changesKeeps Local AI selected during endpoint cycles, reuses its previous available port, and adds terminal cleanup and regression tests. Merge readiness⛔ Blocked before merge - 5 items remain This remains useful and is not implemented on current main. Earlier cleanup fixes are present, but the previously reported interrupted-withdrawal defect remains, and the maintainer-requested restart proof is outstanding. Priority: P1 Review scores
Verification
How this fits togetherThe Windows companion starts and monitors the local llama-server process. Its gateway coordinator updates the managed WSL gateway’s provider and model selection so agent requests reach that local endpoint. flowchart TD
A[Companion startup or restart] --> B[Inspect saved endpoint and listeners]
B --> C{Previous port available?}
C -->|Yes| D[Retain route and reuse port]
C -->|No| E[Withdraw provider for endpoint cycle]
D --> F[Start and verify local server]
E --> F
F -->|Healthy| G[Publish route for gateway requests]
F -->|Terminal failure| H[Restore terminal routing]
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Preserve local selection through recoverable cycles, restore terminal routing on every abandoned cycle, and verify existing-install recovery through a real gateway request. Do we have a high-confidence way to reproduce the issue? Yes, from source: interrupt or fail the verification read after EndpointCycle removes the provider on a no-fallback install; terminal cleanup is bypassed. This review did not execute that regression. Is this the best way to solve the issue? Yes in direction: the existing lifecycle and coordinator are the right owners, and real fallback preferences remain preserved. The implementation still needs complete handling of partially completed withdrawal. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3edc9b1b5b6e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
@clawsweeper provided proof |
|
@clawsweeper review again and provide feedback on proof status. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper rereview...what's the issue dude? |
|
🦞👀 I queued a lightweight read-only assist pass. It will post a separate answer comment and will not edit the durable ClawSweeper review comment or trigger close, merge, repair, label, or branch changes. Request: rereview...what's the issue dude? |
|
ClawSweeper assist: The remaining issue is not the screenshot itself; it’s that the prior review identified two P1 terminal-failure paths that may still leave retained Local AI routing active:
The supplied screenshots are evidence of a fresh install’s first request reaching Local AI, but they do not demonstrate the existing-install restart path or terminal recovery paths on the current head. Evidence:
Suggested next action: For a full current-head correctness assessment, request Source: #1321 (comment) |
On every companion start, EnsureStartedCoreAsync quiesced the gateway
route, started llama-server, probed it, and only then republished. With
no prior model to restore, quiesce unset agents.defaults.model.primary
outright -- and an absent primary is not "no routing", it is the
gateway's built-in default:
parseModelRef(... ?? "gpt-5.6-sol", "openai", ...)
So any prompt sent during that window was dispatched to openai and
failed with ProviderAuthError / missing-provider-auth on a Local
AI-only install. The window was ~10s and reproduced on every launch,
because requestedPort is 0 and the OS-assigned port made the previously
published baseUrl stale by construction.
Retain the managed primary across an endpoint cycle. QuiesceAsync now
takes a LocalAiQuiesceReason: EndpointCycle keeps llamacpp/<alias> in
place so a mid-cycle request fails as Local AI rather than as an
unrelated provider, while Teardown (stop, shutdown, failed publish)
still restores whatever preceded Local AI.
Reuse the last verified port when it is free, and skip the quiesce
entirely when the published route already names the port about to be
bound. The normal restart now performs zero config writes; PublishAsync
re-verifies and no-ops. A route is only withdrawn when the endpoint
genuinely moves.
Deciding the port before touching routing exposed a latent bug: the
port-conflict and ownership-unknown paths returned Conflict without
withdrawing the published route, leaving the gateway aimed at a port a
foreign process owns. FailStartupAsync now takes a route to withdraw,
and every startup-failure path passes it when one was left standing.
Refs openclaw#1293
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
ClawSweeper review of PR openclaw#1321 identified two terminal lifecycle paths that could leave the gateway configured for a Local AI provider nothing would serve: 1. With a retained route (last-verified port reuse), a process-launch exception, immediate child exit, probe failure, or cancellation hit the catch handlers in EnsureStartedCoreAsync, which only disposed the child. The gateway kept routing to the retained port with no listener. Both catch paths now withdraw the retained route with teardown semantics before the child's listener disappears. 2. HandleManagedProcessExitedAsync always quiesced with EndpointCycle semantics even when automatic restart attempts were exhausted, so the managed primary stayed selected with its provider absent and no republish to follow. The exit handler now picks the quiesce reason from whether a restart will actually run: EndpointCycle for a pending restart, Teardown once the retry budget is spent. FailStartupAsync also now withdraws a retained route before disposing the child (previously after), matching the lifecycle contract that managed routing is removed before a listener can disappear. Tests: three new regression tests cover launch exception, retry exhaustion, and cancellation with a retained route; the publish-failure and startup-timeout tests were updated for the withdraw-before-stop ordering. Validation: build.ps1 clean; OpenClaw.Connection.Tests 724/724, OpenClaw.Tray.Tests 2864/2864, OpenClaw.SetupEngine.Tests LocalAiGpu 8/8 pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
a523555 to
7a15b10
Compare
|
@clawsweeper re-review Both P1 findings from the previous review are fixed on the new head 7a15b10:
FailStartupAsync also withdraws before disposing the child, matching the remove-routing-before-listener-disappears contract. Proof status:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Maintainer verdict: HOLD_FOR_AUTHOR on current head \7a15b100\ (take confidence 40%, recommendation confidence 99%). The direction is valuable, but two terminal cleanup gaps remain: cancellation during preset preparation can leave retained routing published, and a failed port-relocation attempt can leave the managed primary selected after the provider is removed. Please repair both paths, add focused regressions, and provide current-head \windows-wsl-dgx-blackwell\ proof that an existing-install restart reaches a healthy endpoint and serves a gateway request. The current CI Gate failure is in unchanged \SystemRun_Where_ReturnsExpectedOutput\ infrastructure and is not the reason for this hold. |
Co-authored-by: Copilot App <[email protected]> Copilot-Session: d0dbb47f-7bb0-4294-bda6-60b2a8b5fc55
|
Superseded by #1390 (fix(local-ai): keep routing safe across endpoint restarts), rebuilt from current main with terminal cleanup, retry-exhaustion, cancellation, setup rollback, and UI recovery coverage. |
* fix(local-ai): stop routing to OpenAI while the endpoint restarts
On every companion start, EnsureStartedCoreAsync quiesced the gateway
route, started llama-server, probed it, and only then republished. With
no prior model to restore, quiesce unset agents.defaults.model.primary
outright -- and an absent primary is not "no routing", it is the
gateway's built-in default:
parseModelRef(... ?? "gpt-5.6-sol", "openai", ...)
So any prompt sent during that window was dispatched to openai and
failed with ProviderAuthError / missing-provider-auth on a Local
AI-only install. The window was ~10s and reproduced on every launch,
because requestedPort is 0 and the OS-assigned port made the previously
published baseUrl stale by construction.
Retain the managed primary across an endpoint cycle. QuiesceAsync now
takes a LocalAiQuiesceReason: EndpointCycle keeps llamacpp/<alias> in
place so a mid-cycle request fails as Local AI rather than as an
unrelated provider, while Teardown (stop, shutdown, failed publish)
still restores whatever preceded Local AI.
Reuse the last verified port when it is free, and skip the quiesce
entirely when the published route already names the port about to be
bound. The normal restart now performs zero config writes; PublishAsync
re-verifies and no-ops. A route is only withdrawn when the endpoint
genuinely moves.
Deciding the port before touching routing exposed a latent bug: the
port-conflict and ownership-unknown paths returned Conflict without
withdrawing the published route, leaving the gateway aimed at a port a
foreign process owns. FailStartupAsync now takes a route to withdraw,
and every startup-failure path passes it when one was left standing.
Refs #1293
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
* fix(local-ai): route terminal startup outcomes through teardown
ClawSweeper review of PR #1321 identified two terminal lifecycle paths
that could leave the gateway configured for a Local AI provider nothing
would serve:
1. With a retained route (last-verified port reuse), a process-launch
exception, immediate child exit, probe failure, or cancellation hit
the catch handlers in EnsureStartedCoreAsync, which only disposed the
child. The gateway kept routing to the retained port with no listener.
Both catch paths now withdraw the retained route with teardown
semantics before the child's listener disappears.
2. HandleManagedProcessExitedAsync always quiesced with EndpointCycle
semantics even when automatic restart attempts were exhausted, so the
managed primary stayed selected with its provider absent and no
republish to follow. The exit handler now picks the quiesce reason
from whether a restart will actually run: EndpointCycle for a pending
restart, Teardown once the retry budget is spent.
FailStartupAsync also now withdraws a retained route before disposing
the child (previously after), matching the lifecycle contract that
managed routing is removed before a listener can disappear.
Tests: three new regression tests cover launch exception, retry
exhaustion, and cancellation with a retained route; the publish-failure
and startup-timeout tests were updated for the withdraw-before-stop
ordering.
Validation: build.ps1 clean; OpenClaw.Connection.Tests 724/724,
OpenClaw.Tray.Tests 2864/2864, OpenClaw.SetupEngine.Tests
LocalAiGpu 8/8 pass.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
* fix(local-ai): teardown terminal restart failures
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: d0dbb47f-7bb0-4294-bda6-60b2a8b5fc55
* fix(local-ai): teardown interrupted endpoint cycles
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): keep routing safe across restarts
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): harden terminal restart cleanup
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): complete terminal cleanup retries
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): preserve restart privacy invariants
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): close interrupted lifecycle gaps
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* test(local-ai): assert refresh teardown
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): preserve explicit stop intent
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): expose failed cleanup recovery
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): preserve runtime on refresh cancellation
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): reconcile canceled and missing restarts
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): keep failed stops quiesced
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): keep preserved listeners stop-only
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): preserve pending route recovery
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): stop untrusted listeners on cleanup failure
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): honor stop during automatic retry
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): keep failed shutdown retryable
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* test(local-ai): consolidate unsafe startup coverage
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* test(local-ai): trim review-only commentary
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): complete final process disposal
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* docs(local-ai): tighten lifecycle comments
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* docs(local-ai): remove redundant routing comments
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): surface retained shutdown failures
Bound post-cancellation route recovery, publish retryable ownership when process shutdown fails, and cover teardown failure after retry exhaustion.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
* fix(local-ai): clarify interrupted route recovery
Make endpoint-cycle recovery state explicit and drive the manifest-lock cancellation test causally.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa
---------
Co-authored-by: Pedro Larroy <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Karen Lai <[email protected]>
Copilot-Session: d0dbb47f-7bb0-4294-bda6-60b2a8b5fc55
Copilot-Session: fe99977b-465c-4796-a6ae-436b4b11f6fa


Fixes the
missing-provider-auth/No API key found for provider "openai"failure on the first prompt after the companion starts, on a Local AI-only install.Refs #1293. Note that issue is filed as a gateway-side stale-reload/dispatch race; the root cause is actually in this repo, and the gateway behaved correctly throughout (detail).
Root cause
EnsureStartedCoreAsyncsequenced quiesce → start → probe → publish on every launch.QuiesceAsyncunsetsmodels.providers.llamacppand, whenGatewayFallbackModelisnull, unsetagents.defaults.model.primaryoutright.An absent primary is not "no routing" — the gateway resolves its built-in default:
So any prompt dispatched in that window went to
openaiand failed on a missing credential. From~/.openclaw/logs/config-audit.jsonlon a reproducing run:config unset agents.defaults.model.primaryconfig unset models.providers.llamacppconfig set --batch-file /dev/stdin(republishes provider + primary)with the failure landing at 01:26:15 — inside the ~9s hole. The window existed on every launch, not just after setup, because
requestedPortis0, so the OS assigns a new port each run and the previously publishedbaseUrlis stale by construction.Changes
1. Never leave the gateway without a primary model.
QuiesceAsynctakes aLocalAiQuiesceReason.EndpointCycleretains the managedllamacpp/<alias>primary, so a request that lands mid-cycle fails as Local AI rather than as an unrelated provider.Teardown(stop, shutdown, failed publish, uninstall) keeps the existing restore-or-unset behaviour, so a user with a real prior model still gets it back.2. Make the normal restart a no-op.
ResolvePlannedPortreuses the last verified port when free, so the published route stays valid and the quiesce is skipped entirely;PublishAsyncthen sees an exact match and no-ops. The common restart now performs zero config writes. A route is withdrawn only when the endpoint genuinely moves.3. Latent bug surfaced by (2). Deciding the port before touching routing revealed that the port-conflict and ownership-unknown paths returned
Conflictwithout withdrawing the published route, leaving the gateway aimed at a port a foreign process owns.FailStartupAsyncnow takes a route to withdraw, and every startup-failure path passes it when one was left standing.4. Terminal startup outcomes withdraw retained routing (ClawSweeper P1 findings). With a retained route, a process-launch exception, immediate child exit, or cancellation previously hit the catch handlers in
EnsureStartedCoreAsync, which only disposed the child — the gateway kept routing to the retained port with no listener. Both catch paths now withdraw the retained route withTeardownsemantics before the child's listener disappears.HandleManagedProcessExitedAsyncalso always quiesced withEndpointCyclesemantics even when automatic restart attempts were exhausted, leaving the managed primary selected with its provider absent; it now picks the reason from whether a restart will actually run (EndpointCyclefor a pending restart,Teardownonce the retry budget is spent).FailStartupAsyncwithdraws a retained route before disposing the child, matching the lifecycle contract that managed routing is removed before a listener can disappear.Tests
Six new tests from the first round, each failing on the old code:
Quiesce_EndpointCycleRetainsManagedPrimaryWhenNoFallbackExists— asserts nounsetof the primary pathQuiesce_EndpointCycleStillRestoresRealPriorModelPublish_AcceptsPrimaryRetainedByAnEndpointCycleRestart_ReusesLastVerifiedPortAndNeverWithdrawsThePublishedRoute— asserts no quiesce event at allRestart_WithdrawsStaleRouteWhenTheLastVerifiedPortIsTakenRestart_WithdrawsRetainedRouteWhenStartupNeverBecomesHealthyThree new regression tests for the terminal failure paths from the ClawSweeper review:
Restart_LaunchExceptionWithdrawsRetainedRouteAsTeardown— process-launch exception with a retained route withdraws it asTeardownRestart_ExhaustedAutomaticRestoresEndInTeardownNotEndpointCycle— first unexpected exit isEndpointCycle+ restart, the next exit (retry budget spent) isTeardownRestart_CancellationWithdrawsRetainedRouteBeforeDisposingChild— canceled startup withdraws the retained route before the child stopsThe publish-failure and startup-timeout tests were updated for the withdraw-before-stop ordering;
FakePlatformgained a yield mode andFakeProcessHostlaunch-exception/exit-trigger hooks so the terminal paths are exercised deterministically.Required proof pools
windows-wsl-dgx-blackwell: local AI managed runtime routing/restart behavior changed (this machine's RTX-class GPU hosts the llama-server runtime; GPU-specific detection did not change).Validation
All commands run on the current head (7a15b10), Windows 11 ARM64:
./build.ps1— all builds succeeded.dotnet test ./tests/OpenClaw.Connection.Tests/OpenClaw.Connection.Tests.csproj— 724 passed, 0 failed.dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj— 2864 passed, 0 failed.dotnet test ./tests/OpenClaw.SetupEngine.Tests/... --filter FullyQualifiedName~LocalAiGpu— 8 passed, 0 failed (focused Local AI GPU restart/endpooint policy tests).dotnet test ./tests/OpenClaw.Shared.Tests/...— 3940 passed, 3 failed; all 3 are pre-existing on the PR base with the diff stashed (ReadmeValidationTests.ReadmeAllowCommandsJsonExample_IsValidfails deterministically on the base commit;BoundedProcessWaitTests,PiperVoiceExtractionTests, andMarkdownParserFuzzTeststiming tests pass in isolation and only flake under full-suite parallel load). None touch this PR's subsystems.validate-mxc-e2e.ps1) not run: no changes to MXC,system.run,src/OpenClaw.Shared/Mxc, or setup/connect E2E paths.Real behavior proof
Unit-level (deterministic, current head): the three new terminal-path tests fail on the parent commit and pass on this head — they assert the exact lifecycle contract ClawSweeper required: launch exception →
quiesce:Teardownwith the retained route withdrawn and no child started; retry exhaustion → final exit isquiesce:Teardownwhile the earlier restart wasquiesce:EndpointCycle; cancellation →quiesce:Teardownordered before the child'sstop.Live gateway restart diagnostics (existing-install restart path): captured on this machine against the pre-existing OpenClawGateway-Dev WSL gateway and existing Local AI install (manifest endpoint
http://127.0.0.1:64133/v1, primaryllamacpp/qwen3.6-27b-mtp-q4-k-m):Restart_ReusesLastVerifiedPortAndNeverWithdrawsThePublishedRoute) in the live path.primary: llamacpp/qwen3.6-27b-mtp-q4-k-m,models.providers.llamacpp.baseUrl: http://127.0.0.1:64133/v1— the managed provider and primary remained published and untouched, so no OpenAI fallback window existed at any point.Not verified / blocked: the UI-visible chat round trip through the restarted endpoint could not be captured on this head. Every tray launch on this host (including with this PR's diff stashed and after a clean rebuild of the base commit) crashes in
Microsoft.UI.Input.dll(0xc0000602,EnableMouseInPointer) during WinUI startup before the UI surface appears — the crash reproduces identically on the PR base commit, so it is a pre-existing environment/SDK issue on this machine, not caused by this PR. The runtime path under the UI (managed llama-server lifecycle + gateway coordinator) is exercised by the isolated launches above and fully covered by the deterministic unit tests.🤖 Generated with Claude Code