BoundaryML/baml · error

Strategy client providers are not supported yet in…

Error message

Strategy client providers are not supported yet in LLMPrimitiveProvider

What it means

LLMPrimitiveProvider::try_from for dynamic client construction does not support Strategy (fallback/shuffle etc.) client providers. Matching a ClientProvider::Strategy hits an unimplemented!() which panics rather than returning a graceful error. Strategy providers must be handled at a higher level (LLMRendererProvider / runtime client layer), not as a primitive client.

Solutions

  1. Use the strategy client through the runtime's higher-level client API (e.g. via baml function invocation with ClientRegistry) instead of constructing an LLMPrimitiveProvider from it
  2. Resolve the strategy to one of its concrete underlying providers and construct that primitive provider directly
  3. Wait for/upgrade to a BAML version that implements Strategy support in LLMPrimitiveProvider
  4. Avoid referencing strategy clients in dynamic/primitive contexts; declare a concrete provider in the client registry

Example fix

// before
let provider = LLMPrimitiveProvider::try_from(("MyFallbackStrategy".to_string(), &ctx)?)?;
// after
let provider = LLMPrimitiveProvider::try_from(("MyOpenAiClient".to_string(), &ctx)?)?;
Defensive patterns

Strategy: validation

Validate before calling

// Rust: check provider kind before constructing a primitive client
if let ClientProvider::Strategy(_) = resolved.provider() {
    return Err(anyhow::anyhow!("strategy clients are not supported in primitive provider; use a concrete client"));
}

Type guard

fn is_primitive(p: &ClientProvider) -> bool {
    !matches!(p, ClientProvider::Strategy(_))
}

Try / catch

// unimplemented!() panics, so guard before construction; if unavoidable, catch_upstream at the boundary
let result = std::panic::catch_unwind(|| LLMPrimitiveProvider::try_from(value));

Prevention

When it happens

Trigger: Building a dynamic LLM client (e.g. via ctx.llm.stream/ClientRegistry in a BAML function or baml.ClientRegistry in code) where the configured client name resolves to a strategy provider instead of a concrete provider (openai, anthropic, google-ai, vertex).

Common situations: Users define a `strategy` client (e.g. fallback across OpenAI and Anthropic) in clients.baml and reference it programmatically through the dynamic API, which only supports primitive providers.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/2e00d8948068238f. Report an issue: GitHub.

Appendix: source

Thrown at engine/baml-runtime/src/internal/llm_client/primitive/mod.rs:156

                    OpenAIClientProviderVariant::Transcriptions => {
                        OpenAIClient::dynamic_new_transcriptions(value, ctx).map(Into::into)
                    }
                    OpenAIClientProviderVariant::OpenRouter => {
                        OpenAIClient::dynamic_new_openrouter(value, ctx).map(Into::into)
                    }
                }
            }
            ClientProvider::Anthropic => AnthropicClient::dynamic_new(value, ctx).map(Into::into),
            #[cfg(feature = "bedrock")]
            ClientProvider::AwsBedrock => AwsClient::dynamic_new(value, ctx).map(Into::into),
            #[cfg(not(feature = "bedrock"))]
            ClientProvider::AwsBedrock => anyhow::bail!(
                "AWS Bedrock support was not compiled into this build (enable the `bedrock` feature)"
            ),
            ClientProvider::GoogleAi => GoogleAIClient::dynamic_new(value, ctx).map(Into::into),
            ClientProvider::Vertex => VertexClient::dynamic_new(value, ctx).map(Into::into),
            ClientProvider::Strategy(strategy_client_provider) => {
                unimplemented!(
                    "Strategy client providers are not supported yet in LLMPrimitiveProvider"
                )
            } // "openai" => OpenAIClient::dynamic_new(value, ctx).map(Into::into),
              // "openai-generic" => OpenAIClient::dynamic_new_generic(value, ctx).map(Into::into),
              // "azure-openai" => OpenAIClient::dynamic_new_azure(value, ctx).map(Into::into),
              // "ollama" => OpenAIClient::dynamic_new_ollama(value, ctx).map(Into::into),
              // "anthropic" => AnthropicClient::dynamic_new(value, ctx).map(Into::into),
              // "google-ai" => GoogleAIClient::dynamic_new(value, ctx).map(Into::into),
              // "vertex-ai" => VertexClient::dynamic_new(value, ctx).map(Into::into),
              // // dynamic_new is not implemented for aws::AwsClient
              // other => {
              //     let options = [
              //         "anthropic",
              //         "azure-openai",
              //         "google-ai",
              //         "openai",
              //         "openai-generic",
              //         "vertex-ai",

View on GitHub (pinned to bd85ce9dee)