mirror of
https://github.com/openai/codex.git
synced 2026-11-25 23:30:49 +00:00
websearch
This commit is contained in:
@@ -15,6 +15,7 @@ use codex_protocol::protocol::FileChange;
|
||||
use codex_protocol::protocol::ReviewDecision;
|
||||
use codex_protocol::protocol::SandboxPolicy;
|
||||
use codex_protocol::protocol::TurnAbortReason;
|
||||
use codex_protocol::protocol::default_disabled_tools;
|
||||
use paste::paste;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
@@ -550,6 +551,8 @@ pub struct SendUserTurnParams {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub effort: Option<ReasoningEffort>,
|
||||
pub summary: ReasoningSummary,
|
||||
#[serde(default = "default_disabled_tools")]
|
||||
pub disabled_tools: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, TS)]
|
||||
|
||||
@@ -1015,6 +1015,7 @@ impl CodexMessageProcessor {
|
||||
model,
|
||||
effort,
|
||||
summary,
|
||||
disabled_tools,
|
||||
} = params;
|
||||
|
||||
let Ok(conversation) = self
|
||||
@@ -1050,6 +1051,7 @@ impl CodexMessageProcessor {
|
||||
effort,
|
||||
summary,
|
||||
final_output_json_schema: None,
|
||||
disabled_tools,
|
||||
})
|
||||
.await;
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ use codex_protocol::config_types::SandboxMode;
|
||||
use codex_protocol::protocol::Event;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
use codex_protocol::protocol::InputMessageKind;
|
||||
use codex_protocol::protocol::default_disabled_tools;
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::env;
|
||||
use tempfile::TempDir;
|
||||
@@ -345,6 +346,7 @@ async fn test_send_user_turn_changes_approval_policy_behavior() {
|
||||
model: "mock-model".to_string(),
|
||||
effort: Some(ReasoningEffort::Medium),
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await
|
||||
.expect("send sendUserTurn");
|
||||
@@ -483,6 +485,7 @@ async fn test_send_user_turn_updates_sandbox_and_cwd_between_turns() {
|
||||
model: model.clone(),
|
||||
effort: Some(ReasoningEffort::Medium),
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await
|
||||
.expect("send first sendUserTurn");
|
||||
@@ -513,6 +516,7 @@ async fn test_send_user_turn_updates_sandbox_and_cwd_between_turns() {
|
||||
model: model.clone(),
|
||||
effort: Some(ReasoningEffort::Medium),
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await
|
||||
.expect("send second sendUserTurn");
|
||||
|
||||
@@ -239,6 +239,7 @@ impl ModelClient {
|
||||
instructions: &full_instructions,
|
||||
input: &input_with_instructions,
|
||||
tools: &tools_json,
|
||||
allowed_tools: prompt.allowed_tools.as_slice(),
|
||||
tool_choice: "auto",
|
||||
parallel_tool_calls: prompt.parallel_tool_calls,
|
||||
reasoning,
|
||||
|
||||
@@ -41,6 +41,9 @@ pub struct Prompt {
|
||||
|
||||
/// Optional the output schema for the model's response.
|
||||
pub output_schema: Option<Value>,
|
||||
|
||||
/// The set of tools that are allowed to be used by the model.
|
||||
pub(crate) allowed_tools: Vec<Value>,
|
||||
}
|
||||
|
||||
impl Prompt {
|
||||
@@ -87,6 +90,10 @@ impl Prompt {
|
||||
}
|
||||
}
|
||||
|
||||
fn json_slice_is_empty(values: &[Value]) -> bool {
|
||||
values.is_empty()
|
||||
}
|
||||
|
||||
fn reserialize_shell_outputs(items: &mut [ResponseItem]) {
|
||||
let mut shell_call_ids: HashSet<String> = HashSet::new();
|
||||
|
||||
@@ -268,6 +275,8 @@ pub(crate) struct ResponsesApiRequest<'a> {
|
||||
// separate enum for serialization.
|
||||
pub(crate) input: &'a Vec<ResponseItem>,
|
||||
pub(crate) tools: &'a [serde_json::Value],
|
||||
#[serde(skip_serializing_if = "json_slice_is_empty")]
|
||||
pub(crate) allowed_tools: &'a [serde_json::Value],
|
||||
pub(crate) tool_choice: &'static str,
|
||||
pub(crate) parallel_tool_calls: bool,
|
||||
pub(crate) reasoning: Option<Reasoning>,
|
||||
@@ -457,6 +466,7 @@ mod tests {
|
||||
instructions: "i",
|
||||
input: &input,
|
||||
tools: &tools,
|
||||
allowed_tools: &[],
|
||||
tool_choice: "auto",
|
||||
parallel_tool_calls: true,
|
||||
reasoning: None,
|
||||
@@ -498,6 +508,7 @@ mod tests {
|
||||
instructions: "i",
|
||||
input: &input,
|
||||
tools: &tools,
|
||||
allowed_tools: &[],
|
||||
tool_choice: "auto",
|
||||
parallel_tool_calls: true,
|
||||
reasoning: None,
|
||||
@@ -534,6 +545,7 @@ mod tests {
|
||||
instructions: "i",
|
||||
input: &input,
|
||||
tools: &tools,
|
||||
allowed_tools: &[],
|
||||
tool_choice: "auto",
|
||||
parallel_tool_calls: true,
|
||||
reasoning: None,
|
||||
@@ -547,4 +559,50 @@ mod tests {
|
||||
let v = serde_json::to_value(&req).expect("json");
|
||||
assert!(v.get("text").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serializes_allowed_tools_when_present() {
|
||||
let input: Vec<ResponseItem> = vec![];
|
||||
let tools: Vec<serde_json::Value> = vec![];
|
||||
let allowed = vec![serde_json::json!({
|
||||
"type": "function",
|
||||
"name": "get_weather"
|
||||
})];
|
||||
let req = ResponsesApiRequest {
|
||||
model: "gpt-5",
|
||||
instructions: "i",
|
||||
input: &input,
|
||||
tools: &tools,
|
||||
allowed_tools: allowed.as_slice(),
|
||||
tool_choice: "auto",
|
||||
parallel_tool_calls: true,
|
||||
reasoning: None,
|
||||
store: false,
|
||||
stream: true,
|
||||
include: vec![],
|
||||
prompt_cache_key: None,
|
||||
text: None,
|
||||
};
|
||||
|
||||
let v = serde_json::to_value(&req).expect("json");
|
||||
assert_eq!(
|
||||
v.get("allowed_tools")
|
||||
.and_then(|val| val.as_array())
|
||||
.map(std::vec::Vec::len),
|
||||
Some(1)
|
||||
);
|
||||
let first = v
|
||||
.get("allowed_tools")
|
||||
.and_then(|val| val.as_array())
|
||||
.and_then(|arr| arr.first())
|
||||
.expect("allowed tool entry");
|
||||
assert_eq!(
|
||||
first.get("type"),
|
||||
Some(&serde_json::Value::String("function".into()))
|
||||
);
|
||||
assert_eq!(
|
||||
first.get("name"),
|
||||
Some(&serde_json::Value::String("get_weather".into()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ use codex_protocol::protocol::SessionSource;
|
||||
use codex_protocol::protocol::TaskStartedEvent;
|
||||
use codex_protocol::protocol::TurnAbortReason;
|
||||
use codex_protocol::protocol::TurnContextItem;
|
||||
use codex_protocol::protocol::default_disabled_tools;
|
||||
use futures::future::BoxFuture;
|
||||
use futures::prelude::*;
|
||||
use futures::stream::FuturesOrdered;
|
||||
@@ -264,6 +265,7 @@ pub(crate) struct TurnContext {
|
||||
pub(crate) tools_config: ToolsConfig,
|
||||
pub(crate) is_review_mode: bool,
|
||||
pub(crate) final_output_json_schema: Option<Value>,
|
||||
pub(crate) disabled_tools: Vec<String>,
|
||||
}
|
||||
|
||||
impl TurnContext {
|
||||
@@ -459,6 +461,7 @@ impl Session {
|
||||
cwd,
|
||||
is_review_mode: false,
|
||||
final_output_json_schema: None,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
};
|
||||
let services = SessionServices {
|
||||
mcp_connection_manager,
|
||||
@@ -1142,6 +1145,7 @@ async fn submission_loop(
|
||||
model,
|
||||
effort,
|
||||
summary,
|
||||
disabled_tools,
|
||||
} => {
|
||||
// Recalculate the persistent turn context with provided overrides.
|
||||
let prev = Arc::clone(&turn_context);
|
||||
@@ -1207,6 +1211,7 @@ async fn submission_loop(
|
||||
cwd: new_cwd.clone(),
|
||||
is_review_mode: false,
|
||||
final_output_json_schema: None,
|
||||
disabled_tools: disabled_tools.unwrap_or_else(default_disabled_tools),
|
||||
};
|
||||
|
||||
// Install the new persistent context for subsequent tasks/turns.
|
||||
@@ -1245,6 +1250,7 @@ async fn submission_loop(
|
||||
effort,
|
||||
summary,
|
||||
final_output_json_schema,
|
||||
disabled_tools,
|
||||
} => {
|
||||
turn_context
|
||||
.client
|
||||
@@ -1300,6 +1306,7 @@ async fn submission_loop(
|
||||
cwd,
|
||||
is_review_mode: false,
|
||||
final_output_json_schema,
|
||||
disabled_tools,
|
||||
};
|
||||
|
||||
// if the environment context has changed, record it in the conversation history
|
||||
@@ -1579,6 +1586,7 @@ async fn spawn_review_thread(
|
||||
cwd: parent_turn_context.cwd.clone(),
|
||||
is_review_mode: true,
|
||||
final_output_json_schema: None,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
};
|
||||
|
||||
// Seed the child task with the review prompt as the initial user message.
|
||||
@@ -1945,12 +1953,27 @@ async fn run_turn(
|
||||
.get_model_family()
|
||||
.supports_parallel_tool_calls;
|
||||
let parallel_tool_calls = model_supports_parallel;
|
||||
let allowed_tools = router
|
||||
.allowed_tools()
|
||||
.into_iter()
|
||||
.filter(|tool| {
|
||||
tool.get("name")
|
||||
.and_then(|val| val.as_str())
|
||||
.is_none_or(|name| {
|
||||
!turn_context
|
||||
.disabled_tools
|
||||
.iter()
|
||||
.any(|disabled| disabled == name)
|
||||
})
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
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,
|
||||
};
|
||||
|
||||
let mut retries = 0;
|
||||
@@ -2758,6 +2781,7 @@ mod tests {
|
||||
tools_config,
|
||||
is_review_mode: false,
|
||||
final_output_json_schema: None,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
};
|
||||
let services = SessionServices {
|
||||
mcp_connection_manager: McpConnectionManager::default(),
|
||||
@@ -2826,6 +2850,7 @@ mod tests {
|
||||
tools_config,
|
||||
is_review_mode: false,
|
||||
final_output_json_schema: None,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
});
|
||||
let services = SessionServices {
|
||||
mcp_connection_manager: McpConnectionManager::default(),
|
||||
|
||||
@@ -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 serde_json::json;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ToolCall {
|
||||
@@ -47,6 +48,20 @@ impl ToolRouter {
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn allowed_tools(&self) -> Vec<serde_json::Value> {
|
||||
// return vector of "tools": [
|
||||
// { "type": "function", "name": "get_weather" },
|
||||
//{ "type": "function", "name": "search_docs" }
|
||||
//]
|
||||
self.specs
|
||||
.iter()
|
||||
.map(|config| {
|
||||
let name = config.spec.name();
|
||||
json!({"type": "function", "name": name})
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn tool_supports_parallel(&self, tool_name: &str) -> bool {
|
||||
self.specs
|
||||
.iter()
|
||||
|
||||
@@ -123,7 +123,8 @@ async fn compact_resume_and_fork_preserve_model_history_view() {
|
||||
.as_str()
|
||||
.unwrap_or_default()
|
||||
.to_string();
|
||||
let tool_calls = json!(requests[0]["tools"].as_array());
|
||||
let tool_calls = requests[0]["tools"].clone();
|
||||
let allowed_tools = requests[0]["allowed_tools"].clone();
|
||||
let prompt_cache_key = requests[0]["prompt_cache_key"]
|
||||
.as_str()
|
||||
.unwrap_or_default()
|
||||
@@ -170,6 +171,7 @@ async fn compact_resume_and_fork_preserve_model_history_view() {
|
||||
}
|
||||
],
|
||||
"tools": tool_calls,
|
||||
"allowed_tools": allowed_tools,
|
||||
"tool_choice": "auto",
|
||||
"parallel_tool_calls": false,
|
||||
"reasoning": {
|
||||
@@ -239,6 +241,7 @@ async fn compact_resume_and_fork_preserve_model_history_view() {
|
||||
}
|
||||
],
|
||||
"tools": [],
|
||||
"allowed_tools": allowed_tools,
|
||||
"tool_choice": "auto",
|
||||
"parallel_tool_calls": false,
|
||||
"reasoning": {
|
||||
@@ -304,6 +307,7 @@ SUMMARY_ONLY_CONTEXT"
|
||||
}
|
||||
],
|
||||
"tools": tool_calls,
|
||||
"allowed_tools": allowed_tools,
|
||||
"tool_choice": "auto",
|
||||
"parallel_tool_calls": false,
|
||||
"reasoning": {
|
||||
@@ -389,6 +393,7 @@ SUMMARY_ONLY_CONTEXT"
|
||||
}
|
||||
],
|
||||
"tools": tool_calls,
|
||||
"allowed_tools": allowed_tools,
|
||||
"tool_choice": "auto",
|
||||
"parallel_tool_calls": false,
|
||||
"reasoning": {
|
||||
@@ -474,6 +479,7 @@ SUMMARY_ONLY_CONTEXT"
|
||||
}
|
||||
],
|
||||
"tools": tool_calls,
|
||||
"allowed_tools": allowed_tools,
|
||||
"tool_choice": "auto",
|
||||
"parallel_tool_calls": false,
|
||||
"reasoning": {
|
||||
@@ -495,6 +501,7 @@ SUMMARY_ONLY_CONTEXT"
|
||||
]);
|
||||
normalize_line_endings(&mut expected);
|
||||
assert_eq!(requests.len(), 5);
|
||||
dbg!(&expected);
|
||||
assert_eq!(json!(requests), expected);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ use codex_core::protocol::EventMsg;
|
||||
use codex_core::protocol::InputItem;
|
||||
use codex_core::protocol::Op;
|
||||
use codex_core::protocol::SandboxPolicy;
|
||||
use codex_core::protocol::default_disabled_tools;
|
||||
use codex_protocol::config_types::ReasoningSummary;
|
||||
use core_test_support::responses;
|
||||
use core_test_support::responses::ev_assistant_message;
|
||||
@@ -159,6 +160,7 @@ async fn submit_turn(test: &TestCodex, prompt: &str) -> Result<()> {
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ use codex_core::protocol::EventMsg;
|
||||
use codex_core::protocol::InputItem;
|
||||
use codex_core::protocol::Op;
|
||||
use codex_core::protocol::SandboxPolicy;
|
||||
use codex_core::protocol::default_disabled_tools;
|
||||
use codex_protocol::config_types::ReasoningSummary;
|
||||
use core_test_support::responses;
|
||||
use core_test_support::skip_if_no_network;
|
||||
@@ -84,6 +85,7 @@ async fn codex_returns_json_result(model: String) -> anyhow::Result<()> {
|
||||
model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ use codex_core::protocol::EventMsg;
|
||||
use codex_core::protocol::InputItem;
|
||||
use codex_core::protocol::Op;
|
||||
use codex_core::protocol::SandboxPolicy;
|
||||
use codex_core::protocol::default_disabled_tools;
|
||||
use codex_protocol::config_types::ReasoningSummary;
|
||||
use core_test_support::responses;
|
||||
use core_test_support::responses::ev_assistant_message;
|
||||
@@ -76,6 +77,7 @@ async fn list_dir_tool_returns_entries() -> anyhow::Result<()> {
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
@@ -181,6 +183,7 @@ async fn list_dir_tool_depth_one_omits_children() -> anyhow::Result<()> {
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
@@ -293,6 +296,7 @@ async fn list_dir_tool_depth_two_includes_children_only() -> anyhow::Result<()>
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
@@ -408,6 +412,7 @@ async fn list_dir_tool_depth_three_includes_grandchildren() -> anyhow::Result<()
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ async fn override_turn_context_does_not_persist_when_config_exists() {
|
||||
model: Some("o3".to_string()),
|
||||
effort: Some(Some(ReasoningEffort::High)),
|
||||
summary: None,
|
||||
disabled_tools: None,
|
||||
})
|
||||
.await
|
||||
.expect("submit override");
|
||||
@@ -78,6 +79,7 @@ async fn override_turn_context_does_not_create_config_file() {
|
||||
model: Some("o3".to_string()),
|
||||
effort: Some(Some(ReasoningEffort::Medium)),
|
||||
summary: None,
|
||||
disabled_tools: None,
|
||||
})
|
||||
.await
|
||||
.expect("submit override");
|
||||
|
||||
@@ -12,6 +12,7 @@ use codex_core::protocol::EventMsg;
|
||||
use codex_core::protocol::InputItem;
|
||||
use codex_core::protocol::Op;
|
||||
use codex_core::protocol::SandboxPolicy;
|
||||
use codex_core::protocol::default_disabled_tools;
|
||||
use codex_core::protocol_config_types::ReasoningEffort;
|
||||
use codex_core::protocol_config_types::ReasoningSummary;
|
||||
use codex_core::shell::Shell;
|
||||
@@ -443,6 +444,7 @@ async fn overrides_turn_context_but_keeps_cached_prefix_and_key_constant() {
|
||||
model: Some("o3".to_string()),
|
||||
effort: Some(Some(ReasoningEffort::High)),
|
||||
summary: Some(ReasoningSummary::Detailed),
|
||||
disabled_tools: None,
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
@@ -577,6 +579,7 @@ async fn per_turn_overrides_keep_cached_prefix_and_key_constant() {
|
||||
effort: Some(ReasoningEffort::High),
|
||||
summary: ReasoningSummary::Detailed,
|
||||
final_output_json_schema: None,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
@@ -688,6 +691,7 @@ async fn send_user_turn_with_no_changes_does_not_send_environment_context() {
|
||||
effort: default_effort,
|
||||
summary: default_summary,
|
||||
final_output_json_schema: None,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
@@ -705,6 +709,7 @@ async fn send_user_turn_with_no_changes_does_not_send_environment_context() {
|
||||
effort: default_effort,
|
||||
summary: default_summary,
|
||||
final_output_json_schema: None,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
@@ -802,6 +807,7 @@ async fn send_user_turn_with_changes_sends_environment_context() {
|
||||
effort: default_effort,
|
||||
summary: default_summary,
|
||||
final_output_json_schema: None,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
@@ -819,6 +825,7 @@ async fn send_user_turn_with_changes_sends_environment_context() {
|
||||
effort: Some(ReasoningEffort::High),
|
||||
summary: ReasoningSummary::Detailed,
|
||||
final_output_json_schema: None,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -5,6 +5,7 @@ use codex_core::protocol::EventMsg;
|
||||
use codex_core::protocol::InputItem;
|
||||
use codex_core::protocol::Op;
|
||||
use codex_core::protocol::SandboxPolicy;
|
||||
use codex_core::protocol::default_disabled_tools;
|
||||
use codex_protocol::config_types::ReasoningSummary;
|
||||
use core_test_support::responses;
|
||||
use core_test_support::responses::ev_assistant_message;
|
||||
@@ -74,6 +75,7 @@ async fn read_file_tool_returns_requested_lines() -> anyhow::Result<()> {
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ use codex_core::protocol::EventMsg;
|
||||
use codex_core::protocol::InputItem;
|
||||
use codex_core::protocol::Op;
|
||||
use codex_core::protocol::SandboxPolicy;
|
||||
use codex_core::protocol::default_disabled_tools;
|
||||
use codex_protocol::config_types::ReasoningSummary;
|
||||
use core_test_support::responses;
|
||||
use core_test_support::responses::mount_sse_once_match;
|
||||
@@ -110,6 +111,7 @@ async fn stdio_server_round_trip() -> anyhow::Result<()> {
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
@@ -259,6 +261,7 @@ async fn streamable_http_tool_call_round_trip() -> anyhow::Result<()> {
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
@@ -440,6 +443,7 @@ async fn streamable_http_with_oauth_round_trip() -> anyhow::Result<()> {
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use codex_core::protocol::EventMsg;
|
||||
use codex_core::protocol::InputItem;
|
||||
use codex_core::protocol::Op;
|
||||
use codex_core::protocol::SandboxPolicy;
|
||||
use codex_core::protocol::default_disabled_tools;
|
||||
use codex_protocol::config_types::ReasoningSummary;
|
||||
use core_test_support::assert_regex_match;
|
||||
use core_test_support::responses::ev_apply_patch_function_call;
|
||||
@@ -45,6 +46,7 @@ async fn submit_turn(test: &TestCodex, prompt: &str, sandbox_policy: SandboxPoli
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ use codex_core::protocol::EventMsg;
|
||||
use codex_core::protocol::InputItem;
|
||||
use codex_core::protocol::Op;
|
||||
use codex_core::protocol::SandboxPolicy;
|
||||
use codex_core::protocol::default_disabled_tools;
|
||||
use codex_protocol::config_types::ReasoningSummary;
|
||||
use codex_protocol::plan_tool::StepStatus;
|
||||
use core_test_support::assert_regex_match;
|
||||
@@ -84,6 +85,7 @@ async fn shell_tool_executes_command_and_streams_output() -> anyhow::Result<()>
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
@@ -153,6 +155,7 @@ async fn update_plan_tool_emits_plan_update_event() -> anyhow::Result<()> {
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
@@ -236,6 +239,7 @@ async fn update_plan_tool_rejects_malformed_payload() -> anyhow::Result<()> {
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
@@ -334,6 +338,7 @@ async fn apply_patch_tool_executes_and_emits_patch_events() -> anyhow::Result<()
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
@@ -435,6 +440,7 @@ async fn apply_patch_reports_parse_diagnostics() -> anyhow::Result<()> {
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ use codex_core::protocol::EventMsg;
|
||||
use codex_core::protocol::InputItem;
|
||||
use codex_core::protocol::Op;
|
||||
use codex_core::protocol::SandboxPolicy;
|
||||
use codex_core::protocol::default_disabled_tools;
|
||||
use codex_protocol::config_types::ReasoningSummary;
|
||||
use core_test_support::responses::ev_assistant_message;
|
||||
use core_test_support::responses::ev_completed;
|
||||
@@ -38,6 +39,7 @@ async fn run_turn(test: &TestCodex, prompt: &str) -> anyhow::Result<()> {
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ use codex_core::protocol::EventMsg;
|
||||
use codex_core::protocol::InputItem;
|
||||
use codex_core::protocol::Op;
|
||||
use codex_core::protocol::SandboxPolicy;
|
||||
use codex_core::protocol::default_disabled_tools;
|
||||
use codex_protocol::config_types::ReasoningSummary;
|
||||
use core_test_support::assert_regex_match;
|
||||
use core_test_support::responses::ev_assistant_message;
|
||||
@@ -48,6 +49,7 @@ async fn submit_turn(
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ use codex_core::protocol::EventMsg;
|
||||
use codex_core::protocol::InputItem;
|
||||
use codex_core::protocol::Op;
|
||||
use codex_core::protocol::SandboxPolicy;
|
||||
use codex_core::protocol::default_disabled_tools;
|
||||
use codex_protocol::config_types::ReasoningSummary;
|
||||
use core_test_support::responses::ev_assistant_message;
|
||||
use core_test_support::responses::ev_completed;
|
||||
@@ -128,6 +129,7 @@ async fn unified_exec_reuses_session_via_stdin() -> Result<()> {
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
@@ -264,6 +266,7 @@ PY
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
@@ -370,6 +373,7 @@ async fn unified_exec_timeout_and_followup_poll() -> Result<()> {
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ use codex_core::protocol::EventMsg;
|
||||
use codex_core::protocol::InputItem;
|
||||
use codex_core::protocol::Op;
|
||||
use codex_core::protocol::SandboxPolicy;
|
||||
use codex_core::protocol::default_disabled_tools;
|
||||
use codex_protocol::config_types::ReasoningSummary;
|
||||
use core_test_support::responses;
|
||||
use core_test_support::responses::ev_assistant_message;
|
||||
@@ -100,6 +101,7 @@ async fn view_image_tool_attaches_local_image() -> anyhow::Result<()> {
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
@@ -199,6 +201,7 @@ async fn view_image_tool_errors_when_path_is_directory() -> anyhow::Result<()> {
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
@@ -264,6 +267,7 @@ async fn view_image_tool_errors_when_file_missing() -> anyhow::Result<()> {
|
||||
model: session_model,
|
||||
effort: None,
|
||||
summary: ReasoningSummary::Auto,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ use codex_core::protocol::InputItem;
|
||||
use codex_core::protocol::Op;
|
||||
use codex_core::protocol::SessionSource;
|
||||
use codex_core::protocol::TaskCompleteEvent;
|
||||
use codex_core::protocol::default_disabled_tools;
|
||||
use codex_ollama::DEFAULT_OSS_MODEL;
|
||||
use codex_protocol::config_types::SandboxMode;
|
||||
use event_processor_with_human_output::EventProcessorWithHumanOutput;
|
||||
@@ -348,6 +349,7 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
|
||||
effort: default_effort,
|
||||
summary: default_summary,
|
||||
final_output_json_schema: output_schema,
|
||||
disabled_tools: default_disabled_tools(),
|
||||
})
|
||||
.await?;
|
||||
info!("Sent prompt with event ID: {initial_prompt_task_id}");
|
||||
|
||||
@@ -37,6 +37,11 @@ pub const ENVIRONMENT_CONTEXT_OPEN_TAG: &str = "<environment_context>";
|
||||
pub const ENVIRONMENT_CONTEXT_CLOSE_TAG: &str = "</environment_context>";
|
||||
pub const USER_MESSAGE_BEGIN: &str = "## My request for Codex:";
|
||||
|
||||
/// Default disabled tools used when clients do not explicitly supply one.
|
||||
pub fn default_disabled_tools() -> Vec<String> {
|
||||
vec!["web_search".to_string()]
|
||||
}
|
||||
|
||||
/// Submission Queue Entry - requests from user
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct Submission {
|
||||
@@ -90,6 +95,9 @@ pub enum Op {
|
||||
summary: ReasoningSummaryConfig,
|
||||
// The JSON schema to use for the final assistant message
|
||||
final_output_json_schema: Option<Value>,
|
||||
// disables tools
|
||||
#[serde(default = "default_disabled_tools")]
|
||||
disabled_tools: Vec<String>,
|
||||
},
|
||||
|
||||
/// Override parts of the persistent turn context for subsequent turns.
|
||||
@@ -125,6 +133,10 @@ pub enum Op {
|
||||
/// Updated reasoning summary preference (honored only for reasoning-capable models).
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
summary: Option<ReasoningSummaryConfig>,
|
||||
|
||||
/// Updated disabled tools.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
disabled_tools: Option<Vec<String>>,
|
||||
},
|
||||
|
||||
/// Approve a command execution
|
||||
|
||||
@@ -1751,6 +1751,7 @@ impl ChatWidget {
|
||||
model: Some(model_for_action.clone()),
|
||||
effort: Some(effort_for_action),
|
||||
summary: None,
|
||||
disabled_tools: None,
|
||||
}));
|
||||
tx.send(AppEvent::UpdateModel(model_for_action.clone()));
|
||||
tx.send(AppEvent::UpdateReasoningEffort(effort_for_action));
|
||||
@@ -1807,6 +1808,7 @@ impl ChatWidget {
|
||||
model: None,
|
||||
effort: None,
|
||||
summary: None,
|
||||
disabled_tools: None,
|
||||
}));
|
||||
tx.send(AppEvent::UpdateAskForApprovalPolicy(approval));
|
||||
tx.send(AppEvent::UpdateSandboxPolicy(sandbox.clone()));
|
||||
|
||||
Reference in New Issue
Block a user