Skip to content

[langchain]: Docs contradict on whether schema-only response_format=MyModel is allowed in LangChain ≥1.0 #1560

@ScarletMercy

Description

@ScarletMercy

Type of issue

issue / bug

Language

Python

Description

Problem
The documentation gives two mutually exclusive statements about how to request structured output from an agent in LangChain ≥1.0.

Page: provider_strategy

As of langchain 1.0, simply passing a schema (e.g., response_format=ContactInfo) is no longer supported. You must explicitly use ToolStrategy or ProviderStrategy.

Page: response-format

Response Format
Controls how the agent returns structured data:

  • ToolStrategy[StructuredResponseT]: Uses tool calling for structured output
  • ProviderStrategy[StructuredResponseT]: Uses provider-native structured output
  • type[StructuredResponseT]: Schema type - automatically selects best strategy based on model capabilities
  • None: No structured output

When a schema type is provided directly, LangChain automatically chooses:

  • ProviderStrategy for models supporting native structured output (e.g. OpenAI, Grok)
  • ToolStrategy for all other models

The structured response is returned in the structured_response key of the agent’s final state.

Evidence (repro)
Running the following snippet today (2025-11-21) with langchain==1.0.8 (latest):

class Mood(BaseModel):
    mood: str = Field(..., description="LLM simulates mood from user message")
 

agent = create_agent(model, [], response_format=Mood)
resp = agent.invoke({"messages":  "Hello!"})
print(resp["messages"][-1])

Output contains a valid tool call and returns the expected structure:

content="Returning structured response: mood='friendly'" name='Mood' id=... tool_call_id='call_...'

No exception is raised, confirming that passing response_format=Mood (a schema type) is still accepted.

Suggested fix
Update the first page (provider_strategy) to align with the second page:

  • Remove the claim that “passing a schema directly is no longer supported.”
  • Clarify that supplying only a schema type is shorthand for “auto-select best strategy,” not deprecated.

Environment

langchain==1.0.8
Python 3.11.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    langchainFor docs changes to LangChain

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions