Skip to content

fix(proxy-capture): preserve partial responses and shutdown diagnostics - #143107

Merged
vincentkoc merged 3 commits into
mainfrom
fix/proxy-capture-partial-response
Sep 9, 2026
Merged

vincentkoc merged 3 commits into
mainfrom
fix/proxy-capture-partial-response

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

Related: #143010
Related: #143012
Related: #140621

What Problem This Solves

Resolves a problem where operators inspecting debug proxy captures could lose response bytes already received when a stream failed or capture shutdown interrupted the read. Pending readers could also write after their store closed, persistence failures could disappear during process exit, and a guarded request could be recorded in the wrong capture session after the state root changed.

This is a capture prerequisite discovered while validating the runtime prompt-cache test stack. It does not fix the prompt-cache behavior discussed in the related PR, and the completed live runs have not reproduced that original defect. The secretless stream tests do not establish the cause of a particular live transport failure.

Why This Change Was Made

Capture now owns one bounded response read and one terminal record, preserving observed bytes and explicit incomplete/error outcomes while settling pending reads before the exact owning store closes. Admission remains tied to its original store generation; guarded and globally patched fetch paths share error recording without duplicate or replacement-session writes.

Retired owners release their heavy state, state-root/session identity stays isolated, and persistence failures emit synchronous redacted diagnostics. Caller streams, error identity, cancellation, existing byte/idle limits, and the capture: false global-delegation contract remain intact. No schema, configuration, dependency, provider parser, cache accounting, or cache-threshold changes.

The final scope is capture-only: five production files, five capture test files, and one shrink-only assertion-baseline change. Earlier Windows and Telegram fixture amendments were dropped entirely after main independently landed the fixes by @steipete in #143213 and #143197. Both fixture files match the frozen main base exactly. No retained fixture, temporary observer, or workflow delta.

User Impact

Debug captures retain the response prefix actually observed, distinguish stream/read failures from storage failures, and close without late writes or silently moving requests into another capture session. A transport rejection remains visible as one error event, not a fabricated HTTP response.

Release-note context: preserve partial debug capture responses and finalize capture sessions safely without losing failure diagnostics.

Evidence

  • Reviewed head: f240de23583a42902c13298881276baa5652ba28; tree 12247570b625e5be1cb7e4e8838a454c625efacf; frozen source base 895bdee99ed94c0f4d1014faecc2c0bf79b0db1f. All three capture commits are signed and patch-identical to the previous reviewed series. All ten capture implementation/test blobs match prior head f24c277659b495309300a06bd1d40921031a75c2; both superseded fixtures match frozen main.
  • Exact-head CI passed: https://github.com/openclaw/openclaw/actions/runs/34374251977, attempt 1. The primary-job audit counted 110 passed, 16 skipped, 0 failed jobs; these are job counts, not test-case counts. Required gate: https://github.com/openclaw/openclaw/actions/runs/34374251977/job/102551111983.
  • CI executed merge 1b27dc36dba7e327f0f008e7e29589bbb9720e9c, combining this head with main 73b4086ff658973fb9ae07fa208c49ca8de82a67. Both Windows jobs passed; the media file-URL case executed in 800 ms. Core/test types and artifact runtime SDK entry declarations, exports, and UI checks passed. This is not a full release-DTS or release-package qualification claim.
  • Fresh exact-candidate autoreview is scoped-clean at P0-P2, with final source verification. Independent reconciliation review confirmed all 11 files, blob identities, signatures, and baseline preservation. Exact-head ClawSweeper revision 7 reports no findings, no security issue, and no before-merge item: fix(proxy-capture): preserve partial responses and shutdown diagnostics #143107 (comment).
  • Prior focused proof remains explicitly prior-head: 87 tests passed, zero skipped, at cc3ed5b3e48420a847020833814a0bb1417e15a3 on Node 26.7 in 35.59 seconds, covering runtime/injected-store behavior, lifecycle, nine real-loopback ownership/rejection cases, and 22 existing OpenAI TTS cases. The broader 133 tests passed, zero skipped, at 59d4f3fc28b3f7d7b8e9f917d279299af9ef35d1 in 162.37 seconds, additionally covering store, managed-fetch, pooled-release, and guarded-body tests. These counts are not described as new runs on the final head.
  • Fail-before proof covered late writes after finalization, missing exit-time persistence diagnostics, retained owner state, same-session stores under different roots, wrong-owner recording, saved-wrapper duplication, and an active rejection with zero error records. Existing TTS proves capture: false global delegation remains exact-once; an initial zero-record test expectation was rejected rather than counted as a product defect.
  • Managed-fetch coverage includes terminal responses with an open body, partial EOF, idle timeout, read error, and caller cancellation. A successful terminal can coexist with a captured response-body read failure; this PR preserves the evidence without inferring its cause. Lifecycle coverage includes direct/last-lease shared and legacy closure, sibling settlement, delayed success/rejection across retirement, both finalization orders, and subprocess exit ordering with injected blob/event persistence failures.
  • Earlier independent findings were repaired at these owners. A proposed pre-reader-finalization finding was independently dismissed because native clone/reader acquisition is synchronous before the first await; no speculative guard was added.
  • Production: +689/-353, net +336 across five files. Tests: +1,286/-3 across five files. The baseline is separately +1/-1: main's full baseline remains intact except the existing runtime allowance reduction from 10 to 5. Production growth implements observed-byte, exact-store lifecycle, and admission-ownership invariants; the module extraction keeps retirement and matching patch cleanup together without a second registry or new public entrypoints.
  • Earlier Testbox proof at https://github.com/openclaw/openclaw/actions/runs/34354040282 admitted prior head fead06567d0697765c90eea0466ca5859baaa56e. Core production types and all 17 core test-type graphs passed, then four lint findings stopped that payload before build. Its lease was stopped and its Actions result was not an aggregate pass. Later reviewed corrections addressed those findings; the final exact-head hosted CI above is the current qualification.
  • Earlier local typed lint was blocked before analysis by shared-install declaration admission, without bypass or retry. Earlier fixture diagnostics remain historical only: the temporary Telegram idle-expiry trace was globally incomplete, so historical CI failures are not assigned that cause. No fixture workaround remains in this PR.
  • Native review artifacts now record the exact-head green evidence and maintainer-ready recommendation. No additional provider inference, duplicate release build, or new Testbox lease was used for closeout.

Named separate follow-up: Telegram model-selection reporting can say selection failed after persistence succeeded if confirmation delivery fails. That production reporting issue is outside this capture repair.

@vincentkoc vincentkoc self-assigned this Sep 9, 2026
@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
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.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Sep 9, 2026
@clawsweeper clawsweeper Bot added 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 Sep 9, 2026
@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 9, 2026, 12:09 PM ET / 16:09 UTC (Revision 7).

ClawSweeper review

What this changes

Preserves partial debug-capture responses, records transport failures, and settles pending captures before their owning store closes.

Merge readiness

✅ Ready for maintainer review

This repair remains useful: current main still loses partial capture bodies. No actionable introduced defect was found, and the capture files match the previous reviewed head. The related prompt-cache work does not supersede this PR.

Priority: P2
Reviewed head: f240de23583a42902c13298881276baa5652ba28

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with substantial regression coverage and no identified blocking defect; ordinary exact-head CI remains authoritative.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored PR. Inspected loopback and lifecycle tests exercise the changed capture owners, caller cancellation, and persistence diagnostics; reported passes remain prior-head evidence and were not rerun here.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored PR. Inspected loopback and lifecycle tests exercise the changed capture owners, caller cancellation, and persistence diagnostics; reported passes remain prior-head evidence and were not rerun here.
Evidence reviewed 10 items Pinned scope and clean checkout: The merge-base-to-head delta contains only capture implementation, capture tests, and the assertion-baseline reduction. The Windows and Telegram fixtures have no introduced delta. Final git status was clean and diff whitespace checks passed.
Previous-review continuity verified: GitHub returned the complete prior src tree. Comparing its blob identities with local HEAD confirmed identical capture production/test files and fetch-guard.ts. The previous completed review retained no findings.
Repair remains absent from main and latest release: Current main's reader discards buffered bytes on idle timeout or stream rejection and finalizes through a newly resolved store. Its runtime.ts blob is identical to v2026.9.3, whereas this PR has a different implementation.
Findings None None.
Security None None.

How this fits together

Debug proxy capture observes outbound HTTP traffic and stores diagnostic events and response bodies for operators. Its readers must preserve useful evidence without changing the caller’s response or writing into a retired capture session.

flowchart TD
  A[Outbound HTTP request] --> B[Capture session admission]
  B --> C[Guarded or global fetch]
  C --> D[Caller response or error]
  C --> E[Bounded diagnostic reader]
  E --> F[Capture events and blobs]
  G[Store shutdown] --> E
  G --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +336, Tests +1283, Other 0. Total +1619 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 5 689 353 +336
Tests 5 1286 3 +1283
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 11 1976 357 +1619

Review metrics

Metric Value Why it matters
Production versus test growth Production net +336 lines; tests net +1,283 lines Production growth has an explicit lifecycle and partial-response justification, with regression coverage concentrated on those boundaries.

Technical review

Best possible solution:

Keep capture reads and shutdown settlement under one store owner while preserving caller outcomes, existing size limits, redaction, and both storage formats.

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

Yes, from source: current main drops buffered response bytes when the capture reader stalls or rejects, and pending reads can outlive finalization. Focused regression scenarios are supplied; no runtime reproduction was executed during this review.

Is this the best way to solve the issue?

Yes. Repairing the existing capture reader and exact-store lifecycle addresses the failure at its owner without changing provider parsing, configuration, schema, or public SDK entrypoints.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9c0ae15a4649.

Labels

Label justifications:

  • P2: This repairs diagnostic capture loss and shutdown handling with limited impact outside opt-in capture.
  • 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: The external-contributor proof gate does not apply to this MEMBER-authored PR. Inspected loopback and lifecycle tests exercise the changed capture owners, caller cancellation, and persistence diagnostics; reported passes remain prior-head evidence and were not rerun here.

Evidence

What I checked:

  • Pinned scope and clean checkout: The merge-base-to-head delta contains only capture implementation, capture tests, and the assertion-baseline reduction. The Windows and Telegram fixtures have no introduced delta. Final git status was clean and diff whitespace checks passed. (f240de23583a)
  • Previous-review continuity verified: GitHub returned the complete prior src tree. Comparing its blob identities with local HEAD confirmed identical capture production/test files and fetch-guard.ts. The previous completed review retained no findings. (src/proxy-capture/runtime.ts, f24c277659b4)
  • Repair remains absent from main and latest release: Current main's reader discards buffered bytes on idle timeout or stream rejection and finalizes through a newly resolved store. Its runtime.ts blob is identical to v2026.9.3, whereas this PR has a different implementation. (src/proxy-capture/runtime.ts, 9c0ae15a4649)
  • Release comparison: v2026.9.3 resolves runtime.ts to blob 0f3803e6b55bca95576c985f0c92413b9683a29a, matching the separately inspected current-main tree. (src/proxy-capture/runtime.ts, 1391f7cd2d40)
  • Terminal recording and lifecycle ownership: The bounded reader settles once, preserves observed bytes, cancels without awaiting the sibling tee, and removes its finalizer. Owner retirement clears admission before settling pending readers; store close attempts every cleanup even after a persistence failure. (src/proxy-capture/runtime.ts:107, f240de23583a)
  • Boundary coverage and reported execution: Inspected tests cover real loopback guarded/global fetches, delayed success and cancellation across retirement, exact-once rejection records, shared and legacy store closure, and redacted subprocess-exit diagnostics. The supplied PR body reports 87 and 133 passing tests on explicitly identified prior heads; this review executed no tests. (src/proxy-capture/runtime.guarded-fetch.test.ts:175, f240de23583a)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • steipete: 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 (6 earlier review cycles)
  • reviewed 2026-09-09T12:59:40.926Z sha fead065 :: needs changes before merge. :: none
  • reviewed 2026-09-09T13:20:43.320Z sha fead065 :: blocked before merge. :: none
  • reviewed 2026-09-09T13:36:03.482Z sha 59d4f3f :: needs maintainer review before merge. :: none
  • reviewed 2026-09-09T13:48:38.764Z sha cc3ed5b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-09T14:57:22.776Z sha c626dcc :: needs maintainer review before merge. :: none
  • reviewed 2026-09-09T15:55:08.727Z sha f24c277 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc marked this pull request as ready for review September 9, 2026 13:30
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head c626dccd80a119f148fffa8ffaa00ff1dacb14ea. Since the previous reviewed head, only the Windows media file-URL fixture changed: replace its stale provider-listing spy with canonical provider acquisition and preserve real PNG/file-URL coverage plus acquisition/run/release guards. Capture production code is unchanged.

The same fixture logic passed native Windows proof in https://github.com/openclaw/openclaw/actions/runs/34365049555/job/102511497307 at diagnostic commit 98b1ad2735f8b532285310b133acd7f436040778 (1 passed, 0 skipped). Diagnostic timing/workflow changes were not promoted. Fresh scoped autoreview and independent promotion review found no actionable issues; targeted lint, formatting, and diff checks passed.

The PR body distinguishes that diagnostic proof and prior capture tests from new-head CI, now pending at https://github.com/openclaw/openclaw/actions/runs/34366131803. No aggregate pass or original prompt-cache reproduction is claimed; no merge is requested.

@clawsweeper

clawsweeper Bot commented Sep 9, 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.

Re-review progress:

@vincentkoc
vincentkoc force-pushed the fix/proxy-capture-partial-response branch from c626dcc to f24c277 Compare September 9, 2026 15:49
@openclaw-barnacle openclaw-barnacle Bot added the channel: telegram Channel integration: telegram label Sep 9, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head f24c277659b495309300a06bd1d40921031a75c2 (tree 58052e9a41878a5cf78f6371acfce05d2bf55c01). The PR body now records the necessary rebase, current-owner Windows fixture import, and independently reviewed Telegram fixture-lifetime repair with failure-only diagnostics.

Previous capture code findings remain resolved; capture production changes are patch-identical through the rebase. Fresh combined Telegram autoreview is scoped-clean at P0-P2, and the same focused Node 26 test failed before and passed after (1 executed, 1 passed, 0 skipped). The local idle-expiry witness had a globally incomplete trace, so historical CI causality is not claimed. Typed lint was blocked before analysis by shared-install admission; new exact-head hosted CI is pending.

The separate persisted-selection versus confirmation-delivery reporting issue remains a named follow-up. No temporary observer/workflow, runtime prompt-cache repair, new provider inference, or merge-ready claim is included.

@clawsweeper

clawsweeper Bot commented Sep 9, 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.

Re-review progress:

@vincentkoc
vincentkoc force-pushed the fix/proxy-capture-partial-response branch from f24c277 to f240de2 Compare September 9, 2026 16:03
@openclaw-barnacle openclaw-barnacle Bot removed the channel: telegram Channel integration: telegram label Sep 9, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact capture-only head f240de23583a42902c13298881276baa5652ba28, tree 12247570b625e5be1cb7e4e8838a454c625efacf, based on frozen main 895bdee99ed94c0f4d1014faecc2c0bf79b0db1f.

All Windows/Telegram fixture amendments were dropped after the independent main fixes in #143213 and #143197. Both fixture files now match base exactly. The three remaining capture commits are patch-identical; all capture production/test blobs are unchanged from the prior head. Main's complete assertion baseline is preserved except the reviewed runtime allowance reduction from 10 to 5.

Fresh exact-candidate autoreview is scoped-clean at P0-P2, and independent reconciliation review approved the 11-file scope and identities. Previous capture findings remain resolved. Prior 87/133 focused passes and Testbox types remain explicitly prior-head evidence; new exact-head hosted CI is pending. No retained fixture/workflow delta, new provider inference, original prompt-cache repair, or merge-ready claim.

@clawsweeper

clawsweeper Bot commented Sep 9, 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.

Re-review progress:

@vincentkoc
vincentkoc merged commit 651775b into main Sep 9, 2026
189 checks passed
@vincentkoc
vincentkoc deleted the fix/proxy-capture-partial-response branch September 9, 2026 16:31
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 10, 2026
…cs (openclaw#143107)

* fix(proxy-capture): preserve partial responses and shutdown diagnostics

* refactor(proxy-capture): isolate capture session ownership

* fix(proxy-capture): type fetch patch metadata without assertions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

1 participant