fix: Error when calling Goose CLI with session resume from Python subprocess #6238
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.
Closes #6236
Summary
Issue #6236 Fix Summary
Problem
When calling Goose CLI with session resume (
-rflag) from a Python subprocess (non-interactive mode), the CLI panicked with:This occurred because
cliclack::confirm().interact()tries to read from stdin, which is not connected when running in a subprocess.Root Cause
The
build_session()function inbuilder.rshad two locations that usedcliclack::confirm()without checking if the session is interactive:check_missing_extensions_or_exit()asking about missing extensionsSolution
Modified
crates/goose-cli/src/session/builder.rsto skip interactive prompts whensession_config.interactiveisfalse:Change 1: Working directory prompt (line ~405)
Added
&& session_config.interactiveto the condition so the prompt is only shown when running interactively. When non-interactive, the CLI stays in the current working directory.Change 2: Missing extensions prompt (function
check_missing_extensions_or_exit)Added an
interactive: boolparameter to the function. When non-interactive, the prompt is skipped and the session continues with whatever extensions are available.Change 3: Updated call site
Updated the call to
check_missing_extensions_or_exit()to passsession_config.interactive.Behavior After Fix
Files Changed
crates/goose-cli/src/session/builder.rsVerification
cargo check- PASSEDcargo fmt- PASSED./scripts/clippy-lint.sh- PASSEDGenerated by goose Issue Solver