Skip to content

Conversation

@dylan-hurd-oai
Copy link
Collaborator

Summary

Adds more information to <environment_context> on Windows platforms and when WSL env vars are set. I think we're almost certainly add this to env context for all sessions, but want to test those cases further.

Testing

  • Added unit tests

@Waxime64
Copy link

Waxime64 commented Oct 31, 2025

It's possible to add WSL detection ? I make my code in plaform.rs, but it's better to centralize in your
#5644

@dylan-hurd-oai
Copy link
Collaborator Author

@Waxime64 sure, and the OnceLock is a good call as well

let info = info.expect("expected WSL operating system info");
assert_eq!(info.name, "Windows Subsystem for Linux");
assert_eq!(info.version, "");
assert_eq!(info.is_likely_windows_subsystem_for_linux, Some(true));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need both name and is_likely_windows_subsystem_for_linux ?

Copy link
Collaborator Author

@dylan-hurd-oai dylan-hurd-oai Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this - should be os_info.name, not "Windows Subsystem for Linux" 🤦

When running inside WSL, the os_info will return a linux distribution, e.g. Ubuntu. But it's still helpful to know that this is running inside WSL and the actual machine you're on is a Windows machine.

if has_wsl_env_markers() {
let info = info.expect("expected WSL operating system info");
assert_eq!(info.name, "Windows Subsystem for Linux");
assert_eq!(info.version, "");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what decisions to do we expect model to make better when knowing the version?

@dylan-hurd-oai dylan-hurd-oai force-pushed the dh--env-context-windows branch from 704a9a6 to 66858e4 Compare November 5, 2025 00:42
// Diff messages should only include fields that changed between turns.
// Operating system is a static property of the host and should not be
// emitted as part of a per-turn diff.
let mut ec = EnvironmentContext::new(cwd, approval_policy, sandbox_policy, None);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this feels a bit awkward. Something like EnvironmentContext::init_without_os(...) would be nice

Some(OperatingSystemInfo {
name: info.os_type().to_string(),
version: info.version().to_string(),
is_likely_windows_subsystem_for_linux: Some(has_wsl_env_markers()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this right? If they are running WSL, wouldn't target_os not be windows?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can technically execute codex.exe from within WSL, since WSL supports interop for executables. I think we should generally discourage this, since many things won't work, but it is possible.

}

#[allow(dead_code)]
fn has_wsl_env_markers() -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to have one version of this (also this one doesn't cache the output?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oai-pr PRs posted by Codex team members

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants