From 82d7d2ddb67b84fe5455ceca0bea59f729c7705f Mon Sep 17 00:00:00 2001 From: jif-oai Date: Wed, 19 Nov 2025 10:04:24 +0000 Subject: [PATCH 1/3] fix: parallel tool call instruction injection --- codex-rs/core/src/codex.rs | 10 +++++----- codex-rs/core/templates/parallel/instructions.md | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index 5156ed6453..d221863cd8 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -1982,12 +1982,12 @@ async fn run_turn( let mut base_instructions = turn_context.base_instructions.clone(); if parallel_tool_calls { static INSTRUCTIONS: &str = include_str!("../templates/parallel/instructions.md"); - static INSERTION_SPOT: &str = "## Editing constraints"; - base_instructions - .as_mut() - .map(|base| base.replace(INSERTION_SPOT, INSTRUCTIONS)); + if let Some(family) = find_family_for_model(&sess.state.lock().await.session_configuration.model) { + let mut new_instructions = family.base_instructions; + new_instructions.push_str(INSTRUCTIONS); + base_instructions = Some(new_instructions); + } } - let prompt = Prompt { input, tools: router.specs(), diff --git a/codex-rs/core/templates/parallel/instructions.md b/codex-rs/core/templates/parallel/instructions.md index d690501af7..292d585e45 100644 --- a/codex-rs/core/templates/parallel/instructions.md +++ b/codex-rs/core/templates/parallel/instructions.md @@ -1,3 +1,4 @@ + ## Exploration and reading files - **Think first.** Before any tool call, decide ALL files/resources you will need. @@ -10,5 +11,3 @@ * Always maximize parallelism. Never read files one-by-one unless logically unavoidable. * This concern every read/list/search operations including, but not only, `cat`, `rg`, `sed`, `ls`, `git show`, `nl`, `wc`, ... * Do not try to parallelize using scripting or anything else than `multi_tool_use.parallel`. - -## Editing constraints \ No newline at end of file From c021cf1bd59162a2deb7dd4686c9dbcceef0ee27 Mon Sep 17 00:00:00 2001 From: jif-oai Date: Wed, 19 Nov 2025 10:05:30 +0000 Subject: [PATCH 2/3] FMT --- codex-rs/core/src/codex.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index d221863cd8..b72dcaea28 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -1982,7 +1982,9 @@ async fn run_turn( let mut base_instructions = turn_context.base_instructions.clone(); if parallel_tool_calls { static INSTRUCTIONS: &str = include_str!("../templates/parallel/instructions.md"); - if let Some(family) = find_family_for_model(&sess.state.lock().await.session_configuration.model) { + if let Some(family) = + find_family_for_model(&sess.state.lock().await.session_configuration.model) + { let mut new_instructions = family.base_instructions; new_instructions.push_str(INSTRUCTIONS); base_instructions = Some(new_instructions); From 4eb9e149d8ffc920a7b4e071fb56396ccd50b29e Mon Sep 17 00:00:00 2001 From: jif-oai Date: Wed, 19 Nov 2025 10:17:59 +0000 Subject: [PATCH 3/3] Fix --- codex-rs/core/src/codex.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index b72dcaea28..b810366f0a 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -1985,7 +1985,7 @@ async fn run_turn( if let Some(family) = find_family_for_model(&sess.state.lock().await.session_configuration.model) { - let mut new_instructions = family.base_instructions; + let mut new_instructions = base_instructions.unwrap_or(family.base_instructions); new_instructions.push_str(INSTRUCTIONS); base_instructions = Some(new_instructions); }