Skip to content

Bug: Working directory not passed to ExtensionManager when extensions are loaded #6610

@blackgirlbytes

Description

@blackgirlbytes

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.

Image Image

User Report

Discord thread: https://discord.com/channels/1287729918100246654/1287729920319033345/1463483040511557795

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_v02 but 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

diagnostics_20260121_4.zip

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/memory in the wrong location
  • Any extension that uses GOOSE_WORKING_DIR env var gets the wrong path

Suggested Fix

Either:

  1. Add working_dir field to ExtensionManager and update it when session changes
  2. Pass working_dir explicitly through the call chain from load_extensions_from_sessionadd_extensionextension_manager.add_extension

The key files to modify:

  • crates/goose/src/agents/extension_manager.rs - add_extension() and resolve_working_dir()
  • crates/goose/src/agents/agent.rs - load_extensions_from_session() and add_extension()

Environment

  • App Version: 1.20.1
  • OS: macOS
  • Model: GLM-4.7 (via custom provider)

Metadata

Metadata

Assignees

Labels

corePertains to core goose functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions