Skip to content

openai_tools.parse_tool_call #34123

@Fishingfire

Description

@Fishingfire

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)

raw_tool_call = {'function': {'arguments': None, 'name': 'orderStatus'}, 'id': 'chatcmpl-tool-8b1f759d874b412e931e64cf6f57bdcc', 'type': 'function'}
parse_tool_call(raw_tool_call, return_id=True)

Error Message and Stack Trace (if applicable)

the JSON object must be str, bytes or bytearray, not NoneType

Description

When providing an LLM with a parameter-less tool, if the LLM decides to call this tool, it will only output the tool name without any additional parameters. In this situation, the tool call fails to parse because no parameters are provided, causing the system to be unable to locate or invoke the tool.
The issue occurs during the execution of the following code:

function_args = parse_partial_json(
raw_tool_call["function"]["arguments"], strict=strict
)

At this point, the absence of arguments causes parse_partial_json to fail.

System Info

System Information

OS: Windows
OS Version: 10.0.26100
Python Version: 3.14.0 (tags/v3.14.0:ebf955d, Oct 7 2025, 10:15:03) [MSC v.1944 64 bit (AMD64)]

Package Information

langchain_core: 1.0.5
langchain: 1.0.7
langsmith: 0.4.37
langchain_google_genai: 3.0.0
langchain_mcp_adapters: 0.1.11
langchain_ollama: 1.0.0
langchain_openai: 1.0.3
langgraph_sdk: 0.2.9

Optional packages not installed

langserve

Other Dependencies

filetype: 1.2.0
google-ai-generativelanguage: 0.9.0
httpx: 0.28.1
jsonpatch: 1.33
langgraph: 1.0.3
mcp: 1.18.0
ollama: 0.6.0
openai: 2.7.2
orjson: 3.11.3
packaging: 25.0
pydantic: 2.12.3
pyyaml: 6.0.3
requests: 2.32.5
requests-toolbelt: 1.0.0
tenacity: 9.1.2
tiktoken: 0.12.0
typing-extensions: 4.15.0
zstandard: 0.25.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugRelated to a bug, vulnerability, unexpected error with an existing featurecoreRelated to the package `langchain-core`

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions