mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
Preserve assistant phase for replayed messages (#19832)
This commit is contained in:
committed by
GitHub
Unverified
parent
21e19912e0
commit
598bbcdb58
@@ -609,6 +609,9 @@ pub enum ResponseInputItem {
|
||||
Message {
|
||||
role: String,
|
||||
content: Vec<ContentItem>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
phase: Option<MessagePhase>,
|
||||
},
|
||||
FunctionCallOutput {
|
||||
call_id: String,
|
||||
@@ -1034,11 +1037,15 @@ pub fn local_image_content_items_with_label_number(
|
||||
impl From<ResponseInputItem> for ResponseItem {
|
||||
fn from(item: ResponseInputItem) -> Self {
|
||||
match item {
|
||||
ResponseInputItem::Message { role, content } => Self::Message {
|
||||
ResponseInputItem::Message {
|
||||
role,
|
||||
content,
|
||||
phase,
|
||||
} => Self::Message {
|
||||
role,
|
||||
content,
|
||||
id: None,
|
||||
phase: None,
|
||||
phase,
|
||||
},
|
||||
ResponseInputItem::FunctionCallOutput { call_id, output } => {
|
||||
Self::FunctionCallOutput { call_id, output }
|
||||
@@ -1176,6 +1183,7 @@ impl From<Vec<UserInput>> for ResponseInputItem {
|
||||
UserInput::Skill { .. } | UserInput::Mention { .. } => Vec::new(), // Tool bodies are injected later in core
|
||||
})
|
||||
.collect::<Vec<ContentItem>>(),
|
||||
phase: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1581,6 +1589,29 @@ mod tests {
|
||||
use std::path::PathBuf;
|
||||
use tempfile::tempdir;
|
||||
|
||||
#[test]
|
||||
fn response_input_message_conversion_preserves_phase() {
|
||||
let item = ResponseItem::from(ResponseInputItem::Message {
|
||||
role: "assistant".to_string(),
|
||||
content: vec![ContentItem::OutputText {
|
||||
text: "still working".to_string(),
|
||||
}],
|
||||
phase: Some(MessagePhase::Commentary),
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
item,
|
||||
ResponseItem::Message {
|
||||
id: None,
|
||||
role: "assistant".to_string(),
|
||||
content: vec![ContentItem::OutputText {
|
||||
text: "still working".to_string(),
|
||||
}],
|
||||
phase: Some(MessagePhase::Commentary),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sandbox_permissions_helpers_match_documented_semantics() {
|
||||
let cases = [
|
||||
|
||||
@@ -855,6 +855,7 @@ impl InterAgentCommunication {
|
||||
content: vec![ContentItem::OutputText {
|
||||
text: serde_json::to_string(self).unwrap_or_default(),
|
||||
}],
|
||||
phase: Some(MessagePhase::Commentary),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user