Skip to content

[PR] fix: preserve Request fields during inline fallback - #6566

Merged
ranxianglei merged 15 commits into
ranxianglei:masterfrom
Afloat16:2026-11-13_inline-fallback-request
Nov 14, 2026
Merged

ranxianglei merged 15 commits into
ranxianglei:masterfrom
Afloat16:2026-11-13_inline-fallback-request

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6565

Problem

When inline engine startup fails, the direct fallback calls send(targetUrl, init). For Request inputs this drops the request method, headers, body and signal: a POST arrives as an empty GET without its Authorization header. Providing an init.body alone also fails because the inherited POST method is lost.

Changes

Normalize RequestInit against the original Request and retarget the effective Request to the embedded upstream URL. Preserve transport-specific init fields while avoiding a second header/body application, which would regenerate multipart FormData boundaries. Consumed requests without a replacement reject instead of being replayed as empty GETs. String and URL inputs keep their existing path.

Validation

  • Baseline e1f31ad: 10 failures and 3 passing controls in the new 13-case suite.
  • Fixed branch: all 13 new cases plus pi-inline and inline-streaming pass, 21 tests total.
  • Real loopback HTTP checks cover request methods, headers, UTF-8 bodies, query strings, overrides, null/undefined inheritance, stream bodies, FormData boundary agreement, consumed bodies and cancellation. A transport seam verifies extension fields survive.
  • Root typecheck, complete build, unused-export gate, test-import-graph gate and git diff --check pass. Hosted CI and real-model E2E remain separate merge gates.

Related scope

Fresh all-state searches and 71 prior Afloat16 PRs were checked. #6563 fixes conversion within a running engine and #6560 fixes the cancellation/failure decision. This patch retains caller request data when genuine engine failure takes the existing direct fallback. It adds no retry or configuration and changes no kernel or persistence code.

Remote CI follow-up (2026-11-13)

CI run 43461411667 is failed, not green. I inspected every failed test job: Ubuntu Node 22/24 report the two notice-registry.test.ts assertions for the sqlite-default notice; Windows Node 22 additionally reports EBUSY while deleting index.db in persist-zstd.test.ts and persist-metadata-fold-gate.test.ts teardown. None of the changed files owns those paths. On the unchanged base e1f31ad9d5b47500362699a9867819b861c7de96, running the notice suite with the exact CI preload chain reproduces 3 passed / 2 failed (without the legacy-storage preload it is 5 passed / 0 failed).

Existing upstream PR #6561 / issue #6547 covers these same storage-baseline and Windows-handle failures. This PR keeps its focused product change separate; its full CI verdict remains failed until the upstream test fixes land and the head is rechecked. Windows reproduction here is limited to the remote job logs.

The suite baseline preload (preload-storage-baseline.mjs) pins
BILI_STORAGE_UNIFIED="legacy" for the broad corpus. After ranxianglei#6480 flipped the
storage default to pure-sqlite, the notice-registry suite's visibleNotices
assertions expect the pure-sqlite default notice, which is gated on
unifiedSelectionIsSqlite (unified "sqlite" or absent) — the preload's
"legacy" made the notice silent, so the suite was born-red on master. Pin
the selection explicitly (ranxianglei#4011 lesson: a test that depends on the production
default passes locally but fails in CI).
@ranxianglei

Copy link
Copy Markdown
Owner

(ai: vllm-qwen/qwen3.8-27b)

Review of the code: the fix is correct. The double construction new Request(target, new Request(input, init)) resolves init against the original Request per fetch semantics (init.headers replaces, init.body ?? request body, signal = init.signal ?? request.signal), the outer construction retargets the URL, and stripping headers/body from the second init prevents double application (a re-serialized FormData would pick a new multipart boundary) while keeping transport-specific fields intact. The 13-case suite passes locally on head 7da680c, and the log-wording commit is accurate (the catch covers dispatch failures, not just startup).

The 4 red CI jobs are all inherited from master, not caused by this PR (same 4 on both heads):

No code action needed on your side; the remaining work is master-side (ci-fixes convergence), after which a rebase should leave this PR green.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

CI status — re-verified; state is unchanged from the review above.

The 4 red jobs are all inherited from master (identical on the PR base and head), two distinct master-level defects:

I attempted to unblock directly by merging ci-fixes into the PR branch, but the head lives in the external fork (Afloat16/billion-context) and the agent's push is rejected (permission denied) — re-verified just now with a real push attempt (the --dry-run passes but the actual push is denied). So the merge has to come from the contributor's side.

Contributor unblock (clears the 3 notice-registry reds immediately; the 4th EBUSY flake clears on re-run):

git fetch <upstream> ci-fixes
git merge <upstream>/ci-fixes
git push

Remaining blockers — both master-side, none in this PR's code:

  1. ci-fixes → master convergence (notice-registry fix c6369fb6a1) — sentinel/owner.
  2. Contributor merge of ci-fixes (agent can't push to the fork).

No code change needed — the fix is correct and its own 13-case suite is green in CI. Ready to merge once the two master-side items clear.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Confirming the CI verdict (already posted above) — no new changes since:

  • 4 red jobs are all inherited from master (identical on base and head), two master-level defects, none in this PR's code:
  • No code change needed — the fix is correct, its own 13-case suite is green in CI.
  • Remaining blockers (master-side, not this PR): (1) ci-fixes → master convergence of c6369fb6a1 (sentinel/owner); (2) contributor merge of ci-fixes — agent can't push to the external fork Afloat16/billion-context (push rejected, re-verified).

Ready to merge once the two master-side items clear.

ework-agent and others added 11 commits November 14, 2026 10:20
…test

The dsh plugin lane (ci-e2e-dsh.yml) runs node --import tsx --test
WITHOUT the preload-storage-baseline.mjs preload, so BILI_STORAGE_UNIFIED
is unset and the storage mode defaults to 'full'. Under the pure-sqlite
default flip (5a80e2b, ranxianglei#6480), 'full' mode turns the JSON envelope
writer OFF — so the .content-store.json sidecar is never written, and
the test's readdirSync(namespace) hits ENOENT.

Pin BILI_STORAGE_JSON_WRITER=on in the test so the content-store
sidecar is written regardless of the storage mode. This keeps the
corrupted-store detection path exercised in both full and legacy modes.

Closes: dsh plugin lane red on master (run 43532980164, job 132255459726)
The pure-sqlite default flip (5a80e2b, ranxianglei#6480) turns the JSON envelope
writer OFF, so the .json session file this lane asserts on is never
written and 'proxy must persist the session' / 'no persisted session
carried compressed blocks' fail after the 20s wait. Pin the writer ON in
the spawned client's env (the bootstrapped proxy inherits it) so the
envelope this test was written for is still produced.

Closes: native opencode lane red on master (run 43547593803, job 132302438610)
Same pure-sqlite default flip (5a80e2b, ranxianglei#6480) as the opencode lane:
the JSON envelope writer is OFF, so 'proxy must persist the session
within 20000ms' fails — the on-disk .json session file is never written.
Pin the writer ON in the spawned dsh client's env (the bootstrapped
proxy inherits it).

Closes: native dsh lane red on master (run 43547497015, job 132302138843)
…e2e lane

Same pure-sqlite default flip (5a80e2b, ranxianglei#6480) as the opencode/dsh
lanes: the JSON envelope writer is OFF, so 'session persisted' fails —
the on-disk .json session file is never written. Pin the writer ON in
the spawned pi client's env (the bootstrapped proxy inherits it).

Closes: pi codex-responses WS lane red on master (run 43547626291, job 132302540960)
…lane

4th lane of the pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the
JSON envelope writer is OFF, so 'proxy must persist the session' and
'at least one persisted session must carry compressed blocks' fail — the
on-disk .json session file is never written. Pin the writer ON in the
spawned pi client's env (the bootstrapped proxy inherits it).

Closes: pi package-native lane red on ci-fixes (run 43558179054, job 132336647955)
Same pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON writer
is OFF, so the per-session CCR content-store sidecar (.content-store.json)
that 'child persists its own companion and survives a proxy restart'
asserts on is never written (0 !== 1). The earlier b1bc17b pin only
covered tests/plugin-fork.test.ts, not this file. Pin the writer ON at
module load (before any SessionStore is constructed).

Closes: dsh plugin lane red on ci-fixes (run 43558179102, job 132336519539)
…lane

Pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON envelope
writer is OFF, so 'proxy must persist the session' fails — the on-disk
.json session file is never written. Pin the writer ON in the spawned
opencode client's env (the bootstrapped proxy inherits it).
Pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON envelope
writer is OFF, so the on-disk .json session envelope this lane asserts on
(exactly ONE persisted session under the raw key) is never written. Pin
the writer ON in the spawned dsh client's env.
Pure-sqlite default flip (5a80e2b, ranxianglei#6480) family: the JSON envelope
writer is OFF, so the on-disk .json session file this lane asserts on
(state survival across the OLD→NEW update) is never written. Pin the
writer ON in the spawned proxy's env (both update phases share envBase).
Afloat16 added a commit to Afloat16/billion-context that referenced this pull request Nov 14, 2026
@Afloat16

Copy link
Copy Markdown
Contributor Author

Current head 9ea11fbbcbfbb66e69fbf3443dbf2258e4f1b077 now contains upstream master 1ff89e878522f3e4d4147067973e2dc26e648923 and the requested ci-fixes snapshot 1ca40871581c5009fdb69eea944f448d002098e7. The two feature files are byte-for-byte unchanged from 7da680cfc9331f3a6125e6280ca825c0869c8b8f.

I verified this exact head on Linux / Node 24.22.1: 28 tests passed, 0 failed, 0 skipped — 13 Request fallback cases, 8 adjacent inline cases, 5 notice-registry cases, and the 2 upstream in-place-update regressions. The repository's storage/test-environment/zone preloads were used; its existing registry-fetch test seam kept the optional catalog refresh offline, while the loopback HTTP fixtures ran normally. Exact-head manifest and test log.

The fresh upstream CI run is still pending. This local result does not establish a Windows or full-matrix pass; the Windows handle-teardown work in #6561 remains open.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Re-verified the live state after the contributor's merge — the unblock has landed:

  • New head 9ea11fbb contains upstream master 1ff89e8785 + ci-fixes 1ca4087158, including the notice-registry fix c6369fb6a1 (verified as an ancestor of the new head; the tests/notice-registry.test.ts diff confirms the BILI_STORAGE_UNIFIED pin is applied). The two feature files are byte-unchanged from 7da680cfc9.
  • Live CI (mirror cache, fetched 2026-11-14T06:13Z): the run on 9ea11fbb is still pending — 4 jobs pending, 0 failed so far. Not green yet.
  • No action needed from me — the contributor did the unblock (merged master + ci-fixes into the PR branch). The 3 notice-registry reds should clear once the pending run completes. The Windows EBUSY flake ([PR] test: unpin legacy envelope suites from the storage baseline #6561) is a separate concern the contributor noted as still open.

I'll confirm green once the run finishes.

@Afloat16

Copy link
Copy Markdown
Contributor Author

Updated again after upstream master advanced to 9495c764: this PR is now at b0f2656196cbd61fed8cdddf232693a5a649886e, with the shared test-file conflicts resolved. The Request fallback implementation and its regression tests remain unchanged.

The merge retains master's revised CI fixture setup and the Windows SessionStore close fixes that landed through #6552. The Windows cleanup work cited in the previous status is therefore present in this branch now. The outstanding update-state JSON-writer pin is preserved.

Validation on the exact published tree: full build, strict TypeScript checking of the affected files and dependencies, and all 21 focused fallback/adjacent inline tests pass (0 failures, 0 skips). The new upstream CI run is still pending; full hosted and Windows results remain to be confirmed.

The same master integration and conflict resolution are also pushed to #6484, #6487, #6489, #6492, #6494, #6496, #6498, #6500, #6502, #6504, #6556, #6560, #6563, #6571, #6575 and #6577. Each branch has its own validated tree and fresh CI run.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Verified the new head b0f26561 independently:

  • Contains the new master 9495c764 (which carries the Windows SessionStore close fixes from [PR] release v0.1.214 #6552) + the notice-registry fix c6369fb6a1 + the PR's own 2 commits.
  • The PR's own changes are unchanged: src/agent/pi-inline.ts (15 lines) + tests/pi-inline-fallback-request.test.ts (155 lines).
  • Live CI (mirror cache, fetched 2026-11-14T08:40Z): run on b0f26561 is still pending — 6 jobs pending, 0 failed so far.

No action needed from me — the contributor has done the unblock (merged the new master + ci-fixes). Once the CI run completes, the reds should clear (both the notice-registry fix and the Windows SessionStore close fixes are in the head). I'll confirm green when the run lands.

@ranxianglei
ranxianglei merged commit 10bd293 into ranxianglei:master Nov 14, 2026
50 checks passed
@ranxianglei

Copy link
Copy Markdown
Owner

Superseded by #6677 (merged as 3858b6956, 2026-11-14).

Landed into master via the real merge commit 10bd29316a0 (Merge Afloat16/2026-11-13_inline-fallback-request (PR #6566)), so your original commits are preserved verbatim in master history — only hashes of the batch wrapper changed, your authorship and commit messages are intact.

The fix for #6565 is now in master. Closing this PR as superseded — thanks for the careful, well-tested fix.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Confirmed and verified against live master: the fix for #6565 is in — current master 3858b6956a (the #6677 merge) contains the merge commit 10bd29316a0 and the src/agent/pi-inline.ts change is present.

The CI lane's work is complete: the 4 red jobs were all inherited from master (3× tests/notice-registry.test.ts born-red after #6480 + 1× Windows EBUSY flake #6561), and both root causes are now resolved in master (the notice-registry selection pin + the Windows SessionStore close fixes from #6552). No further action needed from the CI lane.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inline direct fallback loses Request method, headers and body

2 participants