Repository navigation
[PR] test(wire): pin all four protocols against their official SDK consumers - #7466
ranxianglei wants to merge 1 commit into
Conversation
Wires the official client SDKs as hermetic CI consumers for the three protocols that lacked the guarantee #7402 established for Responses: openai chat (openai 6.26.0), anthropic (@anthropic-ai/sdk 0.91.1), and google (@google/genai 1.52.0). Each suite feeds the proxy's synthesized byte stream (adapter emit* + stream-error legacy completion + a proxy-mode re-emitted upstream) to the real SDK and asserts the stream is accepted and the content/usage/finish fields survive — the same "official client must eat our stream" contract as tests/responses-content-index.test.ts. SDKs are resolved through the in-tree pi-coding-agent (the #7402 precedent) so no package.json/lockfile changes; the google consumer runs against a local HTTP server because @google/genai's streaming path uses the global fetch (no client-level fetch option). The wiring surfaced a real bug: the official OpenAI SDK rejects a stream whose choice 0 never carries a role ("missing role for choice 0"), the same class as #7401. When the upstream dies before sending any bytes the synthesized error completion is the client's first frame, and both emit sites (relay-level emitStreamError and the loop-level adapter emitError) omitted the role. Both now open with the assistant role; a duplicate role is harmless. Pinned by the two error-completion tests. Closes #7461
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.11219-pr.7466.36474eaThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr7466.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Dedupe: not a duplicate. #7466 is the only open PR wiring official SDK consumers for the wire protocols, and the only open PR citing #7461. The other open PRs matching "consumer" in the title (#5944, #4844) are unrelated domains (window sizing, dsh WS-lane gate). Live status (verified just now):
Labels: the mirror shim does not implement the label endpoints in this environment ( I am now reviewing the branch (code + regression surface) and will follow up with the structured review. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Independent review of PR #7466 — done. I re-read the diff from scratch (not from the issue thread), re-ran the suites locally, and probed the one claim the tests do not cover. Verdict: review clean, mergeable once CI goes green (it is still running: 29 success / 23 skipped / 8 in progress / no failures; the 40 "cancelled" rows are the superseded earlier run). What I verified beyond the PR's own claims:
Residual risk (low, for the record): the Labels: the PR already carries Auto-merge gate: not eligible — it changes a wire shape (error completion) and is a test+fix combo, so this is a human-merge PR. CI green + your merge is all that's left. 八问
收工判定:审核通过,无拦截项;等 CI 全绿 + owner 合并(人工合并,wire shape 变更不走 auto-merge)。 |
What
Wires the official client SDKs as hermetic CI consumers for the three protocols that lacked the guarantee #7402 established for Responses: openai chat (
openai6.26.0), anthropic (@anthropic-ai/sdk0.91.1), and google (@google/genai1.52.0). Each suite feeds the proxy's synthesized byte stream (adapteremit*+stream-errorlegacy completion + a proxy-mode re-emitted upstream) to the real SDK and asserts the stream is accepted and the content / usage / finish fields survive — the same "official client must eat our stream" contract astests/responses-content-index.test.ts.This is direction 2 of the investigation issue #7461. Directions 1 and 3 are answered in the issue thread.
Bug found and fixed while wiring
The official OpenAI SDK rejects a stream whose choice 0 never carries a role (
missing role for choice 0) — the same failure class as #7401 (Responses missingcontent_index). When the upstream dies before sending any bytes, the proxy's synthesized error completion is the client's first frame, and both emit sites (relay-levelemitStreamErrorand the loop-leveladapter.emitError) omitted the role, so the SDK rejected the whole response and the client saw a connection error instead of the failure text. Both now open with the assistant role; a duplicate role (upstream already sent one) is harmless — the SDK just re-sets the already-"assistant" role. Pinned by the two error-completion tests.How the consumers are wired
@earendil-works/pi-coding-agent(the [PR] fix(responses): preserve content indices in synthesized streams #7402 precedent):createRequire(import.meta.resolve("@earendil-works/pi-coding-agent"))→await import(pathToFileURL(req.resolve(pkg)).href). Nopackage.json/ lockfile changes. If pi-ai ever drops one of these transitive deps the suite fails loudly (a visible, deliberate diff), not silently.new OpenAI({ fetch })/new Anthropic({ fetch })with afetchthat returns the synthesized bytes. Fully hermetic, no network.@google/genai'smodels.generateContentStreampath uses the global fetch (no client-levelfetchoption — verified in the SDK source), so the consumer runs against a local HTTP server onlisten(0)that serves the synthesized bytes. Still hermetic (loopback only, no external network).tests/*.test.tsfiles are auto-globbed byscripts/run-ci-tests.mjs(no registration). None of the suites spawn a process, so noLIVE_FILEStripwire entry is needed.Files
tests/openai-chat-sdk-consumer.test.ts(new, 7 tests)tests/anthropic-sdk-consumer.test.ts(new, 7 tests)tests/google-sdk-consumer.test.ts(new, 5 tests)src/stream-error.ts(openai legacy completion opens with the assistant role)src/loop/adapter-openai.ts(newbuildRole();emitErrorcompletion shape opens with it)Closes #7461