Skip to content

feat: Better OS Detection, starting with windows - #6046

Closed
dylan-hurd-oai wants to merge 5 commits into
mainfrom
dh--env-context-windows
Closed

dylan-hurd-oai wants to merge 5 commits into
mainfrom
dh--env-context-windows

Conversation

@dylan-hurd-oai

Copy link
Copy Markdown
Contributor

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

Waxime64 commented Oct 31, 2025 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor 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
Copy Markdown
Contributor

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 ?

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

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor

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
Copy Markdown
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fn new_without_operating_system(
    cwd: Option<PathBuf>,
    approval_policy: Option<AskForApproval>,
    sandbox_policy: Option<SandboxPolicy>,
    shell: Option<Shell>,
) -> Self {
    let mut ec = Self::new(cwd, approval_policy, sandbox_policy, shell);
    ec.operating_system = None;
    ec
}

EnvironmentContext::new_without_operating_system(cwd, approval_policy, sandbox_policy, None)

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
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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?)

@Waxime64

Waxime64 commented Nov 8, 2025

Copy link
Copy Markdown
Contributor

Can be merge ? Or always miss something ?

@Waxime64

Copy link
Copy Markdown
Contributor

Can be merge ? Or always miss something ?

@dylan-hurd-oai ?

Waxime64 added a commit to Waxime64/codex that referenced this pull request Nov 17, 2025
Waxime64 added a commit to Waxime64/codex that referenced this pull request Dec 4, 2025
draft: feat: Better OS Detection, starting with windows openai#6046
@github-actions

github-actions Bot commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 14 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants