# Create\_agent + ToolStrategy: Tools + Structured Output Not Working Across Models (LangChain 1.0.2)

**URL:** <https://forum.langchain.com/t/create-agent-toolstrategy-tools-structured-output-not-working-across-models-langchain-1-0-2/2293>\
**Category:** LangSmith Product Help\
**Created:** [November 21, 2025, 2:20pm UTC](https://forum.langchain.com/t/create-agent-toolstrategy-tools-structured-output-not-working-across-models-langchain-1-0-2/2293 "2025-11-21T14:20:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![prathamagarwal07](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/prathamagarwal07/32/1682_2.png) [@prathamagarwal07](https://forum.langchain.com/u/prathamagarwal07)\
**Post date:** [November 21, 2025, 2:20pm UTC](https://forum.langchain.com/t/create-agent-toolstrategy-tools-structured-output-not-working-across-models-langchain-1-0-2/2293/1 "2025-11-21T14:20:22Z")

</div>

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**

1. **Is there a recommended/official pattern for using tools + structured output together that works across different models—not just GPT-4o-mini?**

2. **Why does ProviderStrategy fail with models like Gemini 2.5 Pro that _claim_ to support structured output?  
Are there known incompatibilities?**

3. **Is there any fallback approach recommended, such as:**

4. **Is this limitation expected in LangChain 1.0.2, or should ToolStrategy and ProviderStrategy work together more reliably?**

---

<div class="post-metadata">

**Author:** ![Milan](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/milan/32/1750_2.png) [@Milan](https://forum.langchain.com/u/Milan)\
**Post date:** [November 26, 2025, 1:48pm UTC](https://forum.langchain.com/t/create-agent-toolstrategy-tools-structured-output-not-working-across-models-langchain-1-0-2/2293/2 "2025-11-26T13:48:09Z")

</div>

When using openrouter I found that using `ToolStrategy(YourPydanticModel.model_json_schema())` fixes most recursion loops.

The response sometimes needs to be parsed using (nested) `json.loads()`, but it’s valid json pretty much 99% of the time.

Since openrouter uses OpenAI format, the ProviderStrategy doesn’t work correctly when using other model providers through openrouter.

---

<div class="post-metadata">

**Author:** ![jrocco2](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/jrocco2/32/1716_2.png) [@jrocco2](https://forum.langchain.com/u/jrocco2)\
**Post date:** [November 27, 2025, 1:30am UTC](https://forum.langchain.com/t/create-agent-toolstrategy-tools-structured-output-not-working-across-models-langchain-1-0-2/2293/3 "2025-11-27T01:30:36Z")

</div>

Same issue for me!

---

<div class="post-metadata">

**Author:** ![ZYJ-3721](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.langchain.com/zyj-3721/32/2028_2.png) [@ZYJ-3721](https://forum.langchain.com/u/ZYJ-3721)\
**Post date:** [January 5, 2026, 1:48am UTC](https://forum.langchain.com/t/create-agent-toolstrategy-tools-structured-output-not-working-across-models-langchain-1-0-2/2293/4 "2026-01-05T01:48:15Z")

</div>

Currently, there is a conflict between the structured output of create\_agent and the tool call. Can it be optimized in this direction: 1. Place the restrictions on the structured output at the last output. 2. Set structured output for the tool. Within the agent, the llm can call different tools and use different structured outputs as the input for the tool functions. A bit of insight, I wonder if it’s feasible.
