fix(responses): harden sparse SSE tool streams#175
Conversation
Match the agent SSE buffering protections so pending tool calls flush through idle gaps instead of arriving only after tool completion. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Refresh the signed enclave measurements for the master-based Responses SSE keepalive build before opening the PR. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
WalkthroughThe PR appends new PCR history records to both development and production JSON history files, and refactors the SSE response handler to return a typed Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/web/responses/handlers.rs (1)
2943-2948: Optional: strengthen cache directive for intermediaries.Consider including
no-transforminCache-Controlto further reduce proxy-side response transformations on streaming traffic.Suggested tweak
- (header::CACHE_CONTROL, HeaderValue::from_static("no-cache")), + ( + header::CACHE_CONTROL, + HeaderValue::from_static("no-cache, no-transform"), + ),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/web/responses/handlers.rs` around lines 2943 - 2948, The Cache-Control header currently uses HeaderValue::from_static("no-cache"); update the header value to include no-transform (e.g. "no-cache, no-transform") so intermediaries won't alter streaming responses; change the value where header::CACHE_CONTROL is set (the HeaderValue::from_static("no-cache") call) and keep the existing x-accel-buffering header unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/web/responses/handlers.rs`:
- Around line 2943-2948: The Cache-Control header currently uses
HeaderValue::from_static("no-cache"); update the header value to include
no-transform (e.g. "no-cache, no-transform") so intermediaries won't alter
streaming responses; change the value where header::CACHE_CONTROL is set (the
HeaderValue::from_static("no-cache") call) and keep the existing
x-accel-buffering header unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: bcc363a1-d9be-44a3-a815-b2c0ae61a37a
⛔ Files ignored due to path filters (2)
pcrDev.jsonis excluded by!pcrDev.jsonpcrProd.jsonis excluded by!pcrProd.json
📒 Files selected for processing (3)
pcrDevHistory.jsonpcrProdHistory.jsonsrc/web/responses/handlers.rs
| fn responses_sse_response<S>(event_stream: S) -> Response | ||
| where | ||
| S: Stream<Item = Result<Event, Infallible>> + Send + 'static, | ||
| { | ||
| let sse = Sse::new(event_stream).keep_alive( | ||
| KeepAlive::new() | ||
| .interval(Duration::from_secs(RESPONSES_SSE_KEEPALIVE_INTERVAL_SECS)) | ||
| .text("keep-alive"), | ||
| ); | ||
|
|
||
| ( | ||
| [ | ||
| (header::CACHE_CONTROL, HeaderValue::from_static("no-cache")), | ||
| ( | ||
| HeaderName::from_static("x-accel-buffering"), | ||
| HeaderValue::from_static("no"), | ||
| ), | ||
| ], | ||
| sse, | ||
| ) | ||
| .into_response() | ||
| } |
There was a problem hiding this comment.
🚩 Other SSE endpoint lacks keepalive and proxy headers
The chat completions SSE endpoint at src/web/openai.rs:380 uses Sse::new(stream).into_response() without any keepalive or x-accel-buffering: no header. If the motivation for this PR is that sparse SSE streams get dropped by proxies/load balancers, the same issue could affect the other SSE endpoint. Consider whether the responses_sse_response helper should be reused there as well.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Validation
Summary by CodeRabbit
New Features
Improvements
Chores