fix(openai): improve Responses API streaming reliability and diagnostics
This commit is contained in:
@@ -26,7 +26,7 @@ impl OpenAIProvider {
|
||||
.timeout(std::time::Duration::from_secs(300))
|
||||
.pool_idle_timeout(std::time::Duration::from_secs(90))
|
||||
.pool_max_idle_per_host(4)
|
||||
.tcp_keepalive(std::time::Duration::from_secs(30))
|
||||
.tcp_keepalive(std::time::Duration::from_secs(15))
|
||||
.build()?;
|
||||
|
||||
Ok(Self {
|
||||
@@ -441,6 +441,7 @@ impl super::Provider for OpenAIProvider {
|
||||
self.client
|
||||
.post(&url)
|
||||
.header("Authorization", format!("Bearer {}", api_key))
|
||||
.header("Accept", "text/event-stream")
|
||||
.json(&body),
|
||||
)
|
||||
.map_err(|e| AppError::ProviderError(format!("Failed to create EventSource for Responses API: {}", e)))?;
|
||||
@@ -527,8 +528,8 @@ impl super::Provider for OpenAIProvider {
|
||||
}
|
||||
Ok(_) => {
|
||||
// If the probe returned 200, but the stream ended, it might be a silent failure or timeout.
|
||||
tracing::warn!("Responses stream ended prematurely (probe returned 200)");
|
||||
Err(AppError::ProviderError(format!("Responses stream error (probe returned 200): {}", e)))?;
|
||||
tracing::warn!("Responses stream ended prematurely (probe returned 200). Error: {}", e);
|
||||
Err(AppError::ProviderError(format!("Responses stream error (connection closed by server after 200 OK): {}", e)))?;
|
||||
}
|
||||
Err(probe_err) => {
|
||||
tracing::error!("OpenAI Responses Stream Error Probe failed: {}", probe_err);
|
||||
|
||||
Reference in New Issue
Block a user