mirror of
https://github.com/openai/codex.git
synced 2026-11-06 20:20:34 +00:00
codex: move response metadata filtering upstream
Filter rollout-only response metadata out of resumed initial messages in protocol, so app-server does not need to scrub SessionConfigured history. Keep app-server's live event suppression so ResponseMetadata stays out of the public interface. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
co-authored by
Codex
parent
792478ef87
commit
24eebd7d5c
@@ -5837,19 +5837,9 @@ impl CodexMessageProcessor {
|
||||
break;
|
||||
}
|
||||
};
|
||||
let mut public_event = event.clone();
|
||||
match &mut public_event.msg {
|
||||
EventMsg::ResponseMetadata(_) => continue,
|
||||
EventMsg::SessionConfigured(session_configured) => {
|
||||
if let Some(initial_messages) =
|
||||
session_configured.initial_messages.as_mut()
|
||||
{
|
||||
initial_messages.retain(|msg| {
|
||||
!matches!(msg, EventMsg::ResponseMetadata(_))
|
||||
});
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
let public_event = event.clone();
|
||||
if matches!(public_event.msg, EventMsg::ResponseMetadata(_)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// For now, we send a notification for every event,
|
||||
|
||||
@@ -67,18 +67,12 @@ async fn resume_includes_initial_messages_from_rollout_events() -> Result<()> {
|
||||
EventMsg::TurnStarted(started),
|
||||
EventMsg::UserMessage(first_user),
|
||||
EventMsg::TokenCount(_),
|
||||
EventMsg::ResponseMetadata(response_metadata),
|
||||
EventMsg::AgentMessage(assistant_message),
|
||||
EventMsg::TokenCount(_),
|
||||
EventMsg::TurnComplete(completed),
|
||||
] => {
|
||||
assert_eq!(first_user.message, "Record some messages");
|
||||
assert_eq!(first_user.text_elements, text_elements);
|
||||
assert_eq!(response_metadata.request_id, None);
|
||||
assert_eq!(
|
||||
response_metadata.response_id.as_deref(),
|
||||
Some("resp-initial")
|
||||
);
|
||||
assert_eq!(assistant_message.message, "Completed first turn");
|
||||
assert_eq!(completed.turn_id, started.turn_id);
|
||||
assert_eq!(
|
||||
@@ -139,7 +133,6 @@ async fn resume_includes_initial_messages_from_reasoning_events() -> Result<()>
|
||||
EventMsg::TurnStarted(started),
|
||||
EventMsg::UserMessage(first_user),
|
||||
EventMsg::TokenCount(_),
|
||||
EventMsg::ResponseMetadata(response_metadata),
|
||||
EventMsg::AgentReasoning(reasoning),
|
||||
EventMsg::AgentReasoningRawContent(raw),
|
||||
EventMsg::AgentMessage(assistant_message),
|
||||
@@ -147,11 +140,6 @@ async fn resume_includes_initial_messages_from_reasoning_events() -> Result<()>
|
||||
EventMsg::TurnComplete(completed),
|
||||
] => {
|
||||
assert_eq!(first_user.message, "Record reasoning messages");
|
||||
assert_eq!(response_metadata.request_id, None);
|
||||
assert_eq!(
|
||||
response_metadata.response_id.as_deref(),
|
||||
Some("resp-initial")
|
||||
);
|
||||
assert_eq!(reasoning.text, "Summarized step");
|
||||
assert_eq!(raw.text, "raw detail");
|
||||
assert_eq!(assistant_message.message, "Completed reasoning turn");
|
||||
|
||||
@@ -1979,7 +1979,11 @@ impl InitialHistory {
|
||||
.history
|
||||
.iter()
|
||||
.filter_map(|ri| match ri {
|
||||
RolloutItem::EventMsg(ev) => Some(ev.clone()),
|
||||
RolloutItem::EventMsg(ev)
|
||||
if !matches!(ev, EventMsg::ResponseMetadata(_)) =>
|
||||
{
|
||||
Some(ev.clone())
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect(),
|
||||
@@ -1988,7 +1992,11 @@ impl InitialHistory {
|
||||
items
|
||||
.iter()
|
||||
.filter_map(|ri| match ri {
|
||||
RolloutItem::EventMsg(ev) => Some(ev.clone()),
|
||||
RolloutItem::EventMsg(ev)
|
||||
if !matches!(ev, EventMsg::ResponseMetadata(_)) =>
|
||||
{
|
||||
Some(ev.clone())
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect(),
|
||||
|
||||
Reference in New Issue
Block a user