Install & Compatibility
Where this runs
tested against v0.0.7.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.9
✕ build_error
✕ build_error
73MB installed
● package 73MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
create_tools_json
✓ from langgraph_utils import create_tools_json
This function converts a list of LangChain StructuredTool objects into a JSON string.
This quickstart demonstrates how to use `create_tools_json` to serialize a list of mock LangChain `StructuredTool` objects into a JSON string. While the `langgraph-utils` PyPI description mentions conversion 'and vice versa', the `create_tools_json` function is explicitly detailed. For deserialization, you would typically use standard JSON parsing and potentially recreate `StructuredTool` instances based on the JSON structure.
import os
from typing import List, Dict, Any
from langchain_core.tools import StructuredTool
from langgraph_utils import create_tools_json
# Mock a LangChain StructuredTool
# In a real application, you would import and define actual tools.
class MockTool(StructuredTool):
name: str = "mock_tool"
description: str = "A mock tool for demonstration."
args_schema: Dict[str, Any] = {"param": {"type": "string", "description": "A parameter"}}
def _run(self, param: str) -> str:
return f"MockTool executed with: {param}"
async def _arun(self, param: str) -> str:
return f"MockTool async executed with: {param}"
mock_tools = [
MockTool(name='search_internet', description='Searches the internet for information'),
MockTool(name='get_weather', description='Fetches current weather for a location')
]
tools_json_string = create_tools_json(mock_tools)
print(f"Serialized Tools: {tools_json_string}")
# Example of deserialization (assuming a hypothetical deserialize_tools_json function exists or custom logic)
# This library's PyPI description focuses on 'create_tools_json', but also mentions 'and vice versa'.
# For full deserialization, you might need to implement custom logic or use other LangChain utilities.
# For illustrative purposes, we'll just show the structure.
import json
deserialized_data = json.loads(tools_json_string)
print(f"Deserialized data structure: {deserialized_data[0]['name']}")
Debug
Known issues
gotchaThe official PyPI description for `langgraph-utils` (version 0.0.7.4) specifies its role as a 'LangChain Tools JSON Converter', focusing on `create_tools_json`. This is more specific than the broader 'Utilities for Langchain and langgraph' summary provided in some contexts. Ensure this specific JSON conversion functionality aligns with your needs.fixRefer to the official PyPI page for `langgraph-utils` for the precise functionality and exposed methods.
affects: All versions
breakingLangChain and LangGraph APIs, including tool definitions (`StructuredTool`), undergo updates. Breaking changes, especially in major LangChain/LangGraph versions (e.g., LangGraph v1.0), could affect how tools are defined or interpreted, potentially impacting the serialization/deserialization process.fixAlways pin major versions of `langchain` and `langgraph`. Regularly check their migration guides (e.g., LangGraph v1 migration guide) and test your serialization/deserialization logic when upgrading core LangChain/LangGraph libraries.
affects: Potentially LangChain >= 0.2, LangGraph >= 1.0
gotchaIf `langgraph-utils` is used within a larger LangGraph application, pay close attention to state management. Incorrectly serialized or deserialized tool definitions, or state changes during parallel execution, can lead to unexpected tool calls or graph behavior.fixDefine a clear `TypedDict` or Pydantic model for your graph state. Validate tool inputs and outputs rigorously within your nodes. Utilize LangGraph's checkpointing and LangSmith for debugging complex state transitions.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'langgraph_utils'
The 'langgraph-utils' library is not installed in the current Python environment or the environment is not correctly activated.
fixInstall the library using pip: `pip install langgraph-utils==0.0.7.4`
TypeError: Object of type <ClassName> is not JSON serializable
This error occurs when attempting to serialize a LangChain tool object (or a component within it) that `langgraph-utils`'s `create_tools_json` function does not inherently know how to convert into a JSON-compatible format. This can happen if the tool object contains complex custom types or objects that are not standard Python primitives, lists, or dictionaries.
fixEnsure that all components within your LangChain tool objects are JSON-serializable. You may need to manually convert specific complex objects within your tool definitions into a JSON-compatible representation (e.g., dictionaries, strings) before passing them to `create_tools_json`, or implement custom serialization logic for those types.
AttributeError: module 'langgraph_utils' has no attribute 'json_to_tool'
Users often expect a symmetrical function for deserialization (e.g., `json_to_tool`) when a library provides a serialization function like `create_tools_json`. However, `langgraph-utils` (version 0.0.7.4) primarily focuses on converting LangChain tool objects to JSON and does not expose a direct utility function for deserializing JSON back into LangChain tool objects.
fixTo deserialize, you need to use standard Python `json.loads()` to parse the JSON string and then manually reconstruct the LangChain `StructuredTool` (or other appropriate LangChain tool) instances based on the structure defined in the JSON. There is no direct `langgraph_utils.json_to_tool` function.
Upgrade
Version history
0.0.7.4latest on PyPI · released May 19, 2025
Audit
Dependencies
langchainrequiredProvides the StructuredTool objects that this library serializes and deserializes.
langgraphrequiredThe utilities are intended for use within LangGraph applications.