diff --git a/crates/chat-cli/src/cli/chat/message.rs b/crates/chat-cli/src/cli/chat/message.rs index 569846c1c2..f2c4ec7705 100644 --- a/crates/chat-cli/src/cli/chat/message.rs +++ b/crates/chat-cli/src/cli/chat/message.rs @@ -15,6 +15,11 @@ use tracing::{ warn, }; +use crate::util::system_info::{ + in_wsl, + os_version, +}; + use super::consts::{ MAX_CURRENT_WORKING_DIRECTORY_LEN, MAX_USER_MESSAGE_SIZE, @@ -540,8 +545,21 @@ impl From for AssistantToolUse { } pub fn build_env_state() -> EnvState { + // Build a detailed OS description using system_info + let os_description = match os_version() { + Some(version) => { + let base = version.to_string(); + if in_wsl() { + format!("{} (WSL - Windows Subsystem for Linux)", base) + } else { + base + } + }, + None => env::consts::OS.into(), + }; + let mut env_state = EnvState { - operating_system: Some(env::consts::OS.into()), + operating_system: Some(os_description), ..Default::default() }; diff --git a/crates/chat-cli/src/cli/chat/tools/tool_index.json b/crates/chat-cli/src/cli/chat/tools/tool_index.json index 6ebeb50334..4d3a72c319 100644 --- a/crates/chat-cli/src/cli/chat/tools/tool_index.json +++ b/crates/chat-cli/src/cli/chat/tools/tool_index.json @@ -24,13 +24,13 @@ }, "execute_bash": { "name": "execute_bash", - "description": "Execute the specified bash command.", + "description": "Execute the specified shell command.\n\nIMPORTANT: Always check the 'operating_system' field in the user's environment context before generating commands.\n\nOS-specific guidance:\n- Windows: Use PowerShell syntax (Get-ChildItem instead of ls, Get-Content instead of cat, New-Item instead of touch, Remove-Item instead of rm, Copy-Item instead of cp, Move-Item instead of mv). Use backslashes for paths or forward slashes. Use $env:VAR for environment variables.\n- Linux/macOS: Use bash/POSIX syntax (ls, cat, touch, rm, cp, mv). Use forward slashes for paths. Use $VAR for environment variables.\n- WSL: The environment is Linux but may interact with Windows paths via /mnt/c/.\n\nNever assume Linux commands will work on Windows or vice versa. When the OS is unclear, ask the user to confirm.", "input_schema": { "type": "object", "properties": { "command": { "type": "string", - "description": "Bash command to execute" + "description": "Shell command to execute. Must use syntax appropriate for the user's operating system." }, "summary": { "type": "string",