feat: enable parallel tool calls (#6796)
This commit is contained in:
parent
838531d3e4
commit
f5d9939cda
4 changed files with 44 additions and 2 deletions
|
|
@ -1934,12 +1934,30 @@ async fn run_turn(
|
|||
.client
|
||||
.get_model_family()
|
||||
.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 {
|
||||
input,
|
||||
tools: router.specs(),
|
||||
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(),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ pub enum Feature {
|
|||
RemoteCompaction,
|
||||
/// Enable the default shell tool.
|
||||
ShellTool,
|
||||
/// Allow model to call multiple tools in parallel (only for models supporting it).
|
||||
ParallelToolCalls,
|
||||
}
|
||||
|
||||
impl Feature {
|
||||
|
|
@ -313,6 +315,12 @@ pub const FEATURES: &[FeatureSpec] = &[
|
|||
stage: Stage::Experimental,
|
||||
default_enabled: false,
|
||||
},
|
||||
FeatureSpec {
|
||||
id: Feature::ParallelToolCalls,
|
||||
key: "parallel",
|
||||
stage: Stage::Experimental,
|
||||
default_enabled: false,
|
||||
},
|
||||
FeatureSpec {
|
||||
id: Feature::ShellTool,
|
||||
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(),
|
||||
apply_patch_tool_type: Some(ApplyPatchToolType::Freeform),
|
||||
shell_type: if cfg!(windows) { ConfigShellToolType::ShellCommand } else { ConfigShellToolType::Default },
|
||||
supports_parallel_tool_calls: true,
|
||||
support_verbosity: false,
|
||||
)
|
||||
} 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),
|
||||
base_instructions: GPT_5_1_INSTRUCTIONS.to_string(),
|
||||
default_reasoning_effort: Some(ReasoningEffort::Medium),
|
||||
supports_parallel_tool_calls: true,
|
||||
)
|
||||
} else if slug.starts_with("gpt-5") {
|
||||
model_family!(
|
||||
|
|
|
|||
14
codex-rs/core/templates/parallel/instructions.md
Normal file
14
codex-rs/core/templates/parallel/instructions.md
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Reference in a new issue