Conversation
|
|
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughA concurrency bug fix snapshots Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.11.4)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
🧪 Test Suite AvailableThis PR can be tested by a repository admin. |
Confidence Score: 5/5Safe to merge — targeted, minimal fix for a real concurrency bug with no behavioral changes outside the race window. Change is small and focused: two local-variable snapshots mirroring the already-present No files require special attention. Important Files Changed
Reviews (3): Last reviewed commit: "Merge branch 'main' into 04-26-fix_pool_..." | Re-trigger Greptile |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
core/bifrost.go (1)
5702-5727: Please add a regression test for this pooled-request capture path.This closure fix looks right, but it guards a subtle concurrency bug. A streaming test that interleaves different
RequestTypevalues across concurrent attempts would make this much harder to regress.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@core/bifrost.go` around lines 5702 - 5727, Add a regression test that reproduces the pooled-request concurrency scenario around tryStreamRequest and postHookRunner to ensure the captured attemptRequestType doesn't bleed between concurrent streaming attempts: write a streaming test that starts multiple overlapping attempts with different RequestType values, forces the code path that releases and reuses the pooled *ChannelMessage (so tryStreamRequest interleaves attempts), and verifies via PopulateExtraFields/RunPostLLMHooks results and errors (and IsFinalChunk/drainAndAttachPluginLogs behavior) that each attempt's RequestType/provider/model remains the per-attempt snapshot (no cross-attempt contamination). Ensure the test asserts for both successful chunks and errors and fails if any response/error shows the wrong RequestType.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@core/bifrost.go`:
- Around line 5702-5727: Add a regression test that reproduces the
pooled-request concurrency scenario around tryStreamRequest and postHookRunner
to ensure the captured attemptRequestType doesn't bleed between concurrent
streaming attempts: write a streaming test that starts multiple overlapping
attempts with different RequestType values, forces the code path that releases
and reuses the pooled *ChannelMessage (so tryStreamRequest interleaves
attempts), and verifies via PopulateExtraFields/RunPostLLMHooks results and
errors (and IsFinalChunk/drainAndAttachPluginLogs behavior) that each attempt's
RequestType/provider/model remains the per-attempt snapshot (no cross-attempt
contamination). Ensure the test asserts for both successful chunks and errors
and fails if any response/error shows the wrong RequestType.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6e3d02e3-0961-484b-8535-757ae6a7eeb7
📒 Files selected for processing (2)
core/bifrost.gocore/changelog.md
cc6d227 to
a45bd43
Compare
Merge activity
|

Summary
Under high concurrency, streaming requests were experiencing
RequestTypecorruption in response extra fields. This happened because*BifrostRequestand*ChannelMessageobjects are returned to their respective pools as soon as the stream channel is handed off, allowing a concurrent request to reuse and overwrite theRequestTypefield before the post-hook closure had a chance to read it.Changes
req.RequestTypeinto a local variable (shortCircuitRequestTypeintryStreamRequest,attemptRequestTypeinrequestWorker) before the post-hook closure is created, so the closure captures the correct value at the time of the request rather than reading from a potentially recycled object.Type of change
Affected areas
How to test
Reproduce by sending a high volume of concurrent streaming requests with different request types and verifying that the
RequestTypefield in response extra fields consistently matches the originating request.go version go test ./...Screenshots/Recordings
Breaking changes
Related issues
Security considerations
No security implications.
Checklist
docs/contributing/README.mdand followed the guidelines