-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Bug: Working directory shared across sessions via process-wide env var #6909
Description
Description
When multiple chat sessions are active, changing the working directory in one session (or the Home screen) affects all other sessions. This is because the developer extension reads its working directory from a process-wide environment variable (GOOSE_WORKING_DIR), creating two sources of truth.
Steps to Reproduce
- Open Goose Desktop and start a chat session in
/project-a - Navigate to the Home screen
- Change the directory to
/project-b(or start a new session there) - Return to the original chat session in
/project-a - Run a shell command - it will execute in
/project-binstead of/project-a
Expected Behavior
Each chat session should maintain its own working directory, independent of other sessions.
Actual Behavior
Changing the working directory anywhere (Home screen or another session) overwrites the GOOSE_WORKING_DIR environment variable for the entire goosed process, affecting all active sessions.
Root Cause
The developer extension reads its working directory from a global env var:
// In crates/goose-mcp/src/developer/rmcp_developer.rs
let working_dir = std::env::var("GOOSE_WORKING_DIR")
.ok()
.map(std::path::PathBuf::from);And when sessions start, they set this process-wide:
// In crates/goose/src/agents/extension_manager.rs
std::env::set_var("GOOSE_WORKING_DIR", &effective_working_dir);Since std::env::set_var affects the entire process, all sessions end up sharing the same working directory.
Suggested Fix
The developer extension should receive its working directory through its initialization context or store it per-instance, rather than reading from a global environment variable.
Environment
- Version: v1.22.2
- OS: Ubuntu (reported), likely affects all platforms
Related
- This is different from fix: actually set the working dir for extensions from session #6612, which fixed extensions not receiving the session's working directory at initialization
- fix(ui): preserve working directory when creating new chat #6789 fixed preserving working directory when creating new chats, but doesn't address the shared state issue
Reporter
Originally reported by a community member on the forum.