Skip to content

fix(local-ai): stop a stalled llama-server health body at the startup budget - #1627

Merged
shanselman merged 4 commits into
openclaw:mainfrom
SebTardif:fix/f116-llama-health-body-timeout
Oct 6, 2026
Merged

shanselman merged 4 commits into
openclaw:mainfrom
SebTardif:fix/f116-llama-health-body-timeout

Conversation

@SebTardif

@SebTardif SebTardif commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

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.Timeout stops covering the response body after ResponseHeadersRead returns. The previous startup loop checked elapsed time only between probes, and automatic restart used CancellationToken.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

  • Bug fix
  • Tests or validation

Scope

  • Gateway, connection, or pairing
  • Tests, CI, or docs

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_ROOT set to that worktree and OPENCLAW_TRAY_DATA_DIR set to a session-specific directory. Test projects were built first so --no-restore could not silently no-op. These commands ran against the exact tree committed as 94b5af1d:

Command Result
.\build.ps1 Exit 0; full ARM64 build
dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore 4,232 passed, 36 skipped, 0 failed
dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore 3,899 passed, 0 skipped, 0 failed
dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --no-restore --filter 'FullyQualifiedName~LocalAi|FullyQualifiedName~Llama' 167 passed, 5 skipped, 0 failed

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-authorized gh run rerun 37410253309 --failed was 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

LlamaServerRuntimeService drives the production LlamaServerClient and SocketsHttpHandler against a real loopback TcpListener that writes HTTP 200 headers and keeps its response incomplete.

Local current-tree output:

real-transport startup state=Failed elapsed_ms=1026 detail=The local AI router did not become healthy before the startup timeout.
real-transport dispose elapsed_ms=1

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:

Finding Opus 5.5 GPT-6 Astra Consensus / fix confidence
Unreachable fake probe-entry signal MEDIUM LOW Both; 99%, fixed
Real timer races 2 ms fake-clock failure injection MEDIUM-LOW not flagged One model; 95%, fixed
400 ms client timeout obscures 1 s startup-budget proof not flagged LOW One model; 95%, fixed

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.

… 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]>
@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 4, 2026
@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 12:15 AM ET / 04:15 UTC (Revision 6).

ClawSweeper review

What this changes

The 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
Reviewed head: 94b5af1d696b6e1dc156741b84b536cc61772129

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct repair with strong scoped transport proof and reported required validation.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Recorded Windows ARM64 output exercises the production startup service and real HTTP transport against an incomplete loopback response, observing startup-budget failure at 1026 ms and disposal at 1 ms. Process and endpoint lifecycle substitutes limit the claim to transport cancellation and runtime coordination. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Recorded Windows ARM64 output exercises the production startup service and real HTTP transport against an incomplete loopback response, observing startup-budget failure at 1026 ms and disposal at 1 ms. Process and endpoint lifecycle substitutes limit the claim to transport cancellation and runtime coordination. No stored-data contract changes.
Evidence reviewed 8 items Pinned introduced change: The verified main-to-head delta contains only two Local AI production files and two test files. Review covered the introduced hunks and surrounding startup, restart, cancellation, and disposal paths.
Main still needs the repair: Main's body reader passes only caller cancellation to stream reads after ResponseHeadersRead. Its startup loop checks elapsed time between probes, so an incomplete body can retain the operation gate.
Latest release check: The v2026.9.4 source also reads the response stream using caller cancellation without an independent body deadline; the requested repair is not already available there.
Findings None None.
Security None None.

How this fits together

Local 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]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test LOC production +26 net; tests +285 net Production growth is justified by cancellation ownership and body deadlines; most added code provides regression and real-transport coverage.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded Local AI startup and shutdown reliability repair, with no evidence of a broader urgent regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Recorded Windows ARM64 output exercises the production startup service and real HTTP transport against an incomplete loopback response, observing startup-budget failure at 1026 ms and disposal at 1 ms. Process and endpoint lifecycle substitutes limit the claim to transport cancellation and runtime coordination. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded Windows ARM64 output exercises the production startup service and real HTTP transport against an incomplete loopback response, observing startup-budget failure at 1026 ms and disposal at 1 ms. Process and endpoint lifecycle substitutes limit the claim to transport cancellation and runtime coordination. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • shanselman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Joel: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Dallin Romney: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-10-04T03:00:50.489Z sha f89b7e7 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-04T03:28:30.074Z sha bccab25 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-06T03:31:58.296Z sha bccab25 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-06T03:39:26.704Z sha bccab25 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-06T03:55:56.033Z sha 94b5af1 :: needs maintainer review before merge. :: none

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]>
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Oct 4, 2026
@shanselman shanselman added status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. and removed status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. labels Oct 6, 2026
shanselman and others added 2 commits October 5, 2026 20:35
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
@shanselman

Copy link
Copy Markdown
Collaborator

Maintainer closeout is blocked, not merged. Current head 94b5af1d696b6e1dc156741b84b536cc61772129, CI run 37410253309 attempt 1, failed the required CI Gate. The single Connection failure in Core and CLI job 112097053126 is MigrationRecordTests.CleanupScript_CompletedReceiptPreservesFilesWithoutCallingWsl(parentShare: null, expectedExit: 10, clockRollback: True): migration script exceeded 120 seconds; nested preservation check exceeded 90 seconds and exited 2. Connection results: 1564 passed, 1 failed, 1 skipped. This test is unchanged by this PR. Local full build, Shared, Tray, focused Local AI tests, and real loopback timeout proof all passed as recorded in the description; hosted Tray and all three E2E jobs also passed. Exact logs, summary, and core test artifact are preserved for the coordinator CI investigation. No CI rerun, protection bypass, or unrelated fix was attempted.

@shanselman shanselman added status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. and removed status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. labels Oct 6, 2026
@shanselman

Copy link
Copy Markdown
Collaborator

Bounded recovery classification: the failing migration test, codec, and both invoked PowerShell scripts are blob-identical to current main d53b5ab8; no newer main fix exists. The exact (null, 10, true) theory passed locally in 1.3335 seconds with fresh isolated fixture directories; all five theory cases passed. The original-head hosted run also passed this case in 6 seconds. Source history 01589702 documents an existing runner-sensitive subprocess/file-write timeout in this fixture. Attempt 1 directly records the inner 90-second watchdog and outer 120-second deadline; it does not identify whether compilation, AV, filesystem, or scheduling caused the stall. Classifying this as an unrelated migration subprocess timeout, not a llama regression. Per coordinator authorization, making exactly one failed-job rerun of the unchanged head 94b5af1d. The failed first attempt and its artifacts remain evidence; no timeout changes, branch retrigger, or protection bypass.

@shanselman
shanselman merged commit b1a41be into openclaw:main Oct 6, 2026
43 of 45 checks passed
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Oct 6, 2026
@SebTardif
SebTardif deleted the fix/f116-llama-health-body-timeout branch October 7, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants