codex: preserve empty developer instructions (#16964)

This commit is contained in:
Ahmed Ibrahim
2026-04-06 19:44:52 -07:00
parent 8ecfca3186
commit aafcfec146
3 changed files with 20 additions and 12 deletions
@@ -338,17 +338,22 @@ async fn thread_fork_honors_explicit_null_thread_instructions() -> Result<()> {
expect_instructions,
"unexpected instructions field in payload: {payload:?}"
);
let developer_texts = request.message_input_texts("developer");
if index == 2 {
assert_eq!(
payload.get("instructions"),
Some(&Value::String(String::new()))
);
assert!(
developer_texts.iter().any(|text| text.is_empty()),
"expected explicit empty developerInstructions to produce an empty developer instruction message: {developer_texts:?}"
);
} else {
assert!(
developer_texts.iter().all(|text| !text.is_empty()),
"did not expect empty developer instruction messages: {developer_texts:?}"
);
}
let developer_texts = request.message_input_texts("developer");
assert!(
developer_texts.iter().all(|text| !text.is_empty()),
"did not expect empty developer instruction messages: {developer_texts:?}"
);
}
Ok(())
@@ -252,17 +252,22 @@ async fn turn_start_honors_explicit_null_thread_instructions() -> Result<()> {
expect_instructions,
"unexpected instructions field in payload: {payload:?}"
);
let developer_texts = request.message_input_texts("developer");
if index == 2 {
assert_eq!(
payload.get("instructions"),
Some(&Value::String(String::new()))
);
assert!(
developer_texts.iter().any(|text| text.is_empty()),
"expected explicit empty developerInstructions to produce an empty developer instruction message: {developer_texts:?}"
);
} else {
assert!(
developer_texts.iter().all(|text| !text.is_empty()),
"did not expect empty developer instruction messages: {developer_texts:?}"
);
}
let developer_texts = request.message_input_texts("developer");
assert!(
developer_texts.iter().all(|text| !text.is_empty()),
"did not expect empty developer instruction messages: {developer_texts:?}"
);
}
Ok(())
-2
View File
@@ -3664,7 +3664,6 @@ impl Session {
// stays isolated as its own top-level developer message for guardian subagents.
if !separate_guardian_developer_message
&& let Some(developer_instructions) = turn_context.developer_instructions.as_deref()
&& !developer_instructions.is_empty()
{
developer_sections.push(developer_instructions.to_string());
}
@@ -3779,7 +3778,6 @@ impl Session {
// subagent sees a distinct, easy-to-audit instruction block.
if separate_guardian_developer_message
&& let Some(developer_instructions) = turn_context.developer_instructions.as_deref()
&& !developer_instructions.is_empty()
&& let Some(guardian_developer_message) =
crate::context_manager::updates::build_developer_update_item(vec![
developer_instructions.to_string(),