Compare commits

...

1 Commits

Author SHA1 Message Date
Anton Panasenko
2478afee90 [codex] tell model that interactive mode is off when approval policy is equal never 2025-10-30 14:56:55 -07:00
2 changed files with 15 additions and 0 deletions

View File

@@ -135,6 +135,7 @@ impl EnvironmentContext {
/// <environment_context>
/// <cwd>...</cwd>
/// <approval_policy>...</approval_policy>
/// <interactive_mode>...</interactive_mode>
/// <sandbox_mode>...</sandbox_mode>
/// <writable_roots>...</writable_roots>
/// <network_access>...</network_access>
@@ -150,6 +151,12 @@ impl EnvironmentContext {
lines.push(format!(
" <approval_policy>{approval_policy}</approval_policy>"
));
match approval_policy {
AskForApproval::Never => {
lines.push(" <interactive_mode>false</interactive_mode>".to_string());
}
_ => lines.push(" <interactive_mode>true</interactive_mode>".to_string()),
};
}
if let Some(sandbox_mode) = self.sandbox_mode {
lines.push(format!(" <sandbox_mode>{sandbox_mode}</sandbox_mode>"));
@@ -220,6 +227,7 @@ mod tests {
let expected = r#"<environment_context>
<cwd>/repo</cwd>
<approval_policy>on-request</approval_policy>
<interactive_mode>true</interactive_mode>
<sandbox_mode>workspace-write</sandbox_mode>
<network_access>restricted</network_access>
<writable_roots>
@@ -242,6 +250,7 @@ mod tests {
let expected = r#"<environment_context>
<approval_policy>never</approval_policy>
<interactive_mode>false</interactive_mode>
<sandbox_mode>read-only</sandbox_mode>
<network_access>restricted</network_access>
</environment_context>"#;
@@ -260,6 +269,7 @@ mod tests {
let expected = r#"<environment_context>
<approval_policy>on-failure</approval_policy>
<interactive_mode>true</interactive_mode>
<sandbox_mode>danger-full-access</sandbox_mode>
<network_access>enabled</network_access>
</environment_context>"#;

View File

@@ -44,6 +44,7 @@ fn default_env_context_str(cwd: &str, shell: &Shell) -> String {
r#"<environment_context>
<cwd>{}</cwd>
<approval_policy>on-request</approval_policy>
<interactive_mode>true</interactive_mode>
<sandbox_mode>read-only</sandbox_mode>
<network_access>restricted</network_access>
{}</environment_context>"#,
@@ -348,6 +349,7 @@ async fn prefixes_context_and_instructions_once_and_consistently_across_requests
r#"<environment_context>
<cwd>{}</cwd>
<approval_policy>on-request</approval_policy>
<interactive_mode>true</interactive_mode>
<sandbox_mode>read-only</sandbox_mode>
<network_access>restricted</network_access>
{}</environment_context>"#,
@@ -503,6 +505,7 @@ async fn overrides_turn_context_but_keeps_cached_prefix_and_key_constant() {
let expected_env_text_2 = format!(
r#"<environment_context>
<approval_policy>never</approval_policy>
<interactive_mode>false</interactive_mode>
<sandbox_mode>workspace-write</sandbox_mode>
<network_access>enabled</network_access>
<writable_roots>
@@ -626,6 +629,7 @@ async fn per_turn_overrides_keep_cached_prefix_and_key_constant() {
r#"<environment_context>
<cwd>{}</cwd>
<approval_policy>never</approval_policy>
<interactive_mode>false</interactive_mode>
<sandbox_mode>workspace-write</sandbox_mode>
<network_access>enabled</network_access>
<writable_roots>
@@ -871,6 +875,7 @@ async fn send_user_turn_with_changes_sends_environment_context() {
let expected_env_msg_2 = text_user_input(
r#"<environment_context>
<approval_policy>never</approval_policy>
<interactive_mode>false</interactive_mode>
<sandbox_mode>danger-full-access</sandbox_mode>
<network_access>enabled</network_access>
</environment_context>"#