fix(web-search): release unused OpenAI probe leases - #4946
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe passthrough web-search bridge now supports one-time finalization for completion, failure, and cancellation. The response path uses finalization to release an unused OpenAI sidecar probe lease. Tests and documentation cover these lifecycle paths. ChangesPassthrough finalization
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The finalization change has no established merge-blocking risk in the reviewed paths. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
✅ Deterministic PR hygiene checks passed. |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request is already Ready for Review. Hygiene✅ Deterministic PR hygiene checks passed. |
리뷰 · 우선순위 71 / 80이 PR은 웹검색(passthrough web-search) 다리를 만들 때 미리 잡아 둔 OpenAI 사이드카의 쿨다운 복구용 probe lease를, 실제로 검색을 쓰지 않거나 클라이언트가 중간에 끊어도 다시 돌려주는 고칩니다. 지금 고치는 방법은 단순합니다. 라인 passthrough-bridge.ts createPassthroughWebSearchBridgeStream cancel - 라인 passthrough-delivery.ts onFinalize - 사이드카가 없는 경로에서 openAiSidecar?.authContext가 undefined여도 release가 안전하게 무시되는지는 현재 라인 web-search-passthrough-bridge.test.ts cancelled client stream - 예전 AbortController.abort 기반 테스트를 getReader().cancel로 바꾼 것은 이번 finalize 계약에 맞습니다. 그런데 signal.abort와 cancel이 동시에 오는 경우·이미 pull이 close된 뒤 cancel이 오는 경우는 커버되지 않습니다. 우선순위는 낮지만 회귀 구멍이 될 수 있습니다. 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
…pstream read cancel() deferred the finalizer until iterator.return() settled. A generator suspended inside an upstream read cannot process a queued return until that read completes, so a disconnected client left the OpenAI probe lease held for the lifetime of an abandoned leg, which is the leak this branch fixes. Optional chaining also short-circuited the finalizer entirely for an iterator without a return method. Finalize first, then request generator teardown.
…udget structure/runtime.md sits at exactly the 600-line structure-ssot budget on dev and is not in grace.oversizeDocs, so the two added lines fail that gate once this branch merges. Fold the same contract into the existing sentence instead; the file already carries 83 lines over 150 characters, so a long line is its normal shape.
…18' into agent/websearch-probe-lease-20260918
Summary
web_search, and that resolution can grant the account's sole quota-recovery probe lease. When the turn ends without a search — or the client cancels — nothing settled the lease, so the cooled account stayed locked out of recovery probes until the cooldown itself expired.onFinalize?: () => voidhook toPassthroughWebSearchBridgeStreamOptionsand run it exactly once on normal completion, error, and client cancellation insidecreatePassthroughWebSearchBridgeStream.releaseCodexAuthContextProbeLease(openAiSidecar?.authContext). After an executed search the outcome recorder has already settled the lease, so the release is a no-op on that path; on the no-search and cancellation paths it hands the lease back so a later probe can be granted.structure/runtime.mdand extend the bridge tests to assert the finalizer runs on the no-search completion and on client cancellation.Verification
f04e823da7c411892b2234f458511c047eb5c549(tree0dfdf8f5feb2a761caa94baab5936b6a1da3ecac), based on deve80e571f63a52a3dbba0edeeb576060debf14190.bun test tests/web-search/web-search-passthrough-bridge.test.ts: 68 pass, 0 fail.bun x tsc --noEmit: clean.bun run structure:check: passed.bun run privacy:scan: passed.bun scripts/file-size-ratchet.ts: passed.Remaining gates:
Summary by CodeRabbit
Bug Fixes
Documentation