Standardize shell execution on unified exec (#39757)

## What changed

- Remove the legacy `shell_command` handler and runtime, leaving `exec_command`
  and `write_stdin` as the shell execution tools.
- Treat legacy `shell_command` model metadata as `unified_exec`, and normalize
  legacy user opt-outs so they do not disable command execution. Managed feature
  requirements and `shell_tool` can still disable it.
- Preserve shell approvals, sandboxing, zsh-fork support, and output truncation
  through the unified execution path.

## Testing

- Cover legacy configuration and model-metadata compatibility.
- Exercise unified shell execution, approvals, truncation, and `apply_patch`
  serialization across the app-server and core test suites.

GitOrigin-RevId: 5c2fd6164fc3519cdae4944cb9db276b8467311c
This commit is contained in:
jif authored and copyberry committed 2026-08-20 17:46:05 +00:00
1 parent d0cc662b8c
commit 8a40095ea3
116 files changed
+1338 -4711

No files matched your search

+46
View File
@@ -467,6 +467,52 @@ fn exec_command_tool_output_formats_truncated_response() {
}
}
#[test]
fn exec_command_tool_output_reserves_metadata_budget_and_preserves_policy_units() {
let payload = ToolPayload::Function {
arguments: "{}".to_string(),
};
let raw_output = (1..=150)
.map(|line| format!("{line}\n"))
.collect::<String>()
.into_bytes();
for (policy, marker) in [
(TruncationPolicy::Bytes(200), "chars truncated"),
(TruncationPolicy::Tokens(50), "tokens truncated"),
] {
let response = ExecCommandToolOutput {
event_call_id: "call-42".to_string(),
chunk_id: "abc123".to_string(),
wall_time: std::time::Duration::from_millis(/*millis*/ 1250),
raw_output: raw_output.clone(),
truncation_policy: policy,
max_output_tokens: None,
process_id: None,
exit_code: Some(0),
original_token_count: Some(123),
output_omitted_bytes: None,
hook_command: None,
}
.to_response_item("call-42", &payload);
let ResponseInputItem::FunctionCallOutput { output, .. } = response else {
panic!("expected FunctionCallOutput");
};
let text = output
.body
.to_text()
.expect("exec output should serialize as text");
assert!(text.len() <= (policy * 1.2).byte_budget());
assert_eq!(text.matches(marker).count(), 1);
assert!(text.contains("Original token count: 123"));
assert!(text.contains("Total output lines: 150"));
assert!(text.contains("\n1\n2\n3\n"));
assert!(text.ends_with("149\n150\n"));
}
}
#[test]
fn exec_command_tool_output_preserves_omission_metadata_when_truncated() {
let payload = ToolPayload::Function {