mirror of
https://github.com/openai/codex.git
synced 2026-10-30 19:18:49 +00:00
Remove empty collaboration update fallback
This commit is contained in:
@@ -6638,8 +6638,6 @@ mod tests {
|
||||
use codex_protocol::models::FunctionCallOutputBody;
|
||||
use codex_protocol::models::FunctionCallOutputPayload;
|
||||
|
||||
use crate::protocol::COLLABORATION_MODE_CLOSE_TAG;
|
||||
use crate::protocol::COLLABORATION_MODE_OPEN_TAG;
|
||||
use crate::protocol::CompactedItem;
|
||||
use crate::protocol::CreditsSnapshot;
|
||||
use crate::protocol::InitialHistory;
|
||||
@@ -8968,59 +8966,6 @@ mod tests {
|
||||
assert!(environment_update.contains("<timezone>Europe/Berlin</timezone>"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn build_settings_update_items_emits_empty_collaboration_marker_when_instructions_clear()
|
||||
{
|
||||
let (session, previous_context) = make_session_and_context().await;
|
||||
let previous_context = Arc::new(previous_context);
|
||||
let mut current_context = previous_context
|
||||
.with_model(
|
||||
previous_context.model_info.slug.clone(),
|
||||
&session.services.models_manager,
|
||||
)
|
||||
.await;
|
||||
current_context.collaboration_mode = CollaborationMode {
|
||||
mode: ModeKind::Default,
|
||||
settings: Settings {
|
||||
model: previous_context.collaboration_mode.model().to_string(),
|
||||
reasoning_effort: previous_context.collaboration_mode.reasoning_effort(),
|
||||
developer_instructions: None,
|
||||
},
|
||||
};
|
||||
|
||||
let mut previous_context_item = previous_context.to_turn_context_item();
|
||||
previous_context_item.collaboration_mode = Some(CollaborationMode {
|
||||
mode: ModeKind::Realtime,
|
||||
settings: Settings {
|
||||
model: previous_context.collaboration_mode.model().to_string(),
|
||||
reasoning_effort: previous_context.collaboration_mode.reasoning_effort(),
|
||||
developer_instructions: Some("realtime instructions".to_string()),
|
||||
},
|
||||
});
|
||||
|
||||
let update_items = session.build_settings_update_items(
|
||||
Some(&previous_context_item),
|
||||
None,
|
||||
¤t_context,
|
||||
);
|
||||
|
||||
let developer_update = update_items
|
||||
.iter()
|
||||
.find_map(|item| match item {
|
||||
ResponseItem::Message { role, content, .. } if role == "developer" => {
|
||||
let [ContentItem::InputText { text }] = content.as_slice() else {
|
||||
return None;
|
||||
};
|
||||
Some(text)
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.expect("developer update item should be emitted");
|
||||
assert!(developer_update.contains(&format!(
|
||||
"{COLLABORATION_MODE_OPEN_TAG}{COLLABORATION_MODE_CLOSE_TAG}"
|
||||
)));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn shutdown_resets_realtime_collaboration_mode_to_default() {
|
||||
let (session, _turn_context, _rx) = make_session_and_context_with_rx().await;
|
||||
|
||||
@@ -8,8 +8,6 @@ use codex_protocol::models::ContentItem;
|
||||
use codex_protocol::models::DeveloperInstructions;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
use codex_protocol::openai_models::ModelInfo;
|
||||
use codex_protocol::protocol::COLLABORATION_MODE_CLOSE_TAG;
|
||||
use codex_protocol::protocol::COLLABORATION_MODE_OPEN_TAG;
|
||||
use codex_protocol::protocol::TurnContextItem;
|
||||
|
||||
fn build_environment_update_item(
|
||||
@@ -56,21 +54,12 @@ fn build_collaboration_mode_update_item(
|
||||
) -> Option<DeveloperInstructions> {
|
||||
let prev = previous?;
|
||||
if prev.collaboration_mode.as_ref() != Some(&next.collaboration_mode) {
|
||||
Some(
|
||||
DeveloperInstructions::from_collaboration_mode(&next.collaboration_mode)
|
||||
.unwrap_or_else(empty_collaboration_mode_update),
|
||||
)
|
||||
DeveloperInstructions::from_collaboration_mode(&next.collaboration_mode)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn empty_collaboration_mode_update() -> DeveloperInstructions {
|
||||
DeveloperInstructions::new(format!(
|
||||
"{COLLABORATION_MODE_OPEN_TAG}{COLLABORATION_MODE_CLOSE_TAG}"
|
||||
))
|
||||
}
|
||||
|
||||
fn build_personality_update_item(
|
||||
previous: Option<&TurnContextItem>,
|
||||
next: &TurnContext,
|
||||
|
||||
@@ -622,7 +622,6 @@ async fn collaboration_mode_update_emits_empty_marker_when_instructions_clear()
|
||||
let input = req2.single_request().input();
|
||||
let dev_texts = developer_texts(&input);
|
||||
assert_eq!(count_exact(&dev_texts, &collab_xml(realtime_text)), 1);
|
||||
assert_eq!(count_exact(&dev_texts, &collab_xml("")), 1);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -783,58 +782,3 @@ async fn resume_replays_collaboration_instructions() -> Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn empty_collaboration_instructions_emit_empty_marker() -> Result<()> {
|
||||
skip_if_no_network!(Ok(()));
|
||||
|
||||
let server = start_mock_server().await;
|
||||
let req = mount_sse_once(
|
||||
&server,
|
||||
sse(vec![ev_response_created("resp-1"), ev_completed("resp-1")]),
|
||||
)
|
||||
.await;
|
||||
|
||||
let test = test_codex().build(&server).await?;
|
||||
let current_model = test.session_configured.model.clone();
|
||||
|
||||
test.codex
|
||||
.submit(Op::OverrideTurnContext {
|
||||
cwd: None,
|
||||
approval_policy: None,
|
||||
sandbox_policy: None,
|
||||
windows_sandbox_level: None,
|
||||
model: None,
|
||||
effort: None,
|
||||
summary: None,
|
||||
collaboration_mode: Some(CollaborationMode {
|
||||
mode: ModeKind::Default,
|
||||
settings: Settings {
|
||||
model: current_model,
|
||||
reasoning_effort: None,
|
||||
developer_instructions: Some("".to_string()),
|
||||
},
|
||||
}),
|
||||
personality: None,
|
||||
})
|
||||
.await?;
|
||||
|
||||
test.codex
|
||||
.submit(Op::UserInput {
|
||||
items: vec![UserInput::Text {
|
||||
text: "hello".into(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
final_output_json_schema: None,
|
||||
})
|
||||
.await?;
|
||||
wait_for_event(&test.codex, |ev| matches!(ev, EventMsg::TurnComplete(_))).await;
|
||||
|
||||
let input = req.single_request().input();
|
||||
let dev_texts = developer_texts(&input);
|
||||
assert_eq!(dev_texts.len(), 2);
|
||||
let collab_text = collab_xml("");
|
||||
assert_eq!(count_exact(&dev_texts, &collab_text), 1);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user