Skip to content

Conversation

@AWSNygma
Copy link

@AWSNygma AWSNygma commented Jan 7, 2026

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_bash tool description didn't instruct the LLM to check or use this information.

Changes

1. Enhanced execute_bash Tool Description (tool_index.json)

  • Added explicit instruction to check the operating_system field before generating commands
  • Added OS-specific command guidance:
    • Windows: Use PowerShell syntax (Get-ChildItem, Get-Content, New-Item, etc.)
    • Linux/macOS: Use bash/POSIX syntax (ls, cat, touch, etc.)
    • WSL: Linux environment with Windows path access via /mnt/c/
  • Updated command parameter description to emphasize OS-appropriate syntax

2. Enhanced OS Information in build_env_state() (message.rs)

  • Now uses the existing os_version() function from system_info module
  • Provides detailed OS descriptions instead of simple strings:
    • Before: "windows", "linux", "macos"
    • After: "Windows 11 (or newer) - build 22631", "Linux 5.15.0 - Ubuntu 22.04 LTS", "macOS 14.5.0 (23F79)"
  • Added WSL detection to append "(WSL - Windows Subsystem for Linux)" suffix

Testing

  • cargo build -p chat_cli - Success
  • cargo test -p chat_cli message - All 7 tests pass
  • JSON validation - Valid

Impact

The LLM will now:

  1. Be explicitly instructed to check the OS before generating shell commands
  2. Receive more detailed OS information to make better decisions
  3. Generate PowerShell commands for Windows and bash commands for Linux/macOS

…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.
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.

1 participant