Hi everyone — I’m running into a major limitation with create_agent in LangChain 1.0.2, specifically when using tools + structured output together.
I’ve tested both ToolStrategy and ProviderStrategy, and each has problems in different ways.
Issue Summary
1. ToolStrategy — Tools + Structured Output Conflict
When using ToolStrategy with real tools and structured output:
-
Agent hits recursion limit (30 iterations)
-
Real tool calls don’t execute properly
-
The artificial structured-output tool conflicts with actual tools
-
The agent keeps retrying instead of returning valid structured output
This makes ToolStrategy unusable when both tools + structured output are required.
2. ProviderStrategy — Only Works With Very Few Models
Switching to ProviderStrategy fixes the conflict, but introduces a new issue:
Works:
openai/gpt-4o-mini(via OpenRouter)
Fails (recursion loops, parsing errors):
-
google/gemini-2.5-pro -
openai/gpt-5 -
Several other OpenRouter models
This means ProviderStrategy only works with a very limited subset of models, even when the models claim to support structured output.
What I Expect
Ideally, I want an agent that can:
-
Use real tools (tool calling)
-
Return structured output at the end
-
Work across multiple models that support tool calling + structured output
-
Avoid recursion-limit failures from parsing mismatch
Environment
-
LangChain: 1.0.2
-
LangGraph: 0.2.62
-
Provider: OpenRouter
-
Models tested: GPT-4o-mini (works), Gemini 2.5 Pro (fails), GPT-5 (fails)
Questions
-
Is there a recommended/official pattern for using tools + structured output together that works across different models—not just GPT-4o-mini?
-
Why does ProviderStrategy fail with models like Gemini 2.5 Pro that claim to support structured output?
Are there known incompatibilities? -
Is there any fallback approach recommended, such as:
-
Doing tool calling first, then applying
with_structured_output()after? -
Prompt-based JSON mode instead of
response_format? -
Splitting tool calling + structured output into separate agent steps?
-
-
Is this limitation expected in LangChain 1.0.2, or should ToolStrategy and ProviderStrategy work together more reliably?