Skip to content

fix: release stalled captured provider responses promptly - #130804

Merged
steipete merged 4 commits into
mainfrom
codex/lmstudio-response-release-r11
Aug 27, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/lmstudio-response-release-r11

Conversation

@steipete

@steipete steipete commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users discovering LM Studio models, reading live provider catalogs, or authenticating GitHub Copilot could wait for an unused error response body when HTTP capture retained a clone. Redirects could also stall before proceeding or reporting a missing/blocked destination.

Also fixes in-flight caller cancellation being lost when a guarded request supplies init.signal alongside a timeout, including native PDF requests. The caller signal must be selected before composing the deadline, rather than being replaced by its generated signal.

Why This Change Was Made

Cancellation of one branch of a cloned response can remain pending until the capture branch finishes. Unread-body cleanup now requests cancellation without waiting for that unrelated consumer. The guarded request owns a fresh abort controller for each redirect hop and ends only that hop before returning its dispatcher lease. This also bounds the abandoned transport rather than merely making the status error prompt.

The core cancellation helper remains the canonical internal flow; duplicate one-use LM Studio and Copilot helpers are removed. Custom fetch implementations still receive response cancellation even if they ignore abort signals. Caller cancellation and its reason work with and without a timeout; an explicit top-level signal retains precedence over init.signal. Redirect authorization, pooled sibling requests, and completed captures are preserved. The public release(): Promise<void> signature and the shipped generic dispatcher graceful-close API are unchanged; no config, dependency, or storage changes are included.

The guard's awaited redirect cancellation is traceable to #121687, commit f09a33c (2026-08-10; code/PR author and merger: @steipete). This identifies that guard regression, not a common origin for every affected provider helper.

User Impact

Known HTTP failures and redirects settle promptly while guarded abandoned requests release their transport. Other in-flight requests sharing the same dispatcher and caller signal remain usable. Copilot's unguarded authentication request keeps its existing timeout/capture limits; this change promises prompt typed authentication errors, not immediate closure of that separate capture stream.

Callers can also cancel an in-flight request that combines a request-option signal with a deadline. The native PDF path is a current-main example, not a claimed stable-release PDF regression.

Existing reader-cancellation-before-release paths in streaming wrappers and prefix readers remain separate follow-ups. This is not a claim that all capture or streaming cancellation paths are repaired.

Evidence

Reviewed corrective head: fe2cb3cd0f28a607a435699576c3c3a95639e598.

  • Full frozen before/after proof used owned localhost HTTP servers, the public runtime/catalog paths, the real SSRF guard and dispatcher, and actual capture with an in-memory sink. This is live HTTP boundary proof, not authenticated LM Studio or Copilot service testing; no user models, service configuration, or credentials were used.
  • LM Studio 503: original remained pending past the unchanged 500 ms observation deadline; final repaired runtime returned the correct reachable/503 result and observed the actual server-side socket close in 43 ms. Both runs left zero owned sockets/listeners.
  • Seven sibling HTTP cases: five original known-error/redirect cases waited beyond 1 second; all seven final repaired cases passed. Catalog 401, successful redirect, missing-location, and blocked-host outcomes took 34/6/2/3 ms with their abandoned sockets closed. The blocked destination received zero requests; cross-origin credentials remained stripped. Copilot 403 returned its typed recovery hint in 5 ms before fixture EOF. Catalog/Copilot 200 controls passed, with zero owned sockets/timers/listeners after cleanup.
  • Retained real TCP regression: original guard failed the 1-second release-and-close deadline; candidate passed. A held response on the same real pooled Agent and parent signal completed with its full capture, then a third request reused the dispatcher. The expanded six-case suite also proves caller signals with/without timeout and explicit top-level precedence. Before the producer fix, only init.signal plus timeout failed; afterward all six passed.
  • Actual native PDF public request to an owned localhost HTTP server: abort after the server sent a response prefix was ignored beyond 1 second before the producer fix. The final request rejected with the exact caller reason and closed its socket in 6 ms, leaving zero owned sockets/listeners. This proves in-flight cancellation, not an authenticated vendor request or a claim that client-side body reading had already begun.
  • 456 tests passed across 18 complete owner/sibling files, covering HTTP body handling, SSRF/redirects, real release, dispatcher pooling/runtime fetch, live catalogs, capture, LM Studio, Copilot, Ollama, Hugging Face, native PDF, DashScope, and WhatsApp media. After the final test-only reader correction below, 167 tests across four complete files passed again; these are overlapping reruns, not additional unique coverage. Formatting and targeted core type-aware lint passed. Fresh full-patch P0–P2 and independent source/proof review, including the final reader correction, found no actionable issues.
  • The first hosted run passed build and production/test types and executed the retained TCP test against the frozen pinned installation, but failed lint and exposed post-release signal assertions and incomplete Response fixtures. The corrections preserve admission-live/owned-release-aborted state, cleared timer ownership, byte caps, cancellation, and media payload/error assertions using real response streams; no production fallback or weaker lint rule was added.
  • The next full CI run at 9b9ab4a461529a1b4df9b38b268ea898b8de8d08 passed after one unchanged failed-job retry. Its first attempt had doctor process/hook timeouts amid broad 8–9× slowdown; the cause remains unknown, and the entire seven-group job plus gate passed on retry. The separate OpenGrep scan flagged five direct response reads in our owned test fixtures. Those reads now use the existing 32-byte bounded whole-body reader, with no new timer, truncation, suppression, or scan exclusion. Against the original guard, the modified tests still produced the four intended release/cancellation/redirect failures while 113 controls passed; restoring the candidate passed all 117, then the 167-test reader/guard scope.
  • The reader-correction head passed the separate OpenGrep scan, then full CI exposed a pre-existing portal test allocation race before the retained TCP group could run. A controlled second-bind reproduction kept the original collision assertion: after the first listener closed, an owned competitor claimed its port, reproducing the exact EADDRINUSE error instead of the expected ten-collision terminal error. This was an intra-case allocation-order proof, not a full-file or cross-test culprit claim. The two fixtures now hold an owned target, leave actual socket allocation at port zero, and inject only the one-shot reported address needed to exercise collision handling. All ten attempts, real listener shutdown, both bind hosts, and exact bounded HTTP forwarding remain proved. The complete portal service/proxy files passed 36 tests before and after, and targeted type-aware lint passed. No production retry or timeout was changed. Fresh full-patch P0–P2 and independent source/proof review, including this final test correction, found no actionable issues.
  • The separate portal proxy retry-page tests still cover HTTP 502. Their local probe-and-release target assumption at src/gateway/portals/portal-http-proxy.test.ts:513 is a named follow-up, not fixed here; the deterministic worker failure cases remain unchanged.
  • Final exact-head CI run passed on its first attempt: 147 jobs, 126 successful and 21 skipped, including the required gate, production/test types, and lint. The complete head inventory has no failed or pending checks; the two cancelled checks are ancillary label/dispatch runs. The precise OpenGrep scan also passed. The final hosted job executed all 15 portal service tests and all six retained TCP cases (68 ms) after the frozen dependency installation using the Undici 8.10.0 pin. This fulfills the latest completed ClawSweeper review's exact-head transport/CI rank-up request; its newer started-only review is not a completed verdict.
  • Local runtime used Undici 8.9.0. Local plugin lint stopped during declaration preparation on existing dependency mismatches, so no full local type/lint pass is claimed; the final hosted types/lint and pinned-transport checks above supply that required validation.
  • Runtime production LOC is net -2; the stale cron cleanup comment correction removes one further line. Total production +29/-32 (net -3); tests +526/-182 (net +344), including the focused LM fetch-test split, replacement of incomplete response fixtures, and portal allocation-fixture correction.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 27, 2026 07:48
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. 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. labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 5:53 AM ET / 09:53 UTC.

ClawSweeper review

What this changes

The branch makes unused captured HTTP response cleanup non-blocking and preserves caller cancellation when guarded fetch also applies a timeout.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this maintainer-owned PR open: the shared transport repair is coherent and has no actionable code finding, but exact-head validation against the pinned runtime is still incomplete.

Priority: P2
Reviewed head: fe2cb3cd0f28a607a435699576c3c3a95639e598

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused, net-negative transport repair has strong targeted coverage; successful exact-head runtime validation remains the material merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-associated PR is exempt from the external contributor proof gate; its body nevertheless records detailed owned-localhost transport evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-associated PR is exempt from the external contributor proof gate; its body nevertheless records detailed owned-localhost transport evidence.
Evidence reviewed 4 items Current-main behavior: Current main still awaits unread-body cancellation and only passes the top-level signal to the timeout helper, so it does not contain this PR's non-blocking cleanup or init-signal repair.
Changed owner boundary: The PR composes the caller signal before the timeout, owns an abort controller per redirect hop, then aborts only that hop and starts unread cleanup before returning the dispatcher lease.
Shared helper and sibling coverage: The shared cleanup helper now intentionally does not await a response tee, with focused tests for cloned responses, redirects, LM Studio errors, and a real local pooled-dispatcher scenario.
Findings None None.
Security None None.

Live Verification

Command: pnpm test src/infra/net/fetch-guard.release.test.ts

Result: PASS (completed)

$ node --import tsx scripts/test-projects.mts src/infra/net/fetch-guard.release.test.ts
[test] starting test/vitest/vitest.unit-fast.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130804-L0Lnyy/target

 ✓  unit-fast  src/infra/net/fetch-guard.release.test.ts (6 tests) 72ms

 Test Files  1 passed (1)
      Tests  6 passed (6)
   Start at  09:54:37
   Duration  1.64s (transform 1.03s, setup 86ms, import 1.35s, tests 72ms, environment 0ms)

[test] passed 1 Vitest shard in 11.55s

Assertions:

  • NOT OBSERVED expect_output: guarded request release — command exited successfully; expected output was not observed in the captured pane

How this fits together

Guarded fetch validates provider, catalog, and media URLs before dispatching them through pinned HTTP transports. Its response-release callback must clean up one request without stalling or interrupting other requests that share a dispatcher.

flowchart LR
  A[Provider or media caller] --> B[Guarded HTTP request]
  B --> C[URL and redirect validation]
  C --> D[Pinned dispatcher]
  D --> E[Captured response]
  E --> F[Release and cancellation]
  F --> G[Typed result or error]
Loading

Before merge

  • Resolve merge risk (P1) - The lifecycle change depends on Undici 8.10.0 abort and dispatcher-close behavior that could not be independently inspected here; the exact-head hosted checks remain incomplete.
  • Complete next step (P2) - This protected maintainer PR has no mechanical repair to dispatch; complete exact-head CI and maintainer review.
Agent review details

Security

None.

PR surface

Source -3, Tests +344. Total +341 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 5 29 32 -3
Tests 12 531 187 +344
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 560 219 +341

Review metrics

Metric Value Why it matters
Production versus test delta production +29/-32 (net -3); tests +526/-182 (net +344) The runtime repair is net-negative; most changed lines are focused regression and fixture coverage across transport and provider paths.

Merge-risk options

Maintainer options:

  1. Confirm the pinned transport behavior (recommended)
    Wait for exact-head CI to complete successfully, including the retained guarded-fetch TCP regression against the pinned Undici runtime.
  2. Pause for runtime evidence
    Pause the lifecycle change if the exact-head regression cannot validate abort and pooled-dispatcher behavior with the pinned dependency.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Require successful exact-head checks that include the guarded-fetch retained TCP regression.

Technical review

Best possible solution:

Retain the shared per-hop abort and non-blocking cleanup design, and land only after exact-head CI confirms the retained pooled-TCP regression with Undici 8.10.0.

Do we have a high-confidence way to reproduce the issue?

Yes: the added local HTTP and pooled-dispatcher regression encodes the stalled capture and caller-signal paths, though this read-only review did not execute it.

Is this the best way to solve the issue?

Yes, provisionally: repairing guarded fetch and using the shared cleanup helper removes provider-local duplication while preserving redirect and pooled-dispatcher ownership; exact-head runtime validation remains required.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against dd005e53866f.

Labels

Label justifications:

  • P2: The repair targets stalled provider, catalog, and redirect completion paths without evidence of a broad outage.
  • merge-risk: 🚨 availability: The patch changes abort and dispatcher-release ordering, which could otherwise interrupt or stall HTTP work.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-associated PR is exempt from the external contributor proof gate; its body nevertheless records detailed owned-localhost transport evidence.

Evidence

What I checked:

  • Current-main behavior: Current main still awaits unread-body cancellation and only passes the top-level signal to the timeout helper, so it does not contain this PR's non-blocking cleanup or init-signal repair. (src/infra/http-body.ts:15, dd005e53866f)
  • Changed owner boundary: The PR composes the caller signal before the timeout, owns an abort controller per redirect hop, then aborts only that hop and starts unread cleanup before returning the dispatcher lease. (src/infra/net/fetch-guard.ts:520, fe2cb3cd0f28)
  • Shared helper and sibling coverage: The shared cleanup helper now intentionally does not await a response tee, with focused tests for cloned responses, redirects, LM Studio errors, and a real local pooled-dispatcher scenario. (src/infra/http-body.response.test.ts:137, fe2cb3cd0f28)
  • Dependency contract limitation: The runtime directly uses Undici dispatchers and package metadata pins 8.10.0, but no installed Undici source was available in this read-only checkout and upstream access failed, preventing independent inspection of its abort/close contract. (package.json:2094, fe2cb3cd0f28)

Likely related people:

  • steipete: The supplied merged-history context links steipete to the guarded dispatcher work, and this PR continues that transport lifecycle surface. (role: recent guarded-dispatcher contributor; confidence: medium; commits: f09a33ce4124, fe2cb3cd0f28; files: src/infra/net/fetch-guard.ts, src/infra/net/pinned-dispatcher-pool.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let exact-head CI complete successfully, including the retained real TCP release regression against Undici 8.10.0.

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 (3 earlier review cycles)
  • reviewed 2026-08-27T07:56:34.339Z sha 20e5ffb :: needs maintainer review before merge. :: none
  • reviewed 2026-08-27T08:28:19.904Z sha 9b9ab4a :: needs maintainer review before merge. :: none
  • reviewed 2026-08-27T09:27:51.029Z sha 185c88c :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The corrected head also preserves caller cancellation when init.signal is combined with a timeout. This producer-side change has a failing/passing real TCP regression and a native PDF request over owned localhost HTTP; the updated body includes the exact proof and initial CI corrections. The complete final patch has 456 focused passing tests and clean independent/P0–P2 reviews. Fresh exact-head hosted checks remain required before landing.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@openclaw-barnacle openclaw-barnacle Bot added channel: whatsapp-web Channel integration: whatsapp-web agents Agent runtime and tooling extensions: huggingface labels Aug 27, 2026
@steipete
steipete merged commit d62f0b8 into main Aug 27, 2026
206 of 208 checks passed
@steipete
steipete deleted the codex/lmstudio-response-release-r11 branch August 27, 2026 10:09
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 28, 2026
…30804)

* fix: release stalled captured provider responses promptly

* fix: preserve caller cancellation through guarded request timeouts

* test: bound guarded response regression reads

* test: retain owned sockets in portal collision fixtures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: whatsapp-web Channel integration: whatsapp-web extensions: github-copilot extensions: huggingface extensions: lmstudio gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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