langchain - ✅(Solved) Fix create_agent with ProviderStrategy binds empty tools list and breaks OpenAI-compatible providers [2 pull requests, 2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langchain-ai/langchain#37184Fetched 2026-05-06 06:14:47
View on GitHub
Comments
2
Participants
2
Timeline
11
Reactions
0
Timeline (top)
labeled ×4commented ×2cross-referenced ×2issue_type_added ×1

When using create_agent(..., response_format=MySchema) without any user tools, LangChain can still end up binding an empty tool list in the ProviderStrategy path.

I expect LangChain to omit tool binding entirely in that case, since provider-native structured output does not require tool calling when there are no tools.

Instead, the request path reaches model.bind_tools([]), which causes failures against OpenAI-compatible providers that reject empty tools arrays. Starting with vLLM v0.20.0, this now fails consistently because vLLM validates that tools must either contain at least one item or be omitted entirely.

Error Message

With vLLM v0.20.0+, this consistently fails with an error equivalent to:

Error Message and Stack Trace (if applicable)

{'error': ValueError('tools must not be an empty array. Either provide at least one tool or omit the field entirely.')}

Root Cause

Instead, the request path reaches model.bind_tools([]), which causes failures against OpenAI-compatible providers that reject empty tools arrays. Starting with vLLM v0.20.0, this now fails consistently because vLLM validates that tools must either contain at least one item or be omitted entirely.

Fix Action

Fix / Workaround

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Other Dependencies

blockbuster: 1.5.26 click: 8.3.1 cloudpickle: 3.1.2 croniter: 6.2.2 cryptography: 46.0.6 grpcio: 1.78.0 grpcio-health-checking: 1.78.0 grpcio-tools: 1.78.0 httpx: 0.28.1 jsonpatch: 1.33 jsonschema-rs: 0.44.1 langgraph: 1.1.3 langgraph-checkpoint: 4.0.1 mcp: 1.26.0 openai: 2.30.0 opentelemetry-api: 1.40.0 opentelemetry-exporter-otlp-proto-http: 1.40.0 opentelemetry-sdk: 1.40.0 orjson: 3.11.7 packaging: 26.0 protobuf: 6.33.6 pydantic: 2.12.5 pyjwt: 2.12.1 python-dotenv: 1.2.2 pyyaml: 6.0.3 requests: 2.33.0 requests-toolbelt: 1.0.0 sse-starlette: 3.3.3 starlette: 1.0.0 structlog: 25.5.0 tenacity: 9.1.4 tiktoken: 0.12.0 truststore: 0.10.4 typing-extensions: 4.15.0 uuid-utils: 0.14.1 uvicorn: 0.42.0 watchfiles: 1.1.1 websockets: 16.0 xxhash: 3.6.0 zstandard: 0.25.0

PR fix notes

PR #37185: fix(langchain): omit empty tool bindings for provider strategy

Description (problem / solution / changelog)

Summary

This PR avoids calling model.bind_tools([]) when create_agent(...) resolves structured output to ProviderStrategy and there are no user tools.

Instead, in the provider-strategy branch, create_agent now:

  • calls model.bind_tools(...) when there is at least one tool
  • calls model.bind(...) with response_format when the final tool list is empty

This prevents serializing an empty tools field for providers that reject tools: [].

Motivation

This surfaced with newer vLLM validation behavior, which rejects requests where tools is present but empty and requires omitting the field entirely.

Related upstream context:

  • vllm-project/vllm#39741

In practice, this affected create_agent(..., response_format=...) flows using provider-native structured output with no tools.

Why this change is scoped here

I placed the fix in create_agent rather than a provider-specific adapter because the issue is at the agent orchestration layer:

  • create_agent already knows whether the final tool list is empty
  • binding through bind_tools([]) is unnecessary in that case
  • avoiding the empty tool binding keeps behavior unchanged when tools are actually present
  • this makes the behavior more robust across OpenAI-compatible providers, not just vLLM

Behavior before

When ProviderStrategy was selected and final_tools == [], create_agent still called:

model.bind_tools([], strict=True, response_format=..., ...)

For providers such as vLLM, this could result in a 400 because the request contained tools: [].

Behavior after

When ProviderStrategy is selected and final_tools is empty, create_agent now calls:

model.bind(response_format=..., ...)

So the tools field is omitted entirely.

Tests

Added a regression test in:

  • libs/langchain_v1/tests/unit_tests/agents/test_response_format.py

The test verifies that:

  • ProviderStrategy without tools does not call bind_tools([])
  • structured output still parses correctly

Issue / discussion

LangChain issue or approved discussion:

  • langchain-ai/langchain#37184

Related provider issue:

  • vllm-project/vllm#39741

Changed files

  • libs/langchain_v1/langchain/agents/factory.py (modified, +8/-3)
  • libs/langchain_v1/tests/unit_tests/agents/test_response_format.py (modified, +37/-0)

PR #37186: Fix: omit empty tools array in ProviderStrategy (fixes #37184)

Description (problem / solution / changelog)

Fixes #37184

Prevent binding of an empty tools array in ProviderStrategy by skipping bind_tools([]) and omitting the tools field when no tools are provided, ensuring compatibility with OpenAI-compatible providers.

Changed files

  • libs/langchain_v1/langchain/agents/factory.py (modified, +14/-6)
  • libs/langchain_v1/tests/unit_tests/agents/test_response_format.py (modified, +25/-0)
  • libs/langchain_v1/uv.lock (modified, +1/-1)

Code Example

`tools` must not be an empty array. Either provide at least one tool or omit the field entirely.

---

from pydantic import BaseModel
from langchain.agents import create_agent
from langchain_openai import ChatOpenAI

class MySchema(BaseModel):
    answer: str

model = ChatOpenAI(
    model="...",
    base_url="http://openai-compatible-provider/v1",
    api_key="test",
)

agent = create_agent(
    model=model,
    response_format=MySchema,
)

agent.invoke(
    {"messages": [{"role": "user", "content": "hello"}]}
)

---

{'error': ValueError('`tools` must not be an empty array. Either provide at least one tool or omit the field entirely.')}
RAW_BUFFERClick to expand / collapse

Submission checklist

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-openrouter
  • langchain-perplexity
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Related Issues / PRs

With vLLM v0.20.0+, this consistently fails with an error equivalent to:

`tools` must not be an empty array. Either provide at least one tool or omit the field entirely.

Related provider-side issue:

  • vllm-project/vllm#39741

Reproduction Steps / Example Code (Python)

from pydantic import BaseModel
from langchain.agents import create_agent
from langchain_openai import ChatOpenAI

class MySchema(BaseModel):
    answer: str

model = ChatOpenAI(
    model="...",
    base_url="http://openai-compatible-provider/v1",
    api_key="test",
)

agent = create_agent(
    model=model,
    response_format=MySchema,
)

agent.invoke(
    {"messages": [{"role": "user", "content": "hello"}]}
)

Error Message and Stack Trace (if applicable)

{'error': ValueError('`tools` must not be an empty array. Either provide at least one tool or omit the field entirely.')}

Description

When using create_agent(..., response_format=MySchema) without any user tools, LangChain can still end up binding an empty tool list in the ProviderStrategy path.

I expect LangChain to omit tool binding entirely in that case, since provider-native structured output does not require tool calling when there are no tools.

Instead, the request path reaches model.bind_tools([]), which causes failures against OpenAI-compatible providers that reject empty tools arrays. Starting with vLLM v0.20.0, this now fails consistently because vLLM validates that tools must either contain at least one item or be omitted entirely.

System Info

System Information

OS: Darwin OS Version: Darwin Kernel Version 25.4.0: Thu Mar 19 19:32:59 PDT 2026; root:xnu-12377.101.15~1/RELEASE_ARM64_T8122 Python Version: 3.12.11 (main, Jun 4 2025, 17:42:58) [Clang 20.1.4 ]

Package Information

langchain_core: 1.2.22 langchain: 1.2.13 langsmith: 0.7.22 langchain_mcp_adapters: 0.2.2 langchain_openai: 1.1.12 langgraph_api: 0.7.89 langgraph_cli: 0.4.19 langgraph_runtime_inmem: 0.26.0 langgraph_sdk: 0.3.12 langgraph_supervisor: 0.0.31

Optional packages not installed

deepagents deepagents-cli

Other Dependencies

blockbuster: 1.5.26 click: 8.3.1 cloudpickle: 3.1.2 croniter: 6.2.2 cryptography: 46.0.6 grpcio: 1.78.0 grpcio-health-checking: 1.78.0 grpcio-tools: 1.78.0 httpx: 0.28.1 jsonpatch: 1.33 jsonschema-rs: 0.44.1 langgraph: 1.1.3 langgraph-checkpoint: 4.0.1 mcp: 1.26.0 openai: 2.30.0 opentelemetry-api: 1.40.0 opentelemetry-exporter-otlp-proto-http: 1.40.0 opentelemetry-sdk: 1.40.0 orjson: 3.11.7 packaging: 26.0 protobuf: 6.33.6 pydantic: 2.12.5 pyjwt: 2.12.1 python-dotenv: 1.2.2 pyyaml: 6.0.3 requests: 2.33.0 requests-toolbelt: 1.0.0 sse-starlette: 3.3.3 starlette: 1.0.0 structlog: 25.5.0 tenacity: 9.1.4 tiktoken: 0.12.0 truststore: 0.10.4 typing-extensions: 4.15.0 uuid-utils: 0.14.1 uvicorn: 0.42.0 watchfiles: 1.1.1 websockets: 16.0 xxhash: 3.6.0 zstandard: 0.25.0

extent analysis

TL;DR

The issue can be resolved by omitting the tools field or providing at least one tool when creating an agent with LangChain.

Guidance

  • Verify that the create_agent function is called without any user tools, which causes LangChain to bind an empty tool list.
  • Check the ProviderStrategy path to ensure it handles the case where no tools are provided.
  • Consider modifying the create_agent function to omit the tools field when no tools are provided, rather than passing an empty list.
  • Review the related provider-side issue (vllm-project/vllm#39741) for potential solutions or workarounds.

Example

No code example is provided as the issue is related to the internal implementation of LangChain and requires a deeper understanding of the library's codebase.

Notes

The issue is specific to LangChain and OpenAI-compatible providers, and the solution may not apply to other libraries or providers. The fix may require modifications to the LangChain library itself, rather than just the user's code.

Recommendation

Apply a workaround by modifying the create_agent function to omit the tools field when no tools are provided, as this is a more straightforward solution than upgrading to a fixed version of LangChain, which may not be available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

langchain - ✅(Solved) Fix create_agent with ProviderStrategy binds empty tools list and breaks OpenAI-compatible providers [2 pull requests, 2 comments, 2 participants]