-
Notifications
You must be signed in to change notification settings - Fork 19.9k
Description
Checked other resources
- 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-cli
- 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-perplexity
- langchain-prompty
- langchain-qdrant
- langchain-xai
- Other / not sure / general
Example Code (Python)
By default, the model has the freedom to choose which bound tool to use based on the user’s input. However, you might want to force choosing a tool, ensuring the model uses either a particular tool or any tool from a given list:
model_with_tools = model.bind_tools([tool_1], tool_choice="any")
or
model_with_tools = model.bind_tools([tool_1], tool_choice="tool_1")Error Message and Stack Trace (if applicable)
Description
"Forcing tool calls" is not universal. Its effectiveness and application are related to the use of large models. Can it be made universal?
For example, when using the "Qwen3-30B-A3B-Instruct-2507" large model, setting tool_choice="any" will not take effect, but changing it to tool_choice="auto" will make it work.
System Info
System Information
OS: Linux
OS Version: #1 SMP PREEMPT_DYNAMIC Debian 6.1.148-1 (2025-08-26)
Python Version: 3.13.9 | packaged by Anaconda, Inc. | (main, Oct 21 2025, 19:16:10) [GCC 11.2.0]
Package Information
langchain_core: 1.1.0
langchain: 1.1.0
langchain_community: 0.4.1
langsmith: 0.4.37
langchain_classic: 1.0.0
langchain_cohere: 0.5.0
langchain_mcp_adapters: 0.1.14
langchain_openai: 1.1.0
langchain_postgres: 0.0.16
langchain_text_splitters: 1.0.0
langgraph_api: 0.5.27
langgraph_cli: 0.4.7
langgraph_runtime_inmem: 0.19.0
langgraph_sdk: 0.2.10
Optional packages not installed
langserve
Other Dependencies
aiohttp: 3.13.2
asyncpg: 0.30.0
blockbuster: 1.5.25
click: 8.3.0
cloudpickle: 3.1.1
cohere: 5.20.0
cryptography: 44.0.3
dataclasses-json: 0.6.7
grpcio: 1.76.0
grpcio-tools: 1.75.1
httpx: 0.28.1
httpx-sse: 0.4.0
jsonpatch: 1.33
jsonschema-rs: 0.29.1
langgraph: 1.0.3
langgraph-checkpoint: 3.0.1
mcp: 1.22.0
numpy: 2.3.4
openai: 2.6.0
opentelemetry-api: 1.38.0
opentelemetry-exporter-otlp-proto-http: 1.38.0
opentelemetry-sdk: 1.38.0
orjson: 3.11.3
packaging: 25.0
pgvector: 0.3.6
protobuf: 6.33.0
psycopg: 3.2.12
psycopg-pool: 3.2.7
pydantic: 2.12.3
pydantic-settings: 2.11.0
pyjwt: 2.10.1
python-dotenv: 1.1.1
pyyaml: 6.0.3
PyYAML: 6.0.3
requests: 2.32.5
requests-toolbelt: 1.0.0
sqlalchemy: 2.0.44
SQLAlchemy: 2.0.44
sse-starlette: 2.1.3
starlette: 0.48.0
structlog: 25.4.0
tenacity: 9.1.2
tiktoken: 0.12.0
truststore: 0.10.4
types-pyyaml: 6.0.12.20250915
typing-extensions: 4.15.0
uvicorn: 0.38.0
watchfiles: 1.1.1
zstandard: 0.25.0