Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion crates/goose-server/src/routes/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,16 @@ async fn start_agent(
})?;

// Initialize session with extensions (either overrides from hub or global defaults)
let extensions_to_use =
let mut extensions_to_use =
extension_overrides.unwrap_or_else(goose::config::get_enabled_extensions);

// If recipe has extensions, merge them with the global/override extensions
if let Some(ref recipe) = original_recipe {
if let Some(ref recipe_extensions) = recipe.extensions {
extensions_to_use.extend(recipe_extensions.clone());
}
}

let mut extension_data = session.extension_data.clone();
let extensions_state = EnabledExtensionsState::new(extensions_to_use);
if let Err(e) = extensions_state.to_extension_data(&mut extension_data) {
Expand Down
24 changes: 23 additions & 1 deletion crates/goose/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::posthog;
use crate::providers::create;
use crate::recipe::Recipe;
use crate::scheduler_trait::SchedulerTrait;
use crate::session::extension_data::{EnabledExtensionsState, ExtensionState};
use crate::session::session_manager::SessionType;
use crate::session::{Session, SessionManager};

Expand Down Expand Up @@ -740,13 +741,34 @@ async fn execute_job(
}
}

let session = SessionManager::create_session(
let mut session = SessionManager::create_session(
std::env::current_dir()?,
format!("Scheduled job: {}", job.id),
SessionType::Scheduled,
)
.await?;

// Save recipe extensions to session extension_data so they're properly loaded
if let Some(ref extensions) = recipe.extensions {
let mut extension_data = session.extension_data.clone();
let extensions_state = EnabledExtensionsState::new(extensions.clone());
if let Err(e) = extensions_state.to_extension_data(&mut extension_data) {
tracing::warn!("Failed to save recipe extensions to session: {}", e);
} else {
SessionManager::update_session(&session.id)
.extension_data(extension_data.clone())
.apply()
.await?;
session.extension_data = extension_data;
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After updating extension_data in the database, you're also updating the local session object with the same data. However, this local mutation doesn't persist since the session object isn't used further in this function - it's only referenced once more to get the id on line 772. Consider removing this line as it serves no purpose.

Suggested change
session.extension_data = extension_data;

Copilot uses AI. Check for mistakes.
}
}

// Save recipe to session
SessionManager::update_session(&session.id)
.recipe(Some(recipe.clone()))
.apply()
.await?;

Comment on lines +766 to +771
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The recipe is being saved to the session twice - once here and again at lines 837-841. Remove this duplicate update since line 839 already saves the recipe to the session.

Suggested change
// Save recipe to session
SessionManager::update_session(&session.id)
.recipe(Some(recipe.clone()))
.apply()
.await?;

Copilot uses AI. Check for mistakes.
agent.update_provider(agent_provider, &session.id).await?;

let mut jobs_guard = jobs.lock().await;
Expand Down