-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Bug: GooseMode changes not applied to existing cached sessions #7603
Description
Summary
When a user changes the Goose mode (auto, approve, smart_approve, chat) via the GUI settings, existing cached agent sessions do not pick up the new mode. This can lead to unexpected behavior and significant cost overruns when users believe they've switched to a more restrictive mode but the session continues operating in the original mode.
Root Cause
The AgentManager caches agents in an LRU cache (up to 100 sessions). When an agent is created, the GooseMode is read once from config and stored in AgentConfig.goose_mode. When the same session is accessed again, the cached agent is returned with its original mode - the config is never re-read.
Relevant code in crates/goose/src/execution/manager.rs:
pub async fn get_or_create_agent(&self, session_id: String) -> Result<Arc<Agent>> {
// Returns cached agent with OLD mode
if let Some(existing) = sessions.get(&session_id) {
return Ok(Arc::clone(existing));
}
// Only reads mode when creating NEW agent
let mode = Config::global().get_goose_mode().unwrap_or(GooseMode::Auto);
let config = AgentConfig::new(..., mode, ...);
// ...
}AgentConfig in crates/goose/src/agents/agent.rs:
pub struct AgentConfig {
pub goose_mode: GooseMode, // Set once at creation, never updated
// ...
}Steps to Reproduce
- Start a new chat session in the GUI
- Note the current mode (e.g.,
auto) - Change the mode to
smart_approveorapprovein settings - Continue using the same chat session
- Observe that tools still execute without approval prompts (original
autobehavior)
Impact
- Cost overruns: Users who switch to restrictive modes expecting approval prompts may leave Goose running, resulting in unexpected API costs
- Security/Safety: Users may believe they have approval controls enabled when they don't
- User trust: Unexpected behavior erodes confidence in the mode system
Real-world impact
A user reported switching to "smart" mode, leaving Goose running, and returning to find their project spend had gone from $4.50 to $70+, then to $184+ after reopening the same chat window (context load-in with the wrong mode).
Suggested Fix
Option A: Re-read goose_mode from config at the start of each reply/request rather than caching it in the agent.
Option B: Invalidate/update cached agents when mode changes in config (would require config change notification mechanism).
Option C: When mode changes in GUI, restart/recreate agents for active sessions.
Environment
- Goose version: v1.26.0+
- Affects: GUI (Desktop app)
- Config location:
~/.config/goose/config.yaml
Workaround
Users should:
- Restart the Goose GUI app after changing mode settings
- Start a new chat session after mode changes (don't continue existing sessions)