Repository: block/goose
File: crates/goose-cli/src/session/builder.rs (Rust)

Code before:
    agent: Agent,
    session_config: &SessionBuilderConfig,
    recipe: Option<&Recipe>,
    session_id: &str,
    provider_for_debug: Arc<dyn goose::providers::base::Provider>,
) -> Arc<Agent> {
    for warning in goose::config::get_warnings() {
        eprintln!("{}", style(format!("Warning: {}", warning)).yellow());
    }

    let mut configured_extensions: Vec<ExtensionConfig> = if session_config.resume {
        agent
            .config
            .session_manager
            .get_session(session_id, false)
            .await
            .ok()
            .and_then(|s| EnabledExtensionsState::from_extension_data(&s.extension_data))
            .map(|state| state.extensions)
            .unwrap_or_else(get_enabled_extensions)
    } else if session_config.no_profile {
        Vec::new()
    } else {
        resolve_extensions_for_new_session(recipe.and_then(|r| r.extensions.as_deref()), None)
    };
    configured_extensions.retain(|config| !is_deprecated_platform_extension(config));

    let cli_flag_extensions = parse_cli_flag_extensions(
        &session_config.extensions,
        &session_config.streamable_http_extensions,
        &session_config.builtins,
    );

    let mut extensions_to_load: Vec<(String, ExtensionConfig)> = configured_extensions
        .iter()
        .map(|cfg| (cfg.name(), cfg.clone()))
        .collect();
    extensions_to_load.extend(cli_flag_extensions);

    load_extensions(
        agent,
        extensions_to_load,
        provider_for_debug,
        session_config.interactive,
        session_id,
    )
    .await
}

async fn configure_session_prompts(
    session: &CliSession,

Review comment (suggestion):
shouldn't we be doing this at a higher level? this fixes it for the cli, but how does this work for the desktop? 

I think in general we should just ignore trying to load platform extensions that don't exist. we offer a let goose help you fix this for you, but for platform extensions and built-in extensions there is just nothing you can do

Code after:
            session_id,
            Config::global(),
        )
        .await
    } else if session_config.no_profile {
        Vec::new()
    } else {
        resolve_extensions_for_new_session(recipe.and_then(|r| r.extensions.as_deref()), None)
    };

    let cli_flag_extensions = parse_cli_flag_extensions(
        &session_config.extensions,
        &session_config.streamable_http_extensions,
        &session_config.builtins,
    );

    let mut all: Vec<ExtensionConfig> = configured_extensions;
    all.extend(cli_flag_extensions.into_iter().map(|(_, cfg)| cfg));

    Ok(all)
}

async fn resolve_and_load_extensions(
    agent: Agent,
    extensions: Vec<ExtensionConfig>,
    provider_for_debug: Arc<dyn goose::providers::base::Provider>,
    interactive: bool,
    session_id: &str,
) -> Arc<Agent> {
    for warning in goose::config::get_warnings() {
        eprintln!("{}", style(format!("Warning: {}", warning)).yellow());
    }

    let extensions_to_load: Vec<(String, ExtensionConfig)> = extensions
        .into_iter()
        .map(|cfg| (cfg.name(), cfg))
        .collect();

    load_extensions(
        agent,
        extensions_to_load,
        provider_for_debug,
        interactive,
        session_id,
    )
    .await
}

async fn configure_session_prompts(
    session: &CliSession,
    config: &Config,