mirror of
https://github.com/openai/codex.git
synced 2026-11-12 21:20:34 +00:00
Polish pending transcript queue
This commit is contained in:
@@ -3041,7 +3041,7 @@ impl Session {
|
||||
self.get_pending_turn_input()
|
||||
.await
|
||||
.into_iter()
|
||||
.map(PendingTurnInput::into_response_input_item)
|
||||
.map(ResponseInputItem::from)
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
||||
@@ -350,19 +350,11 @@ async fn interrupting_regular_turn_waiting_on_startup_prewarm_emits_turn_aborted
|
||||
assert!(duration_ms.is_some());
|
||||
|
||||
let history = sess.clone_history().await;
|
||||
let prompt_idx = history.raw_items().iter().position(|item| {
|
||||
matches!(
|
||||
item,
|
||||
ResponseItem::Message {
|
||||
role,
|
||||
content,
|
||||
..
|
||||
} if role == "user"
|
||||
&& content == &[ContentItem::InputText {
|
||||
text: "first prompt".to_string()
|
||||
}]
|
||||
)
|
||||
});
|
||||
let expected_prompt = user_message("first prompt");
|
||||
let prompt_idx = history
|
||||
.raw_items()
|
||||
.iter()
|
||||
.position(|item| item == &expected_prompt);
|
||||
let aborted_idx = history.raw_items().iter().position(|item| {
|
||||
let ResponseItem::Message { role, content, .. } = item else {
|
||||
return false;
|
||||
@@ -375,13 +367,13 @@ async fn interrupting_regular_turn_waiting_on_startup_prewarm_emits_turn_aborted
|
||||
TurnAborted::matches_text(text)
|
||||
})
|
||||
});
|
||||
assert!(
|
||||
prompt_idx.is_some_and(|prompt_idx| {
|
||||
aborted_idx.is_some_and(|aborted_idx| prompt_idx < aborted_idx)
|
||||
}),
|
||||
"expected prompt to be recorded before the interrupted-turn marker: {:?}",
|
||||
history.raw_items()
|
||||
);
|
||||
let (Some(prompt_idx), Some(aborted_idx)) = (prompt_idx, aborted_idx) else {
|
||||
panic!(
|
||||
"expected prompt and interrupted-turn marker in history: {:?}",
|
||||
history.raw_items()
|
||||
);
|
||||
};
|
||||
assert!(prompt_idx < aborted_idx);
|
||||
}
|
||||
|
||||
fn test_model_client_session() -> crate::client::ModelClientSession {
|
||||
|
||||
@@ -78,16 +78,20 @@ pub(crate) struct RunningTask {
|
||||
pub(crate) _timer: Option<codex_otel::Timer>,
|
||||
}
|
||||
|
||||
/// Input queued for ordered transcript recording during an active turn.
|
||||
///
|
||||
/// User prompts keep the original `UserInput` so client-visible turn items can
|
||||
/// preserve UI-only spans such as `text_elements`; model-only response input
|
||||
/// items can stay in their serialized Responses API form.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub(crate) enum PendingTurnInput {
|
||||
UserInput(Vec<UserInput>),
|
||||
ResponseInputItem(ResponseInputItem),
|
||||
}
|
||||
|
||||
impl PendingTurnInput {
|
||||
#[cfg(test)]
|
||||
pub(crate) fn into_response_input_item(self) -> ResponseInputItem {
|
||||
match self {
|
||||
impl From<PendingTurnInput> for ResponseInputItem {
|
||||
fn from(value: PendingTurnInput) -> Self {
|
||||
match value {
|
||||
PendingTurnInput::UserInput(input) => input.into(),
|
||||
PendingTurnInput::ResponseInputItem(input) => input,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user