This commit is contained in:
jif-oai
2025-11-13 16:17:33 +01:00
parent 38b568b504
commit 2790ddff0a
2 changed files with 8 additions and 16 deletions

View File

@@ -32,7 +32,6 @@ use std::task::Context;
use std::task::Poll;
use tokio::sync::mpsc;
use tokio::time::timeout;
use tracing::debug;
use tracing::trace;
/// Implementation for the classic Chat Completions API.
@@ -828,10 +827,7 @@ where
// seen any deltas; otherwise, deltas already built the
// cumulative text and this would duplicate it.
if this.cumulative.is_empty()
&& let ResponseItem::Message {
content,
..
} = &item
&& let ResponseItem::Message { content, .. } = &item
&& let Some(text) = content.iter().find_map(|c| match c {
ContentItem::OutputText { text } => Some(text),
_ => None,
@@ -938,9 +934,7 @@ where
this.cumulative_reasoning.push_str(&delta);
if matches!(this.mode, AggregateMode::Streaming) {
// In streaming mode, also forward the delta immediately.
return Poll::Ready(Some(Ok(
ResponseEvent::ReasoningContentDelta(delta),
)));
return Poll::Ready(Some(Ok(ResponseEvent::ReasoningContentDelta(delta))));
}
}
Poll::Ready(Some(Ok(ResponseEvent::ReasoningSummaryDelta(_)))) => {}

View File

@@ -1,4 +1,3 @@
use std::io::BufRead;
use std::path::Path;
use std::sync::Arc;
use std::time::Duration;
@@ -356,12 +355,11 @@ impl ModelClient {
// stream so downstream consumers (Session) can surface an
// initial TokenCount snapshot, even when the provider does not
// send explicit rate limit headers.
let snapshot = parse_rate_limit_snapshot(resp.headers()).or_else(|| {
Some(RateLimitSnapshot {
let snapshot =
parse_rate_limit_snapshot(resp.headers()).or(Some(RateLimitSnapshot {
primary: None,
secondary: None,
})
});
}));
if let Some(snapshot) = snapshot
&& tx_event
.send(Ok(ResponseEvent::RateLimits(snapshot)))
@@ -945,7 +943,7 @@ async fn handle_sse_event(
*response_error = Some(CodexErr::QuotaExceeded);
} else {
let delay = try_parse_retry_after(&error);
let message = error.message.clone().unwrap_or_default();
let message = error.message.unwrap_or_default();
*response_error = Some(CodexErr::Stream(message, delay));
}
}
@@ -1033,7 +1031,7 @@ mod tests {
use codex_app_server_protocol::AuthMode;
use codex_protocol::ConversationId;
use codex_protocol::models::ResponseItem;
use codex_protocol::protocol::SessionSource;
use futures::StreamExt;
use pretty_assertions::assert_eq;
use serde_json::json;
@@ -1196,7 +1194,7 @@ mod tests {
}
assert_eq!(events.len(), 3);
matches!(events[0], Ok(ResponseEvent::Created {}));
matches!(events[0], Ok(ResponseEvent::Created));
matches!(
&events[1],
Ok(ResponseEvent::OutputItemDone(ResponseItem::Message { role, .. }))