Skip to content

[PR] fix: forward single-shot Responses server-tool calls instead of 400 - #6574

Merged
ranxianglei merged 3 commits into
ranxianglei:masterfrom
sx4im:fix-6548-pi-fetch-xai-400
Nov 15, 2026
Merged

ranxianglei merged 3 commits into
ranxianglei:masterfrom
sx4im:fix-6548-pi-fetch-xai-400

Conversation

@sx4im

@sx4im sx4im commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

With bili installed as a pi package, the xAI web-search backend of pi-web-access stops working: every search gets a 400 from bili, "Missing stable conversation identity". The fetch patch claims the call because its URL ends in /v1/responses, and the proxy then refuses it because no conversation identity exists and there is no history to match.

That call is not a conversation turn. pi-web-access sends a minimal single-shot Responses body, string input plus web_search/x_search tools only, no history, and it has no knob for a session id, so the client cannot carry an identity. The #286 refusal exists to keep content-fingerprint sessions from orphaning state, and a call like this creates no session state at all.

What changed:

  • New isResponsesServerToolSingleShot predicate in src/server/side-request.ts: string input, only web_search/web_search_preview/x_search tools, no previous_response_id/session_id/prompt_cache_key, tool_choice must not force a client tool.
  • src/server/handle.ts: at the 会话身份不稳定:credential/upstream 维度导致长会话状态孤儿化(sessions 缺失) #286 refusal, a request matching that shape is forwarded verbatim instead of 400ing.
  • Tests: predicate positives/negatives, plus end-to-end cases in e2e-session-identity.

How verified:

  • websearch-side-request 8/8, e2e-session-identity 20/20, side-lane-invariants included in a 23/23 run. The new e2e case forwards with 200 and creates no session; a client-tool variant and a previous_response_id variant still 400.
  • Full npm run typecheck clean.
  • Version-first triage: the refusal and the fetch claim are identical at tag v0.1.213 (133f352), the reporter version, so this is not version lag.

Fixes #6548

…anxianglei#6548)

A single-shot Responses call with string input and only server-executed
search tools (pi-web-access xAI web search) is not a conversation turn:
it carries no history to fingerprint and creates no session state, so the
ranxianglei#286 refusal's rationale does not apply to it, and the client cannot carry
an identity here. Forward it verbatim instead of hard-400ing.
@ranxianglei ranxianglei changed the title fix: forward single-shot Responses server-tool calls instead of 400 [PR] fix: forward single-shot Responses server-tool calls instead of 400 Nov 13, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

Reviewed the diff in context, ran the targeted suites locally, and checked both compression modes. Assessment below.

Duplicate screening: Not a duplicate — only PR #6574 references #6548, and no other open PR fixes the same pi-web-access xAI-search 400.

What I verified (independently of the PR description):

  • Predicate is proto-safe by shape. isResponsesServerToolSingleShot (src/server/side-request.ts:103) mirrors isServerToolUtilityCall (Anthropic, :49). It requires string input, so an Anthropic messages body can never match it; the Anthropic detector requires messages, so a Responses body can never match that one. The tool loop vetoes ANY non-server-search tool (function/mcp/…), and the tool_choice handling matches the Responses wire (string auto/required, object forcing a declared server tool; none/client-tool/unrecognized vetoes).
  • The forward is the established pattern. handle.ts:1623 replicates the 「BUG」native-intercept 进程级 globalThis.fetch 补丁按 URL 形状接管所有模型流量,无关调用者(如 MemOS)被卷入宿主压缩流程 #1117 passthrough verbatim-forward (handle.ts:598) exactly — same arg list, same config. I confirmed forward only consults config in the compression path (relay.ts:2581–2796), which is skipped for a verbatim forward (prepared === null), so config vs reqConfig is a non-issue here.
  • Both compression modes. The branch sits in the !clientProvided && !anonAffinity anonymous path. Plugin-mode regular turns (client-provided identity) never reach it; the fix reaches the pi-web-access xAI call precisely because that specific request is anonymous even inside a plugin-hosted process.
  • Targeted suites green locally: websearch-side-request + side-lane-invariants 23/23; e2e-session-identity 20/20 (the 3 new e2e cases + 2 predicate cases all present and passing, not skipped). The e2e harness is real (mock upstream + real startServer, asserting status 200 + zero sessions; the client-tool and previous_response_id variants still 400). npm run typecheck clean.
  • CI: 24 checks still queued (0 failed) — full-suite verdict pending; I'll confirm when it lands.

结构化八问(中文,供人工评审):

  1. 是什么问题:pi-web-access 的 xAI 搜索后端发的是"单发" Responses 请求(字符串 input + 只有 web_search/x_search 工具、无历史、无身份),不是对话轮次。bili 的 fetch 补丁因 URL 以 /v1/responses 结尾就认领了它,会话身份不稳定:credential/upstream 维度导致长会话状态孤儿化(sessions 缺失) #286 拒绝分支因"没有稳定会话身份"直接 400,搜索完全不可用。
  2. 什么原因导致的:会话身份不稳定:credential/upstream 维度导致长会话状态孤儿化(sessions 缺失) #286 拒绝的立法本意是"防止内容指纹会话孤儿化状态",但判定只看"有没有身份",没区分"这个请求根本不会创建会话状态"。单发 server-tool 请求无历史可指纹、不建任何会话状态,会话身份不稳定:credential/upstream 维度导致长会话状态孤儿化(sessions 缺失) #286 的理据对它不成立——是判定粒度问题,不是身份缺失问题。
  3. 影响范围与严重程度:影响所有把 bili 装成 pi 包、用 pi-web-access xAI 搜索后端的用户(也覆盖任何走 Responses 单发 server-tool 的匿名调用)。严重程度:该搜索功能完全不可用(每次 400)——非核心压缩路径,但对配置了该后端的用户是硬伤。
  4. 怎么修复的:在 会话身份不稳定:credential/upstream 维度导致长会话状态孤儿化(sessions 缺失) #286 拒绝分支前加形状谓词 isResponsesServerToolSingleShot(字符串 input + 工具全是服务端搜索类型 + 无 previous_response_id/session_id/prompt_cache_key + tool_choice 不强制客户端工具),命中即按 「BUG」native-intercept 进程级 globalThis.fetch 补丁按 URL 形状接管所有模型流量,无关调用者(如 MemOS)被卷入宿主压缩流程 #1117 透传原样转发(不建会话、不压缩),而非 400。
  5. 是否有回归问题:无。改动只触及"匿名 + 无法指纹 + Responses 单发 server-tool"窄集,这些请求此前一律 400、现在 200。既有行为逐项核过:① 插件模式常规轮次(clientProvided=true)不经过此分支;② 代理模式多轮对话——数组 input 不匹配谓词(谓词要求字符串 input),且 anonAffinity 可解析时不进 !anonAffinity 分支;③ 带客户端工具 / 带 previous_response_id / tool_choice:none 的变体仍 400(有负向 e2e 钉住)。另核了"普通 agent 首轮"边界:Responses 多轮用数组 input(不匹配谓词),且首轮匿名时客户端拿不到 session id、无法依赖首轮建会话,故逐字转发不损害后续轮次的会话创建。无阈值/时序/输出格式漂移。
  6. 是否破坏缓存:不涉及。单发请求不建会话、不进压缩/缓存路径;逐字透传不触碰任何缓存键或增量游标。
  7. 是否改了设计方向:不涉及。未改架构/边界/数据流,只在既有 会话身份不稳定:credential/upstream 维度导致长会话状态孤儿化(sessions 缺失) #286 拒绝分支上加形状豁免,沿用既有 「BUG」native-intercept 进程级 globalThis.fetch 补丁按 URL 形状接管所有模型流量,无关调用者(如 MemOS)被卷入宿主压缩流程 #1117 透传机制。
  8. 是否引入了新的配置:不涉及。无新 env/config/默认值。

Verdict: Mergeable. Code review + targeted suites green; full CI pending (24 queued, 0 failed).

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

Status update (review already posted above with the full 八问):

  • Done: independent code review of the diff in context + targeted suites run locally.
  • Verified green locally: npm run typecheck clean; websearch-side-request + side-lane-invariants 23/23; e2e-session-identity 20/20 (the 3 new e2e cases + 2 predicate cases present and passing, not skipped). The new forward at handle.ts:1623 replicates the 「BUG」native-intercept 进程级 globalThis.fetch 补丁按 URL 形状接管所有模型流量,无关调用者(如 MemOS)被卷入宿主压缩流程 #1117 passthrough pattern exactly, and forward only consults config on the compression path (skipped for a verbatim forward), so the config choice is correct.
  • Remaining / risk: full CI still queued (24 checks pending, 0 failed) — the remote full-suite verdict is CI's job and hasn't landed yet. No code-level risk found in review; the only open item is the CI green.
  • Verdict stands: mergeable on code review + targeted evidence; awaiting CI to confirm.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

CI update: the mirror cache was stale — the full CI actually completed and the test lane has 5 failing shards (ubuntu-22/1, windows-22/1, ubuntu-24/1, windows-22/2, windows-22/3). All other lanes (static gates, guards, docs, lock-sync, build-artifact, unused-exports, kernel-guard, etc.) are green; 14 e2e lanes skipped by design.

I'm now determining whether those 5 test-shard failures are inherited from master (master currently red → not this PR's problem) or introduced by the diff. The PR only touches the #286 refusal branch + a new predicate + its tests, so I need to confirm the failing test names don't overlap the changed paths. Will report the verdict shortly.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Red CI verdict: 100% inherited master red — not this PR's code. No fix applied on the PR branch (policy: master-level fixes converge into ci-fixes, not onto individual PR branches).

Live check state re-verified (mirror cache, head 1d2c8d2be7, run 43464001928) — 5 failing test shards, all on tests this PR does not touch:

Shard Failing tests Signature
test (ubuntu, 22, 1) visibleNotices ×2 (tests/notice-registry.test.ts) inherited born-red (#6480)
test (ubuntu, 24, 1) visibleNotices ×2 (tests/notice-registry.test.ts) inherited born-red (#6480)
test (windows, 22, 1) #5506 metadata fold ×3 (persist-metadata-fold-gate.test.ts) Windows EBUSY unlink index.db flake
test (windows, 22, 2) visibleNotices ×2 (tests/notice-registry.test.ts) inherited born-red (#6480)
test (windows, 22, 3) store BILI_PERSIST_ZSTD ×10 Windows EBUSY unlink index.db flake

This PR's own 5 new tests are all green in CI (verified line-by-line in the passing shard ubuntu-22-2):

Why no fix on the PR branch:

Action taken this run:

Resolution path: once the sentinel converges the visibleNotices hermetic fix into ci-fixes, merge origin/ci-fixes + rerun turns this PR green; the Windows EBUSY flakes pass on rerun.


八问(中文):

  1. 是什么问题:PR [PR] fix: forward single-shot Responses server-tool calls instead of 400 #6574 的 CI 有 5 个 test 分片红,需判定是本 PR 代码问题还是继承性 master 红,并处置。
  2. 什么原因导致的:5 个红分片全部是继承性 master 红——ubu22-1/ubu24-1/win22-2 挂 tests/notice-registry.test.ts 的 2 条 visibleNotices 用例([PR] storage: pure-SQLite default — JSON envelopes stop being written unless dual-write is requested (#6479) #6480 pure-SQLite default 落 master 后的 born-red:该公告由 sqliteDefaultNoticeActive 门控,hermetic 测试未钉存储 env,CI 基线 preload 的钉法使门变假,公告不显示;同 CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 floor 1305/1307/1310/1311/1312/1317/1320 签名);win22-1 挂 Scheduled full test failed: ee0dcc7c | 定时全量测试失败: ee0dcc7c #5506 metadata-fold ×3、win22-3 挂 store BILI_PERSIST_ZSTD ×10,均为 Windows EBUSY: resource busy or locked, unlink '…index.db' 文件锁 flake(同 floor 1307②/1310/1312,重跑即绿)。本 PR diff 与 notices/storage 零交集。
  3. 影响范围与严重程度:仅 CI 红,不影响用户、不影响本 PR 代码正确性;本 PR 自带 5 个新测试在 CI 全绿(通过分片 ubuntu-22-2 逐条核实)。
  4. 怎么修复的:未在 PR 分支修复(CI 协调政策 2026-10-24:master 级修复必须收敛到 ci-fixes 由哨兵统一维护,禁止在 PR 分支夹带无关 master 级测试修)。merge origin/ci-fixes 为空操作(PR base e1f31ad 已是 master head,已含 ci-fixes a007974,已验证祖先关系)。已在 CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 报备,等哨兵把 visibleNotices hermetic 修收敛进 ci-fixes 后 merge 重跑即绿。
  5. 是否有回归问题:无——零代码改动、零 push,高危模式(语义漂移/吞错/阈值时序输出格式变化)逐项不涉及。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

判定:本 PR 的 CI 红 100% 继承性 master 红,非本 PR 代码问题;本分支不动,等哨兵在 ci-fixes 收敛 visibleNotices hermetic 修后 merge 重跑即绿。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[ework] auto-fix stalled: test (ubuntu-latest, 22, 1), test (windows-latest, 22, 1), test (ubuntu-latest, 24, 1), test (windows-latest, 22, 3), test (windows-latest, 22, 2) — stopping for human review

1 similar comment
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[ework] auto-fix stalled: test (ubuntu-latest, 22, 1), test (windows-latest, 22, 1), test (ubuntu-latest, 24, 1), test (windows-latest, 22, 3), test (windows-latest, 22, 2) — stopping for human review

Resolve conflicts with master: the side-request.js import in
src/server/handle.ts and the allowlist in
tests/side-lane-invariants.test.ts both gained identifiers on
both sides — take the union (upstream's hasSingleShotBudget /
isStructuredOutputCall plus the PR's
isResponsesServerToolSingleShot). All other files merged from
disjoint upstream/PR changes.
The merge of master dropped the spaces inside the braces of the
side-request.js import. Restore repo style; no semantic change.
ranxianglei pushed a commit that referenced this pull request Nov 14, 2026
…merge commit

These files (issue-number lists recording the superseded closings of the
previous four batches #6439/#6455/#6464/#6482) are present in neither
parent of the #6574 merge commit yet appear in its result, and survive to
the branch tip. They are not part of any source PR, are referenced
nowhere, are not mentioned in the PR description, and the previous four
batch merges never committed such files to master. Process scratch data
does not belong at the repo root; the closing record already lives in
GitHub history.
@ranxianglei
ranxianglei merged commit 2f92132 into ranxianglei:master Nov 15, 2026
12 of 41 checks passed
@ranxianglei

Copy link
Copy Markdown
Owner

Closes pair #6548 was auto-closed by the batch merge.

Superseded by #6765 (merged to master as 2f92132).

Your commit 6190fb3 is in master verbatim — same content, same authorship, only the object ID changed (the batch used a real git merge, no rebase or cherry-pick rewrite). Merged under a different branch name, so GitHub does not flip this PR by itself.

Thanks for the fix — it is live in master from 2f92132 onward.

@github-actions github-actions Bot mentioned this pull request Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] pi lane: in-process fetch patch claims pi-web-access's xAI search call and hard-400s it (no conversation identity)

2 participants