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

Closed
opened 2026-02-17 17:19:24 -05:00 by yindo · 0 comments
Owner

Originally created by @ScarletMercy on GitHub (Nov 21, 2025).
Original GitHub issue: https://github.com/langchain-ai/docs/issues/1560

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
Originally created by @ScarletMercy on GitHub (Nov 21, 2025). Original GitHub issue: https://github.com/langchain-ai/docs/issues/1560 ### 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](https://docs.langchain.com/oss/python/langchain/agents#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](https://docs.langchain.com/oss/python/langchain/structured-output#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](https://docs.langchain.com/oss/python/integrations/providers/openai), [Grok](https://docs.langchain.com/oss/python/integrations/providers/xai)) > - 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](https://docs.langchain.com/oss/python/langchain/agents#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 ```
yindo added the langchainexternal labels 2026-02-17 17:19:24 -05:00
yindo closed this issue 2026-02-17 17:19:24 -05:00
yindo changed title from [langchain]: Docs contradict on whether schema-only response_format=MyModel is allowed in LangChain ≥1.0 to [GH-ISSUE #1560] [langchain]: Docs contradict on whether schema-only response_format=MyModel is allowed in LangChain ≥1.0 2026-06-05 17:25:40 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/docs#212