Add configurable gating for the sleep tool (#41243)

## What changed

- Add a stable `sleep_tool` feature that can enable or disable registration of the built-in sleep tool independently of the clock tool.
- Support structured `features.sleep_tool` configuration with `model_driven` and `always_on` modes. The default `model_driven` mode preserves the existing model and `current_time_reminder` behavior, while `always_on` registers sleep whenever the feature is enabled.
- Preserve nested sleep-tool configuration across CLI overrides, config merges, and feature toggles, and expose the settings in the generated config schema.

## Testing

- Cover feature-map overrides, both selection modes, legacy clock settings, config merging and editing, and invalid mode rejection.

GitOrigin-RevId: 18eadc582f8a4445958c29d063e5be495276703e
This commit is contained in:
rka-oai authored and copyberry committed 2026-08-28 02:09:07 +00:00
1 parent 41d3dc56a0
commit ec9620c231
12 files changed
+313 -14

No files matched your search

+22 -13
View File
@@ -62,6 +62,7 @@ use crate::tools::router::ToolRouter;
use crate::tools::tool_namespaces_info::collect_tool_namespaces_info;
use codex_extension_api::ExtensionData;
use codex_features::Feature;
use codex_features::SleepToolMode;
use codex_login::AuthManager;
use codex_protocol::DEFAULT_FUNCTION_NAMESPACE;
use codex_protocol::account::PlanType;
@@ -1153,23 +1154,31 @@ fn add_core_utility_tools(context: &CoreToolPlanContext<'_>, registry: &mut Tool
registry.add(GetContextRemainingHandler);
}
if features.enabled(Feature::CurrentTimeReminder) {
registry.add(CurrentTimeHandler);
if turn_context
.config
.current_time_reminder
.as_ref()
.is_some_and(|config| config.sleep_tool)
{
registry.add(SleepHandler);
}
} else if context
let current_time_reminder_enabled = features.enabled(Feature::CurrentTimeReminder);
let model_has_clock = context
.model_info
.experimental_supported_tools
.iter()
.any(|tool| tool == "clock")
{
.any(|tool| tool == "clock");
if current_time_reminder_enabled || model_has_clock {
registry.add(CurrentTimeHandler);
}
if features.enabled(Feature::SleepTool)
&& match turn_context.config.sleep_tool_mode {
SleepToolMode::AlwaysOn => true,
SleepToolMode::ModelDriven => {
if current_time_reminder_enabled {
turn_context
.config
.current_time_reminder
.as_ref()
.is_some_and(|config| config.sleep_tool)
} else {
model_has_clock
}
}
}
{
registry.add(SleepHandler);
}