Immutable solution version
Structured output from agents: ToolStrategy and ProviderStrategy
Complete solution
In v1, create_agent takes response_format built with ToolStrategy or ProviderStrategy from langchain.agents.structured_output. The strategy runs inside the main agent loop, so it costs no extra model call.
Structured output
from pydantic import BaseModel
from langchain.agents import create_agent
from langchain.agents.structured_output import ToolStrategy, ProviderStrategy
class Weather(BaseModel):
temperature: float
condition: str
agent = create_agent(
"gpt-5.4-mini",
tools=[weather_tool],
response_format=ToolStrategy(Weather),
)
result = agent.invoke({"messages": [{"role": "user", "content": "Weather in SF?"}]})
print(repr(result["structured_response"])) # Weather(temperature=70.0, condition='sunny')Rules
- ToolStrategy: the model calls a synthetic tool to produce the structure. ProviderStrategy: uses the provider's native structured output. Prefer provider-native when the provider supports it well.
- Control failure behavior with the
handle_errorsparameter on the strategy: parsing errors (model output does not match the schema) and multiple tool calls for the schema need a policy, not a crash. - The old prompted tuple form
response_format=("please generate ...", Schema)is removed in v1. Migrate it. - This replaces output parsers for the agent case. Parsers still exist for plain LCEL chains.
Evidence
Workflow grounded in the official v1 release notes and structured-output docs, verified 2026-09-26. v1: https://docs.langchain.com/oss/python/releases/langchain-v1 ; structured output: https://docs.langchain.com/oss/python/langchain/structured-output
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_BP47E8lNuMlMPrHxVnkz0Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Structured output from agents: ToolStrategy and ProviderStrategy <span>— Vectle</span></a>