Repository navigation
fix(local-ai): stop a stalled llama-server health body at the startup budget - #1627
Conversation
… budget The health read now uses the HttpClient timeout after the headers arrive. Startup cancels that probe when the startup budget or service shutdown fires, including automatic restart. Validation: ./build.ps1 exit 0. Shared 4225 passed, 33 skipped. Tray 3893 passed. Local AI and llama client tests 122 passed. Signed-off-by: Sebastien Tardif <[email protected]>
|
🦞👀 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 maintainer review before merge. Reviewed October 6, 2026, 12:15 AM ET / 04:15 UTC (Revision 6). ClawSweeper reviewWhat this changesThe PR bounds Local AI health and model-response body reads, cancels stalled startup probes at the startup budget or disposal, and adds timeout regression coverage. Merge readiness✅ Ready for maintainer review This PR remains useful: neither pinned main nor the latest release bounds stalled response bodies. No introduced blocking defect was found, and the supplied production-path transport proof is sufficient. Priority: P2 Review scores
Verification
How this fits togetherLocal AI starts and monitors a managed llama-server process. Loopback HTTP health and model checks determine whether its endpoint is ready for Gateway routing. flowchart TD
A[Local AI start or restart] --> B[Managed server launch]
B --> C[Loopback health and model checks]
D[Startup budget or disposal] --> C
C --> E{Ready before cancellation}
E -->|Yes| F[Publish healthy endpoint]
E -->|No| G[Withdraw route and clean up]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep bounded body reads and startup cancellation within the existing Local AI owners while preserving endpoint ownership and cleanup behavior. Do we have a high-confidence way to reproduce the issue? Yes: main's response-body reads can stall after headers without a deadline, and the inspected loopback scenario directly exercises that path. This review did not execute a failing main reproduction. Is this the best way to solve the issue? Yes: linked cancellation extends the existing timeout and startup-budget behavior without introducing another runtime owner or configuration surface. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d53b5ab80664. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
LlamaServerRuntimeService drives LlamaServerClient over SocketsHttpHandler against a TcpListener that writes HTTP 200 headers and then holds the body. Startup ends at the budget. Dispose returns while that read is still open. Signed-off-by: Sebastien Tardif <[email protected]>
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 8821d6fc-e607-4ceb-a29f-66bce3a8c899
Synchronize disposal with probe entry, arm shutdown failure at process creation, and isolate the startup budget from the HTTP client timeout. Integrates main through d53b5ab without changing the contributor production patch. Validation: full ARM64 build passed; Shared 4232 passed/36 skipped; Tray 3899 passed; focused Local AI and llama 167 passed/5 skipped. Real transport startup 1026 ms and dispose 1 ms. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 8821d6fc-e607-4ceb-a29f-66bce3a8c899
|
Maintainer closeout is blocked, not merged. Current head |
|
Bounded recovery classification: the failing migration test, codec, and both invoked PowerShell scripts are blob-identical to current main |
What Problem This Solves
A llama-server health or model response that sends headers and never finishes its body can outlive the 3-second client timeout. Automatic restart can then retain the Local AI operation gate, blocking shutdown.
User Impact
Body reads are bounded independently of
ResponseHeadersRead. Startup uses its existing budget, and service disposal cancels an in-flight startup probe. Existing timeout/cancellation cleanup and endpoint ownership are preserved.Why This Change Was Made
HttpClient.Timeoutstops covering the response body afterResponseHeadersReadreturns. The previous startup loop checked elapsed time only between probes, and automatic restart usedCancellationToken.None.Evidence
Current head:
94b5af1d696b6e1dc156741b84b536cc61772129.Validated tree:
d4a1ff707c0d56feb8cb1aedb85f657754fd2d3c.Integrated main:
d53b5ab8066443275e7a0827fc218b2f58f532c9.SebTardif's original implementation commits are retained. Both modified production files are byte-identical to
bccab258; the maintainer follow-up changes only tests. It replaces an unreachable probe-entry wait with a TCS, arms simulated shutdown failure at process construction rather than racing a 2 ms timer, and makes the real HTTP client timeout longer than the startup budget.Change Type
Scope
Required proof pools
none: the changed behavior is a loopback HTTP read and an in-process startup budget. No UI, installer, WSL path, or GPU inference behavior changed.Validation
Windows ARM64, isolated worktree,
OPENCLAW_REPO_ROOTset to that worktree andOPENCLAW_TRAY_DATA_DIRset to a session-specific directory. Test projects were built first so--no-restorecould not silently no-op. These commands ran against the exact tree committed as94b5af1d:.\build.ps1dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restoredotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restoredotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --no-restore --filter 'FullyQualifiedName~LocalAi|FullyQualifiedName~Llama'No failed local validation command was retried. The five focused skips are existing symlink/cross-volume prerequisite cases, not timeout proofs. All changed timeout/disposal tests executed and passed. Baseline and after-change TRX/logs are retained in the maintainer session artifacts.
Current-head hosted CI: run 37410253309, attempt 2 succeeded for
94b5af1d; required CI Gate 112104797512 passed. Core results: Shared 4,267 passed/1 skipped, Connection 1,565 passed/1 skipped, WinNode CLI 129 passed. Hosted Tray 3,899 passed; setup, integration and all three E2E jobs also succeeded. UI/release jobs were classification-skipped and are not claimed as executed.Classified recovery, not a hidden retry: Attempt 1 failed one unchanged migration theory,
CleanupScript_CompletedReceiptPreservesFilesWithoutCallingWsl(null, 10, true): inner preservation watchdog exceeded 90 seconds and root script exceeded 120 seconds. The test, codec, and both scripts are blob-identical to main. Fresh isolated execution passed all five theory cases, including the failed case in 1.3335 seconds. One coordinator-authorizedgh run rerun 37410253309 --failedwas performed on the unchanged SHA; the same case passed hosted in 14 seconds. Attempt 1 logs/TRX remain preserved. The exact underlying scheduling/compilation/filesystem cause is unknown, and no timeout inflation or unrelated edits were made.Real behavior proof
LlamaServerRuntimeServicedrives the productionLlamaServerClientandSocketsHttpHandleragainst a real loopbackTcpListenerthat writes HTTP 200 headers and keeps its response incomplete.Local current-tree output:
Current-head hosted CI independently recorded startup 1016 ms and disposal 0 ms at millisecond resolution.
The startup test now uses a 30-second HTTP client timeout against a 1-second startup budget. It asserts headers were sent, the server remains stalled, the runtime reports startup timeout within eight seconds, and the fake managed process was stopped. Thus the independent client timeout cannot explain the result. The fake-probe disposal test explicitly waits for probe entry and completes locally in 27 ms, replacing the previous ineffective five-second polling wait.
Limits / not verified: The transport is real; process ownership and endpoint lifecycle are test substitutes. Header transmission is observed server-side, not an instrumented client body-read entry. This does not claim native child termination, real Gateway withdrawal, packaged llama-server execution, tray UI proof, or GPU inference. The potential 2 ms test race was verified in source but did not fail during the single baseline run.
Review
Independent bounded rubber-duck reviews used Claude Opus 5.5 (
high) and GPT-6 Astra (high,long_context). Both found no introduced production blocker. Their test findings were source-verified before the approved repairs:GPT-6 Astra re-reviewed only the test follow-up and found no issues. Pre-launch lifetime and additional restart/publication coverage limitations were not broadened into unrelated changes.
Security Impact
No new permissions, credentials, network endpoints, command surface, or data access.
Compatibility and Migration
Backward-compatible. No configuration or stored-data migration.
Review Conversations
No unresolved inline review threads at final maintainer review. The original author's evidence remains documented in PR history; current validation above supersedes it for this follow-up.