mirror of
https://github.com/openai/codex.git
synced 2026-04-24 06:35:50 +00:00
change-web-search
This commit is contained in:
@@ -1981,36 +1981,14 @@ async fn run_turn(
|
||||
.get_model_family()
|
||||
.supports_parallel_tool_calls;
|
||||
let parallel_tool_calls = model_supports_parallel;
|
||||
let mut allowed_tools = Vec::new();
|
||||
let mut restricted_tool_choice = false;
|
||||
for tool in router.allowed_tools() {
|
||||
let is_disabled = tool
|
||||
.get("name")
|
||||
.and_then(|val| val.as_str())
|
||||
.is_some_and(|name| {
|
||||
turn_context
|
||||
.disabled_tools
|
||||
.iter()
|
||||
.any(|disabled| disabled.matches_tool_name(name))
|
||||
});
|
||||
if is_disabled {
|
||||
restricted_tool_choice = true;
|
||||
continue;
|
||||
}
|
||||
allowed_tools.push(tool);
|
||||
}
|
||||
let allowed_tools = if restricted_tool_choice {
|
||||
Some(allowed_tools)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let allowed_tools = router.allowed_tools(turn_context.disabled_tools.clone());
|
||||
let prompt = Prompt {
|
||||
input,
|
||||
tools: router.specs(),
|
||||
parallel_tool_calls,
|
||||
base_instructions_override: turn_context.base_instructions.clone(),
|
||||
output_schema: turn_context.final_output_json_schema.clone(),
|
||||
allowed_tools,
|
||||
allowed_tools: Some(allowed_tools),
|
||||
};
|
||||
|
||||
let mut retries = 0;
|
||||
|
||||
@@ -16,6 +16,7 @@ use codex_protocol::models::LocalShellAction;
|
||||
use codex_protocol::models::ResponseInputItem;
|
||||
use codex_protocol::models::ResponseItem;
|
||||
use codex_protocol::models::ShellToolCallParams;
|
||||
use codex_protocol::protocol::DisabledTool;
|
||||
use serde_json::json;
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -48,12 +49,18 @@ impl ToolRouter {
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn allowed_tools(&self) -> Vec<serde_json::Value> {
|
||||
pub fn allowed_tools(&self, disabled_tools: Vec<DisabledTool>) -> Vec<serde_json::Value> {
|
||||
self.specs
|
||||
.iter()
|
||||
.map(|config| {
|
||||
.filter_map(|config| {
|
||||
let name = config.spec.name();
|
||||
json!({"type": "function", "name": name})
|
||||
if disabled_tools
|
||||
.iter()
|
||||
.any(|disabled| disabled.matches_tool_name(name))
|
||||
{
|
||||
return None;
|
||||
}
|
||||
Some(json!({"type": "function", "name": name}))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user