fix(unified_exec): use platform default shell when unified_exec shell… #7486
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.
Unified Exec Shell Selection on Windows
Problem
reference issue #7466
The
unified_exechandler currently deserializes model-provided tool calls into theExecCommandArgsstruct:The
shellfield uses a hard-coded default:When the model returns a tool call JSON that only contains
cmd(which is the common case), Serde fills inshellwith this default value. Later,get_commanduses that value as if it were a model-provided shell path:On Unix, this usually resolves to
/bin/bashand works as expected. However, on Windows this behavior is problematic:"/bin/bash"is not a valid Windows path.get_shell_by_model_provided_pathtreats this as a model-specified shell, and tries to resolve it (e.g. viawhich::which("bash")), which may or may not exist and may not behave as intended.cmd.exe.The core of the issue is that "model did not specify
shell" is currently interpreted as "the model explicitly requested/bin/bash", which is both Unix-specific and wrong on Windows.Proposed Solution
Instead of hard-coding
"/bin/bash"intoExecCommandArgs, we should distinguish between:The model explicitly specifying a shell, e.g.:
{ "cmd": "echo hello", "shell": "pwsh" }In this case, we do want to respect the model’s choice and use
get_shell_by_model_provided_path.The model omitting the
shellfield entirely, e.g.:{ "cmd": "echo hello" }In this case, we should not assume
/bin/bash. Instead, we should usedefault_user_shell()and let the platform decide.To express this distinction, we can:
Change
shellto be optional inExecCommandArgs:Here, the absence of
shellin the JSON is represented asshell: None, rather than a hard-coded string value.