Skip to content

fix(web-search): honor provider HTTP version pins - #2908

Merged
lidge-jun merged 1 commit into
devfrom
codex/web-search-provider-fetch
Aug 29, 2026
Merged

fix(web-search): honor provider HTTP version pins#2908
lidge-jun merged 1 commit into
devfrom
codex/web-search-provider-fetch

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Route every web-search model iteration through the selected routed provider's existing providerFetch, including adapters that perform their own physical fetch through ctx.executor.
  • Preserve the provider-scoped fetch in IncomingMeta and resolve the mutable routed provider at send time so 429 credential rotation cannot retain a stale provider object.
  • Apply the independently resolved OpenAI sidecar provider's own upstreamHttpVersion pin to its /responses request without crossing routed and sidecar credential boundaries.
  • Add mutation-proven coverage for an OpenAI Chat/Zhipu-shaped routed request, an adapter-owned fetchResponse, and the hosted-search sidecar.

This resolves the configuration-ignored gap for web-search turns in #2885: an operator's upstreamHttpVersion: "http1.1" workaround now reaches both routed model iterations and a separately pinned hosted-search sidecar. It does not identify or fix the underlying Windows Bun 1.4.0 versus 1.3.14 HTTP/2/socket behavior reported by the issue, so this PR intentionally does not close it.

Verification

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (No user-facing configuration or behavior contract changed; existing upstreamHttpVersion behavior now reaches the omitted paths.)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. Routed and sidecar provider credentials remain independently scoped.

Summary by CodeRabbit

  • Bug Fixes
    • Improved web search reliability when switching providers after rate limits.
    • Preserved provider-specific connection settings during web-search requests and retries.
    • Ensured routed searches use the correct provider transport instead of a previously selected connection.

@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner August 29, 2026 13:24
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-29T13:28:34.264247Z a3e36ce PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ce55dadc-86f4-431b-8936-0d2df613579b

📥 Commits

Reviewing files that changed from the base of the PR and between 8df7051 and a3e36ce.

📒 Files selected for processing (4)
  • src/server/responses/core.ts
  • src/web-search/executor.ts
  • src/web-search/loop.ts
  • tests/web-search.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

Web-search execution now receives the current routed provider fetch implementation, applies the provider’s upstream HTTP version, and uses the same transport for adapter and retry requests. Tests verify provider routing and http1.1 propagation.

Changes

Web-search transport routing

Layer / File(s) Summary
Propagate routed provider fetch
src/server/responses/core.ts, src/web-search/loop.ts
handleResponsesInner passes a fetch resolver through incomingMeta.providerFetch. runWithWebSearch uses it for adapter and retry requests, with globalThis.fetch as fallback.
Apply upstream HTTP version
src/web-search/executor.ts
runWebSearch wraps outbound requests with withUpstreamHttpVersion, using the forwarded provider configuration.
Validate routed transport behavior
tests/web-search.test.ts
Tests verify provider-scoped fetch routing, adapter executor usage, request contents, and http1.1 propagation for Zhipu-shaped and OpenAI web-search flows.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to a3e36

The PR routes web-search requests through the configured provider transport, including HTTP-version pins and credential rotation paths, while keeping routed and hosted-search providers separate. No actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant Responses as handleResponsesInner
  participant SearchLoop as runWithWebSearch
  participant ProviderFetch as routed provider fetch
  participant Executor as runWebSearch
  Responses->>SearchLoop: pass incomingMeta.providerFetch
  SearchLoop->>ProviderFetch: fetch adapter or retry request
  ProviderFetch->>Executor: apply provider transport configuration
  Executor->>ProviderFetch: send request with upstream HTTP version
Loading

Suggested reviewers: ingwannu

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: web-search requests now honor providers' HTTP version pins. It matches the objectives and affected files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/web-search-provider-fetch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Aug 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a3e36ced99

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/web-search/loop.ts
timeoutMs: connectTimeoutMs,
returnRawErrors: true,
stream: true,
executor: routedProviderFetch,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor the executor in adapter-owned transports

When web search is routed through command-code, mimo-free, or Kiro, this supplied executor is never called: command-code uses its captured executor in src/adapters/command-code.ts:536-537, MiMo calls global fetch in src/adapters/mimo-free.ts:249-274, and Kiro's retry helper invokes fetchWithAttemptDeadline without ctx.executor. Because the fetchResponse branch prevents the fallback send below from running, these supported adapters still discard upstreamHttpVersion and the provider fetch seam on every model iteration. Update each adapter-owned physical send and retry to use ctx.executor, and cover at least one real adapter rather than only an executor-aware test double.

Useful? React with 👍 / 👎.

@lidge-jun

Copy link
Copy Markdown
Owner Author

리뷰 · 우선순위 66 / 80

이 PR은 지금 dev HEAD 8df705120 바로 위에서 웹서치 전송만 고친다. HEAD 제목은 fix(cursor): name the invocation inside a replayed tool result (#2900) 이다. 범위가 섞이지 않은 독립 버그픽스다.

지금 devIncomingMeta.providerFetch 칸은 이미 있다. 그림 브리지와 runTurn 경로는 그걸 쓴다. 웹서치 루프만 빼고 맨 globalThis.fetch 로 모델 반복을 보냈다. 그래서 운영자가 제공자에 upstreamHttpVersion: "http1.1" 을 적어도, 웹서치가 붙은 턴에서는 Bun protocol 핀이 라우트 요청에 안 붙었다. #2885 의 Zhipu openai-chat 경로가 그 구멍이다.

고치는 방법은 세 갈래다. src/server/responses/core.ts 는 보낼 때마다 route.provider 를 다시 읽어서 providerFetch 를 만든다. 429 키 회전이 route.provider = rotated 로 객체를 갈아끼우기 때문이다. 한 번만 잡아 두면 예전 키와 예전 핀이 남는다. 그 래퍼를 incomingMeta.providerFetch 에 넣는다. 루프는 일반 fetchfetchResponsectx.executor 둘 다 그 래퍼로 보낸다. buildRequest 에도 incomingMeta 를 펼쳐서 어댑터가 같은 fetch 를 보게 한다.

호스티드 검색 사이드카는 라우트 fetch 를 쓰지 않는다. src/web-search/executor.ts 가 OpenAI /responses 요청에 withUpstreamHttpVersion(..., forwardProvider) 만 붙인다. 라우트 키와 사이드카 키를 한 객체에 섞지 않는다. #2712 의 x_search 자격 증명 경계도 그대로다.

이 PR은 #2885 를 닫지 않는다. 그 이슈는 Windows 에서 Bun 1.4.0 이면 Zhipu GLM-5.3 스트림 소켓이 갑자기 닫히고, 같은 설정으로 1.3.14 이면 200 이 나는 단일 변수 A/B 다. 웹서치가 없어도 재현된다. 여기서 고친 것은 http1.1 핀이 웹서치 턴에서 무시되던 설정 구멍뿐이다. 소켓이 왜 1.4.0 에서 죽는지는 아직 모른다. 기본 번들을 1.3.14 로 내리라는 신호도 아니다.

테스트 세 개는 각자 자기 배선만 빼면 깨지도록 만들어져 있다. 글로벌 fetch 를 던지게 해 두고 제공자 fetch 로 핀이 가는지, 어댑터 ctx.executor 가 핀을 받는지, 사이드카 protocolhttp1.1 인지. tests/upstream-http-version.test.ts 는 이 PR이 안 건드린다. 그 파일은 이미 핀 헬퍼 자체만 증명한다. types.ts/config.ts 분할과도 무관하다. close-don't-rebase 대상이 아니다. 리눅스 테스트 샤드와 gates/hygiene 는 이 헤드에서 초록이다. macos 샤드는 아직 끝나지 않았다.

라인 5005 - 보낼 때 route.provider 를 다시 읽는 래퍼는 맞다. rotateSidecarProviderOn429 가 새 객체를 끼운다. 그런데 회전 다음에 새 키와 새 핀이 나가는지 보는 테스트는 없다. 한 번만 providerFetch(route.provider) 를 잡아 두어도 지금 테스트는 통과한다.
라인 452 - fetchResponse 에 executor 를 넘긴다. 테스트 어댑터는 그걸 쓴다. 실제 command-code 와 mimo-free 는 ctx.executor 를 무시하고 자기 fetch 를 쓴다. 그 어댑터의 웹서치 턴은 핀이 또 빠진다.
라인 77 - OpenAI 사이드카는 맨 fetch 에 핀만 붙인다. providerFetch(forwardProvider) 를 안 써서 사이드카의 custom fetch, pacing, timeout:0 은 그대로 빠진다. 라우트 자격 증명이랑 섞이지는 않았다.
경로 src/web-search/anthropic-executor.ts - anthropic/xai/gemini/exa 사이드카는 여전히 맨 fetch 다. OpenAI 호스티드 검색만 핀이 간다.
tests/web-search.test.ts 라인 387 - 이름에 #2885 가 붙어 있지만 모델이 바로 done 을 내서 사이드카는 안 돈다. 라우트 레그만 증명한다. Windows Bun 1.4.0 소켓 닫힘은 이 테스트로 안 잡힌다.

메인테이너의 판단이 필요한 지점

너의 추천
남은 macos 가 이 헤드에서 초록이면 dev 로 머지하세요. 웹서치 턴에서 설정한 HTTP 버전 핀이 무시되던 독립 구멍을 막는다. 자격 증명을 사이드카와 라우트 사이에 섞지 않았고, types/config 분할과도 안 겹친다. #2885 는 닫지 마세요. 머지 후 원본이 따로 있으면 Landed via #2908 at <commit> 하고 landed-via-maintainer 로 닫으면 된다. 지금 보이는 원본은 이 PR 자체다.

이 댓글은 grok-bot이 작성했습니다

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant