-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Bug: Working directory not passed to ExtensionManager when extensions are loaded #6610
Description
Summary
When a user changes the working directory via the folder picker in Goose Desktop, the session's working_dir is updated but extensions are loaded using the goose-server process's current directory instead of the session's working directory. This causes shell commands and other extension operations to run in the wrong directory.
User Report
The user reported that:
- The folder picker in the UI showed
.../ios_development/dialysispal_v02/ - But Goose responded: "I see - it looks like your current working directory shows
dialysispal_v02but we're actually operating in/Users/alex/Downloads"
Diagnostics
From the user's diagnostics export (diagnostics_20260121_4.zip):
- Session
working_dir:/Users/alex/Projects/ios_development/dialysispal_v02 <info-msg>injected into conversation:Working directory: /Users/alex/Downloads
The mismatch confirms the bug.
Root Cause Analysis
The bug is in crates/goose/src/agents/extension_manager.rs:
async fn resolve_working_dir(&self) -> PathBuf {
// Fall back to current_dir - working_dir is passed through the call chain from session
std::env::current_dir().unwrap_or_default()
}The comment says "working_dir is passed through the call chain from session" but it is not actually passed through. The method just returns std::env::current_dir() which is the goose-server process's working directory, not the session's.
Call chain that needs fixing:
load_extensions_from_session(session)
→ agent.add_extension(config) // has access to session.working_dir but doesn't pass it
→ extension_manager.add_extension(config) // needs working_dir parameter
→ resolve_working_dir() // currently returns wrong directory
Impact
- Shell commands run in the wrong directory
- The
<info-msg>shows the wrong working directory to the model - Memory extension looks for
.goose/memoryin the wrong location - Any extension that uses
GOOSE_WORKING_DIRenv var gets the wrong path
Suggested Fix
Either:
- Add
working_dirfield toExtensionManagerand update it when session changes - Pass
working_direxplicitly through the call chain fromload_extensions_from_session→add_extension→extension_manager.add_extension
The key files to modify:
crates/goose/src/agents/extension_manager.rs-add_extension()andresolve_working_dir()crates/goose/src/agents/agent.rs-load_extensions_from_session()andadd_extension()
Environment
- App Version: 1.20.1
- OS: macOS
- Model: GLM-4.7 (via custom provider)