Refactor: move persisting extension to session outside of route (#6685)

This commit is contained in:
Zane
2026-01-29 16:03:03 -08:00
committed by GitHub
parent b0c6373cf8
commit a06436461b
15 changed files with 101 additions and 67 deletions
+1 -1
View File
@@ -1448,7 +1448,7 @@ pub async fn configure_tool_permissions_dialog() -> anyhow::Result<()> {
agent.update_provider(new_provider, &session.id).await?;
if let Some(config) = get_extension_by_name(&selected_extension_name) {
agent
.add_extension(config.clone())
.add_extension(config.clone(), &session.id)
.await
.unwrap_or_else(|_| {
println!(
+1 -1
View File
@@ -186,7 +186,7 @@ async fn create_agent(provider_name: &str, model: &str) -> Result<Agent> {
let enabled_configs = goose::config::get_enabled_extensions();
for config in enabled_configs {
if let Err(e) = agent.add_extension(config.clone()).await {
if let Err(e) = agent.add_extension(config.clone(), &init_session.id).await {
eprintln!("Warning: Failed to load extension {}: {}", config.name(), e);
}
}
+8 -2
View File
@@ -211,7 +211,10 @@ async fn offer_extension_debugging_help(
let extensions = get_all_extensions();
for ext_wrapper in extensions {
if ext_wrapper.enabled && ext_wrapper.config.name() == "developer" {
if let Err(e) = debug_agent.add_extension(ext_wrapper.config).await {
if let Err(e) = debug_agent
.add_extension(ext_wrapper.config, &session.id)
.await
{
// If we can't add developer extension, continue without it
eprintln!(
"Note: Could not load developer extension for debugging: {}",
@@ -258,6 +261,7 @@ async fn load_extensions(
extensions_to_load: Vec<(String, ExtensionConfig)>,
provider_for_debug: Arc<dyn goose::providers::base::Provider>,
interactive: bool,
session_id: &str,
) -> Arc<Agent> {
let mut set = JoinSet::new();
let agent_ptr = Arc::new(agent);
@@ -266,7 +270,8 @@ async fn load_extensions(
for (id, (_label, extension)) in extensions_to_load.iter().enumerate() {
let agent_ptr = agent_ptr.clone();
let cfg = extension.clone();
set.spawn(async move { (id, agent_ptr.add_extension(cfg).await) });
let sid = session_id.to_string();
set.spawn(async move { (id, agent_ptr.add_extension(cfg, &sid).await) });
}
let get_message = |waiting_ids: &BTreeSet<usize>| {
@@ -554,6 +559,7 @@ pub async fn build_session(session_config: SessionBuilderConfig) -> CliSession {
extensions_to_load,
Arc::clone(&provider_for_display),
session_config.interactive,
&session_id,
)
.await;
+1 -6
View File
@@ -336,16 +336,11 @@ impl CliSession {
async fn add_and_persist_extensions(&mut self, configs: Vec<ExtensionConfig>) -> Result<()> {
for config in configs {
self.agent
.add_extension(config)
.add_extension(config, &self.session_id)
.await
.map_err(|e| anyhow::anyhow!("Failed to start extension: {}", e))?;
}
self.agent
.persist_extension_state(&self.session_id)
.await
.map_err(|e| anyhow::anyhow!("Failed to save extension state: {}", e))?;
self.invalidate_completion_cache().await;
Ok(())