Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions codex-rs/core/src/tools/handlers/sleep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use codex_tools::JsonSchema;
use codex_tools::ResponsesApiNamespace;
use codex_tools::ResponsesApiNamespaceTool;
use codex_tools::ResponsesApiTool;
use codex_tools::ToolExposure;
use codex_tools::ToolName;
use codex_tools::ToolSpec;
use serde::Deserialize;
Expand Down Expand Up @@ -68,6 +69,10 @@ impl ToolExecutor<ToolInvocation> for SleepHandler {
create_sleep_tool()
}

fn exposure(&self) -> ToolExposure {
ToolExposure::DirectModelOnly
}

fn handle(&self, invocation: ToolInvocation) -> codex_tools::ToolExecutorFuture<'_> {
Box::pin(async move {
let ToolInvocation {
Expand Down
49 changes: 49 additions & 0 deletions codex-rs/core/src/tools/spec_plan_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,55 @@ async fn sleep_tool_follows_current_time_config() {
);
}

#[tokio::test]
async fn sleep_tool_stays_direct_and_outside_code_mode() {
for code_mode_only in [false, true] {
let plan = probe(|turn| {
set_features(
turn,
&[
Feature::CodeMode,
Feature::CurrentTimeReminder,
Feature::MultiAgentV2,
],
);
if code_mode_only {
set_feature(turn, Feature::CodeModeOnly, /*enabled*/ true);
}
update_config(turn, |config| {
config.current_time_reminder = Some(CurrentTimeReminderConfig {
sleep_tool: true,
..CurrentTimeReminderConfig::default()
});
config.multi_agent_v2.wait_agent_enabled = false;
});
})
.await;

assert!(
plan.namespace_function_names("clock")
.iter()
.any(|name| name == "sleep")
);
let sleep_tool_name = ToolName::namespaced("clock", "sleep").to_string();
let wait_agent_tool_name =
ToolName::namespaced(MULTI_AGENT_V2_NAMESPACE, "wait_agent").to_string();
assert_eq!(
plan.exposure(&sleep_tool_name),
ToolExposure::DirectModelOnly
);
plan.assert_registered_lacks(&[wait_agent_tool_name.as_str()]);

let ToolSpec::Freeform(exec) = plan.visible_spec(codex_code_mode::PUBLIC_TOOL_NAME) else {
panic!("expected code mode exec tool");
};
if code_mode_only {
assert!(exec.description.contains("clock__curr_time"));
}
assert!(!exec.description.contains("clock__sleep"));
}
}

#[tokio::test]
async fn mcp_and_tool_search_follow_direct_and_deferred_tool_exposure() {
let direct_mcp = probe_with(
Expand Down
Loading