mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
Gate unified exec TTY support behind a feature flag (#42718)
## What changed - Add the stable, default-on `unified_exec_tty` feature. - When disabled, omit `tty` from the `exec_command` tool schema and reject calls that explicitly request a TTY. - Continue to support commands that omit `tty` or set it to `false`. ## Testing - Add unified exec coverage for the disabled tool schema, explicit TTY rejection, and non-TTY command execution. GitOrigin-RevId: c5934fe9db1423170b891c7ecd0188792cd03f42
This commit is contained in:
@@ -59,6 +59,7 @@ const EXEC_COMMAND_REJECTION_MAX_BYTES: usize = 900;
|
||||
#[derive(Clone, Copy)]
|
||||
pub(crate) struct ExecCommandHandlerOptions {
|
||||
pub(crate) allow_login_shell: bool,
|
||||
pub(crate) allow_tty: bool,
|
||||
pub(crate) exec_permission_approvals_enabled: bool,
|
||||
pub(crate) include_environment_id: bool,
|
||||
pub(crate) include_shell_parameter: bool,
|
||||
@@ -82,6 +83,7 @@ impl Default for ExecCommandHandler {
|
||||
lifetime: ExecCommandLifetime::Interactive,
|
||||
options: ExecCommandHandlerOptions {
|
||||
allow_login_shell: false,
|
||||
allow_tty: true,
|
||||
exec_permission_approvals_enabled: false,
|
||||
include_environment_id: false,
|
||||
include_shell_parameter: true,
|
||||
@@ -122,10 +124,19 @@ impl ToolExecutor<ToolInvocation> for ExecCommandHandler {
|
||||
self.options.include_shell_parameter,
|
||||
self.options.include_windows_shell_guidance,
|
||||
);
|
||||
match self.lifetime {
|
||||
let mut spec = match self.lifetime {
|
||||
ExecCommandLifetime::Interactive => spec,
|
||||
ExecCommandLifetime::OneShot => one_shot_exec_command_spec(spec),
|
||||
};
|
||||
if !self.options.allow_tty
|
||||
&& let ToolSpec::Function(spec) = &mut spec
|
||||
{
|
||||
spec.parameters
|
||||
.properties
|
||||
.get_or_insert_default()
|
||||
.remove("tty");
|
||||
}
|
||||
spec
|
||||
}
|
||||
|
||||
fn supports_parallel_tool_calls(&self) -> bool {
|
||||
@@ -230,6 +241,11 @@ impl ExecCommandHandler {
|
||||
parse_arguments(&arguments)?
|
||||
}
|
||||
};
|
||||
if args.tty && !session.features().enabled(Feature::UnifiedExecTty) {
|
||||
return Err(FunctionCallError::RespondToModel(
|
||||
"TTY execution is disabled by config; omit `tty` or set it to false.".to_string(),
|
||||
));
|
||||
}
|
||||
let sandbox_permissions =
|
||||
resolve_sandbox_permissions(args.sandbox_permissions, args.justification.as_deref())?;
|
||||
let hook_command = args.cmd.clone();
|
||||
|
||||
@@ -997,6 +997,10 @@ fn add_core_tool_sources(context: &CoreToolPlanContext<'_>, registry: &mut ToolR
|
||||
{
|
||||
registry.add(ExecCommandHandler::new(ExecCommandHandlerOptions {
|
||||
allow_login_shell: any_environment_allows_login_shell(context.environments),
|
||||
allow_tty: turn_context
|
||||
.config
|
||||
.features
|
||||
.enabled(Feature::UnifiedExecTty),
|
||||
exec_permission_approvals_enabled: false,
|
||||
include_environment_id,
|
||||
include_shell_parameter: unified_exec_should_include_shell_parameter(
|
||||
@@ -1088,6 +1092,7 @@ fn add_shell_tools(context: &CoreToolPlanContext<'_>, registry: &mut ToolRegistr
|
||||
let include_environment_id = matches!(environment_mode, ToolEnvironmentMode::Multiple);
|
||||
let options = ExecCommandHandlerOptions {
|
||||
allow_login_shell,
|
||||
allow_tty: features.enabled(Feature::UnifiedExecTty),
|
||||
exec_permission_approvals_enabled,
|
||||
include_environment_id,
|
||||
include_shell_parameter: unified_exec_should_include_shell_parameter(
|
||||
|
||||
Reference in New Issue
Block a user