Home / Function/ _supports_provider_strategy() — langchain Function Reference

_supports_provider_strategy() — langchain Function Reference

Architecture documentation for the _supports_provider_strategy() function in factory.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  415a1029_3a76_d9b4_4470_cf97d4851d11["_supports_provider_strategy()"]
  fd7a28b1_3772_169b_6524_1342f35143b1["factory.py"]
  415a1029_3a76_d9b4_4470_cf97d4851d11 -->|defined in| fd7a28b1_3772_169b_6524_1342f35143b1
  f4b66c38_651c_807a_caca_41f73fbbe516["create_agent()"]
  f4b66c38_651c_807a_caca_41f73fbbe516 -->|calls| 415a1029_3a76_d9b4_4470_cf97d4851d11
  style 415a1029_3a76_d9b4_4470_cf97d4851d11 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/factory.py lines 471–508

def _supports_provider_strategy(
    model: str | BaseChatModel, tools: list[BaseTool | dict[str, Any]] | None = None
) -> bool:
    """Check if a model supports provider-specific structured output.

    Args:
        model: Model name string or `BaseChatModel` instance.
        tools: Optional list of tools provided to the agent.

            Needed because some models don't support structured output together with tool calling.

    Returns:
        `True` if the model supports provider-specific structured output, `False` otherwise.
    """
    model_name: str | None = None
    if isinstance(model, str):
        model_name = model
    elif isinstance(model, BaseChatModel):
        model_name = (
            getattr(model, "model_name", None)
            or getattr(model, "model", None)
            or getattr(model, "model_id", "")
        )
        model_profile = model.profile
        if (
            model_profile is not None
            and model_profile.get("structured_output")
            # We make an exception for Gemini models, which currently do not support
            # simultaneous tool use with structured output
            and not (tools and isinstance(model_name, str) and "gemini" in model_name.lower())
        ):
            return True

    return (
        any(part in model_name.lower() for part in FALLBACK_MODELS_WITH_STRUCTURED_OUTPUT)
        if model_name
        else False
    )

Domain

Subdomains

Called By

Frequently Asked Questions

What does _supports_provider_strategy() do?
_supports_provider_strategy() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/factory.py.
Where is _supports_provider_strategy() defined?
_supports_provider_strategy() is defined in libs/langchain_v1/langchain/agents/factory.py at line 471.
What calls _supports_provider_strategy()?
_supports_provider_strategy() is called by 1 function(s): create_agent.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free