fix: add OS-aware guidance to execute_bash tool for correct cross-platform commands#3591
Open
fix: add OS-aware guidance to execute_bash tool for correct cross-platform commands#3591
Conversation
…tform commands - Update execute_bash tool description to instruct LLM to check operating_system field before generating commands - Add OS-specific command guidance (PowerShell for Windows, bash for Linux/macOS) - Enhance build_env_state() to provide detailed OS info (version, build, distro) - Add WSL detection to help LLM understand hybrid environments This fixes the issue where the LLM generates Linux commands on Windows instances because it wasn't being instructed to use the OS context when generating commands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes an issue where the LLM generates Linux/bash commands when running on Windows instances. The root cause was that while the OS information was being sent to the LLM, the
execute_bashtool description didn't instruct the LLM to check or use this information.Changes
1. Enhanced
execute_bashTool Description (tool_index.json)operating_systemfield before generating commands/mnt/c/2. Enhanced OS Information in
build_env_state()(message.rs)os_version()function fromsystem_infomodule"windows","linux","macos""Windows 11 (or newer) - build 22631","Linux 5.15.0 - Ubuntu 22.04 LTS","macOS 14.5.0 (23F79)""(WSL - Windows Subsystem for Linux)"suffixTesting
cargo build -p chat_cli- Successcargo test -p chat_cli message- All 7 tests passImpact
The LLM will now: