From 772e37fb543c781335144802bcc060a551623915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=8C=80=ED=9D=AC?= Date: Wed, 25 Mar 2026 17:55:41 +0900 Subject: [PATCH] feat: feature-gate AWS provider dependencies behind aws-providers (#8080) Signed-off-by: DaeHee Lee Co-authored-by: Claude Opus 4.6 (1M context) --- crates/goose-cli/Cargo.toml | 3 ++- crates/goose-server/Cargo.toml | 3 ++- crates/goose/Cargo.toml | 20 +++++++++++++------- crates/goose/src/providers/formats/mod.rs | 1 + crates/goose/src/providers/init.rs | 8 ++++++-- crates/goose/src/providers/mod.rs | 2 ++ crates/goose/tests/providers.rs | 6 ++++++ 7 files changed, 32 insertions(+), 11 deletions(-) diff --git a/crates/goose-cli/Cargo.toml b/crates/goose-cli/Cargo.toml index b0666212..edad607a 100644 --- a/crates/goose-cli/Cargo.toml +++ b/crates/goose-cli/Cargo.toml @@ -68,9 +68,10 @@ sigstore-verify = { version = "0.6", default-features = false, features = ["rust winapi = { workspace = true } [features] -default = ["code-mode", "local-inference"] +default = ["code-mode", "local-inference", "aws-providers"] code-mode = ["goose/code-mode", "goose-acp/code-mode"] local-inference = ["goose/local-inference"] +aws-providers = ["goose/aws-providers"] cuda = ["goose/cuda", "local-inference"] # disables the update command disable-update = [] diff --git a/crates/goose-server/Cargo.toml b/crates/goose-server/Cargo.toml index 7dddbc93..20bb9b15 100644 --- a/crates/goose-server/Cargo.toml +++ b/crates/goose-server/Cargo.toml @@ -11,9 +11,10 @@ description.workspace = true workspace = true [features] -default = ["code-mode", "local-inference"] +default = ["code-mode", "local-inference", "aws-providers"] code-mode = ["goose/code-mode"] local-inference = ["goose/local-inference"] +aws-providers = ["goose/aws-providers"] cuda = ["goose/cuda", "local-inference"] [dependencies] diff --git a/crates/goose/Cargo.toml b/crates/goose/Cargo.toml index 17115879..225aeb1b 100644 --- a/crates/goose/Cargo.toml +++ b/crates/goose/Cargo.toml @@ -8,7 +8,7 @@ repository.workspace = true description.workspace = true [features] -default = ["code-mode", "local-inference"] +default = ["code-mode", "local-inference", "aws-providers"] code-mode = ["dep:pctx_code_mode"] local-inference = [ "dep:candle-core", @@ -20,6 +20,12 @@ local-inference = [ "dep:rubato", "dep:byteorder", ] +aws-providers = [ + "dep:aws-config", + "dep:aws-smithy-types", + "dep:aws-sdk-bedrockruntime", + "dep:aws-sdk-sagemakerruntime", +] cuda = ["local-inference", "candle-core/cuda", "candle-nn/cuda", "llama-cpp-2/cuda"] [lints] @@ -96,13 +102,13 @@ sqlx = { version = "0.8", default-features = false, features = [ "migrate", ] } -# For Bedrock provider -aws-config = { version = "=1.8.12", features = ["behavior-version-latest"] } -aws-smithy-types = "=1.3.5" -aws-sdk-bedrockruntime = { version = "=1.120.0", default-features = false, features = ["default-https-client", "rt-tokio"] } +# For Bedrock provider (optional, behind "aws-providers" feature) +aws-config = { version = "=1.8.12", features = ["behavior-version-latest"], optional = true } +aws-smithy-types = { version = "=1.3.5", optional = true } +aws-sdk-bedrockruntime = { version = "=1.120.0", default-features = false, features = ["default-https-client", "rt-tokio"], optional = true } -# For SageMaker TGI provider -aws-sdk-sagemakerruntime = { version = "1.62.0", default-features = false, features = ["default-https-client", "rt-tokio"] } +# For SageMaker TGI provider (optional, behind "aws-providers" feature) +aws-sdk-sagemakerruntime = { version = "1.62.0", default-features = false, features = ["default-https-client", "rt-tokio"], optional = true } # For GCP Vertex AI provider auth jsonwebtoken = { version = "10.3.0", features = ["aws_lc_rs"] } diff --git a/crates/goose/src/providers/formats/mod.rs b/crates/goose/src/providers/formats/mod.rs index d7016904..7e7218f4 100644 --- a/crates/goose/src/providers/formats/mod.rs +++ b/crates/goose/src/providers/formats/mod.rs @@ -1,4 +1,5 @@ pub mod anthropic; +#[cfg(feature = "aws-providers")] pub mod bedrock; pub mod databricks; pub mod gcpvertexai; diff --git a/crates/goose/src/providers/init.rs b/crates/goose/src/providers/init.rs index 89081d69..7b03f80a 100644 --- a/crates/goose/src/providers/init.rs +++ b/crates/goose/src/providers/init.rs @@ -1,13 +1,16 @@ use std::sync::{Arc, RwLock}; +#[cfg(feature = "aws-providers")] +use super::bedrock::BedrockProvider; #[cfg(feature = "local-inference")] use super::local_inference::LocalInferenceProvider; +#[cfg(feature = "aws-providers")] +use super::sagemaker_tgi::SageMakerTgiProvider; use super::{ anthropic::AnthropicProvider, avian::AvianProvider, azure::AzureProvider, base::{Provider, ProviderMetadata}, - bedrock::BedrockProvider, chatgpt_codex::ChatGptCodexProvider, claude_acp::ClaudeAcpProvider, claude_code::ClaudeCodeProvider, @@ -26,7 +29,6 @@ use super::{ openai::OpenAiProvider, openrouter::OpenRouterProvider, provider_registry::ProviderRegistry, - sagemaker_tgi::SageMakerTgiProvider, snowflake::SnowflakeProvider, tetrate::TetrateProvider, venice::VeniceProvider, @@ -49,6 +51,7 @@ async fn init_registry() -> RwLock { registry.register::(true); registry.register::(false); registry.register::(false); + #[cfg(feature = "aws-providers")] registry.register::(false); #[cfg(feature = "local-inference")] registry.register::(false); @@ -69,6 +72,7 @@ async fn init_registry() -> RwLock { registry.register::(true); registry.register::(true); registry.register::(true); + #[cfg(feature = "aws-providers")] registry.register::(false); registry.register::(false); registry.register::(true); diff --git a/crates/goose/src/providers/mod.rs b/crates/goose/src/providers/mod.rs index 73944655..3cb824e6 100644 --- a/crates/goose/src/providers/mod.rs +++ b/crates/goose/src/providers/mod.rs @@ -5,6 +5,7 @@ pub mod avian; pub mod azure; pub mod azureauth; pub mod base; +#[cfg(feature = "aws-providers")] pub mod bedrock; pub mod canonical; pub mod catalog; @@ -38,6 +39,7 @@ pub mod openrouter; pub mod provider_registry; pub mod provider_test; mod retry; +#[cfg(feature = "aws-providers")] pub mod sagemaker_tgi; pub mod snowflake; pub mod testprovider; diff --git a/crates/goose/tests/providers.rs b/crates/goose/tests/providers.rs index e9678cba..d483cbdd 100644 --- a/crates/goose/tests/providers.rs +++ b/crates/goose/tests/providers.rs @@ -10,6 +10,7 @@ use goose::permission::{Permission, PermissionConfirmation}; use goose::providers::anthropic::ANTHROPIC_DEFAULT_MODEL; use goose::providers::azure::AZURE_DEFAULT_MODEL; use goose::providers::base::Provider; +#[cfg(feature = "aws-providers")] use goose::providers::bedrock::BEDROCK_DEFAULT_MODEL; use goose::providers::claude_code::CLAUDE_CODE_DEFAULT_MODEL; use goose::providers::codex::CODEX_DEFAULT_MODEL; @@ -19,6 +20,7 @@ use goose::providers::errors::ProviderError; use goose::providers::google::GOOGLE_DEFAULT_MODEL; use goose::providers::litellm::LITELLM_DEFAULT_MODEL; use goose::providers::openai::OPEN_AI_DEFAULT_MODEL; +#[cfg(feature = "aws-providers")] use goose::providers::sagemaker_tgi::SAGEMAKER_TGI_DEFAULT_MODEL; use goose::providers::snowflake::SNOWFLAKE_DEFAULT_MODEL; use goose::providers::xai::XAI_DEFAULT_MODEL; @@ -731,6 +733,7 @@ async fn test_azure_provider() -> Result<()> { .await } +#[cfg(feature = "aws-providers")] #[tokio::test] async fn test_bedrock_provider_long_term_credentials() -> Result<()> { ProviderTestConfig::with_llm_provider( @@ -742,6 +745,7 @@ async fn test_bedrock_provider_long_term_credentials() -> Result<()> { .await } +#[cfg(feature = "aws-providers")] #[tokio::test] async fn test_bedrock_provider_aws_profile_credentials() -> Result<()> { ProviderTestConfig::with_llm_provider("aws_bedrock", BEDROCK_DEFAULT_MODEL, &["AWS_PROFILE"]) @@ -750,6 +754,7 @@ async fn test_bedrock_provider_aws_profile_credentials() -> Result<()> { .await } +#[cfg(feature = "aws-providers")] #[tokio::test] async fn test_bedrock_provider_bearer_token() -> Result<()> { ProviderTestConfig::with_llm_provider( @@ -827,6 +832,7 @@ async fn test_snowflake_provider() -> Result<()> { .await } +#[cfg(feature = "aws-providers")] #[tokio::test] async fn test_sagemaker_tgi_provider() -> Result<()> { ProviderTestConfig::with_llm_provider(