mirror of
https://github.com/openai/codex.git
synced 2026-11-05 16:29:31 +00:00
feat: enable parallel tool calls (#6796)
This commit is contained in:
1 parent
838531d3e4
commit
f5d9939cda
4 files changed
+44
-2
No files matched your search
@@ -1934,12 +1934,30 @@ async fn run_turn(
|
|||||||
.client
|
.client
|
||||||
.get_model_family()
|
.get_model_family()
|
||||||
.supports_parallel_tool_calls;
|
.supports_parallel_tool_calls;
|
||||||
let parallel_tool_calls = model_supports_parallel;
|
|
||||||
|
// TODO(jif) revert once testing phase is done.
|
||||||
|
let parallel_tool_calls = model_supports_parallel
|
||||||
|
&& sess
|
||||||
|
.state
|
||||||
|
.lock()
|
||||||
|
.await
|
||||||
|
.session_configuration
|
||||||
|
.features
|
||||||
|
.enabled(Feature::ParallelToolCalls);
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
let prompt = Prompt {
|
let prompt = Prompt {
|
||||||
input,
|
input,
|
||||||
tools: router.specs(),
|
tools: router.specs(),
|
||||||
parallel_tool_calls,
|
parallel_tool_calls,
|
||||||
base_instructions_override: turn_context.base_instructions.clone(),
|
base_instructions_override: base_instructions,
|
||||||
output_schema: turn_context.final_output_json_schema.clone(),
|
output_schema: turn_context.final_output_json_schema.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ pub enum Feature {
|
|||||||
RemoteCompaction,
|
RemoteCompaction,
|
||||||
/// Enable the default shell tool.
|
/// Enable the default shell tool.
|
||||||
ShellTool,
|
ShellTool,
|
||||||
|
/// Allow model to call multiple tools in parallel (only for models supporting it).
|
||||||
|
ParallelToolCalls,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Feature {
|
impl Feature {
|
||||||
@@ -313,6 +315,12 @@ pub const FEATURES: &[FeatureSpec] = &[
|
|||||||
stage: Stage::Experimental,
|
stage: Stage::Experimental,
|
||||||
default_enabled: false,
|
default_enabled: false,
|
||||||
},
|
},
|
||||||
|
FeatureSpec {
|
||||||
|
id: Feature::ParallelToolCalls,
|
||||||
|
key: "parallel",
|
||||||
|
stage: Stage::Experimental,
|
||||||
|
default_enabled: false,
|
||||||
|
},
|
||||||
FeatureSpec {
|
FeatureSpec {
|
||||||
id: Feature::ShellTool,
|
id: Feature::ShellTool,
|
||||||
key: "shell_tool",
|
key: "shell_tool",
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ pub fn find_family_for_model(slug: &str) -> Option<ModelFamily> {
|
|||||||
base_instructions: GPT_5_CODEX_INSTRUCTIONS.to_string(),
|
base_instructions: GPT_5_CODEX_INSTRUCTIONS.to_string(),
|
||||||
apply_patch_tool_type: Some(ApplyPatchToolType::Freeform),
|
apply_patch_tool_type: Some(ApplyPatchToolType::Freeform),
|
||||||
shell_type: if cfg!(windows) { ConfigShellToolType::ShellCommand } else { ConfigShellToolType::Default },
|
shell_type: if cfg!(windows) { ConfigShellToolType::ShellCommand } else { ConfigShellToolType::Default },
|
||||||
|
supports_parallel_tool_calls: true,
|
||||||
support_verbosity: false,
|
support_verbosity: false,
|
||||||
)
|
)
|
||||||
} else if slug.starts_with("gpt-5.1") {
|
} else if slug.starts_with("gpt-5.1") {
|
||||||
@@ -189,6 +190,7 @@ pub fn find_family_for_model(slug: &str) -> Option<ModelFamily> {
|
|||||||
default_verbosity: Some(Verbosity::Low),
|
default_verbosity: Some(Verbosity::Low),
|
||||||
base_instructions: GPT_5_1_INSTRUCTIONS.to_string(),
|
base_instructions: GPT_5_1_INSTRUCTIONS.to_string(),
|
||||||
default_reasoning_effort: Some(ReasoningEffort::Medium),
|
default_reasoning_effort: Some(ReasoningEffort::Medium),
|
||||||
|
supports_parallel_tool_calls: true,
|
||||||
)
|
)
|
||||||
} else if slug.starts_with("gpt-5") {
|
} else if slug.starts_with("gpt-5") {
|
||||||
model_family!(
|
model_family!(
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
## Exploration and reading files
|
||||||
|
|
||||||
|
- **Think first.** Before any tool call, decide ALL files/resources you will need.
|
||||||
|
- **Batch everything.** If you need multiple files (even from different places), read them together.
|
||||||
|
- **multi_tool_use.parallel** Use `multi_tool_use.parallel` to parallelize tool calls and only this.
|
||||||
|
- **Only make sequential calls if you truly cannot know the next file without seeing a result first.**
|
||||||
|
- **Workflow:** (a) plan all needed reads → (b) issue one parallel batch → (c) analyze results → (d) repeat if new, unpredictable reads arise.
|
||||||
|
|
||||||
|
**Additional notes**:
|
||||||
|
* 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
|
||||||
Reference in new issue
Block a user