chore: add phase to message responseitem (#10455)

### What

add wiring for `phase` field on `ResponseItem::Message` to lay
groundwork for differentiating model preambles and final messages.
currently optional.

follows pattern in #9698.

updated schemas with `just write-app-server-schema` so we can see type
changes.

### Tests
Updated existing tests for SSE parsing and hydrating from history
This commit is contained in:
sayan-oai
2026-02-02 18:52:26 -08:00
committed by GitHub
parent 0999fd82b9
commit fc05374344
46 changed files with 323 additions and 4 deletions

View File

@@ -194,6 +194,7 @@ impl Stream for AggregatedStream {
text: std::mem::take(&mut this.cumulative),
}],
end_turn: None,
phase: None,
};
this.pending
.push_back(ResponseEvent::OutputItemDone(aggregated_message));

View File

@@ -387,6 +387,7 @@ mod tests {
text: "hi".to_string(),
}],
end_turn: None,
phase: None,
}];
let req = ChatRequestBuilder::new("gpt-test", "inst", &prompt_input, &[])
.conversation_id(Some("conv-1".into()))
@@ -414,6 +415,7 @@ mod tests {
text: "read these".to_string(),
}],
end_turn: None,
phase: None,
},
ResponseItem::FunctionCall {
id: None,

View File

@@ -224,12 +224,14 @@ mod tests {
role: "assistant".into(),
content: Vec::new(),
end_turn: None,
phase: None,
},
ResponseItem::Message {
id: None,
role: "assistant".into(),
content: Vec::new(),
end_turn: None,
phase: None,
},
];

View File

@@ -331,6 +331,7 @@ async fn append_assistant_text(
role: "assistant".to_string(),
content: vec![],
end_turn: None,
phase: None,
};
*assistant_item = Some(item.clone());
let _ = tx_event

View File

@@ -429,6 +429,7 @@ mod tests {
use super::*;
use assert_matches::assert_matches;
use bytes::Bytes;
use codex_protocol::models::MessagePhase;
use codex_protocol::models::ResponseItem;
use futures::stream;
use pretty_assertions::assert_eq;
@@ -492,7 +493,8 @@ mod tests {
"item": {
"type": "message",
"role": "assistant",
"content": [{"type": "output_text", "text": "Hello"}]
"content": [{"type": "output_text", "text": "Hello"}],
"phase": "commentary"
}
})
.to_string();
@@ -523,8 +525,11 @@ mod tests {
assert_matches!(
&events[0],
Ok(ResponseEvent::OutputItemDone(ResponseItem::Message { role, .. }))
if role == "assistant"
Ok(ResponseEvent::OutputItemDone(ResponseItem::Message {
role,
phase: Some(MessagePhase::Commentary),
..
})) if role == "assistant"
);
assert_matches!(