Expose the PowerShell version in environment context (#41232)

## What changed

- Add the under-development `powershell_shell_version` feature flag.
- When enabled for a single local PowerShell environment, query the selected
  shell executable and include its major/minor version in
  `<environment_context>`.
- Cache version lookups, bound command execution and output, and report when a
  previously visible version becomes unavailable.

## Testing

- Cover environment-context diffs when the shell version appears or disappears.
- Verify on Windows that the version is model-visible only when the feature is
  enabled.

GitOrigin-RevId: 3ec8e80425ec3c193134dc1b69f61ef09ede375e
This commit is contained in:
zm-oai authored and copyberry committed 2026-08-28 00:22:05 +00:00
1 parent 91c66024c7
commit dc031d4bc7
6 files changed
+188 -2

No files matched your search

+43
View File
@@ -2212,6 +2212,49 @@ async fn omits_environment_context_when_configured_off() {
);
}
#[cfg(windows)]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn powershell_shell_version_is_model_visible_only_when_enabled() -> anyhow::Result<()> {
core_test_support::skip_if_remote!(Ok(()), "requires local Windows PowerShell execution");
let shell_path = codex_shell_command::powershell::try_find_powershell_executable_blocking()
.ok_or_else(|| anyhow::anyhow!("Windows PowerShell is unavailable"))?
.to_path_buf();
for enabled in [false, true] {
let server = MockServer::start().await;
let response = mount_sse_once(&server, sse(vec![ev_completed("done")])).await;
let user_shell = codex_shell_command::shell_detect::DetectedShell {
shell_type: codex_shell_command::shell_detect::ShellType::PowerShell,
shell_path: shell_path.clone(),
}
.into();
let mut builder = test_codex()
.with_user_shell(user_shell)
.with_config(move |config| {
config
.features
.set_enabled(Feature::PowerShellShellVersion, enabled)
.expect("test config should allow PowerShell version feature updates");
});
let test = builder.build_with_auto_env(&server).await?;
test.submit_turn("report the selected shell").await?;
let request = response.single_request();
assert!(message_input_text_contains(
&request,
"user",
"<shell>powershell</shell>"
));
assert_eq!(
message_input_text_contains(&request, "user", "<shell_version>5.1</shell_version>"),
enabled,
"PowerShell shell version must follow its feature flag"
);
}
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn includes_configured_max_effort_in_request() -> anyhow::Result<()> {
skip_if_no_network!(Ok(()));