langchain-ai/langchain · error · NotImplementedError

Trying to load an object that doesn't implement serializatio

Error message

Trying to load an object that doesn't implement serialization: {value}

What it means

Raised when the serialized payload contains a not_implemented marker (lc=1, type='not_implemented') — meaning the original object was dumped with skip_unserializable=True or otherwise replaced by a placeholder because it lacked serialization support — and the loader is asked to revive it. Loading cannot reconstruct the original object from the marker.

Source

Thrown at libs/core/langchain_core/load/load.py:496

            [key] = value["id"]
            if key in self.secrets_map:
                return self.secrets_map[key]
            if self.secrets_from_env and key in os.environ and os.environ[key]:
                return os.environ[key]
            return None

        if (
            value.get("lc") == 1
            and value.get("type") == "not_implemented"
            and value.get("id") is not None
        ):
            if self.ignore_unserializable_fields:
                return None
            msg = (
                "Trying to load an object that doesn't implement "
                f"serialization: {value}"
            )
            raise NotImplementedError(msg)

        if (
            value.get("lc") == 1
            and value.get("type") == "constructor"
            and value.get("id") is not None
        ):
            [*namespace, name] = value["id"]
            mapping_key = tuple(value["id"])

            if (
                self.allowed_class_paths is not None
                and mapping_key not in self.allowed_class_paths
            ):
                msg = (
                    f"Deserialization of {mapping_key!r} is not allowed. "
                    "The default (allowed_objects='core') only permits core "
                    "langchain-core classes. To allow trusted partner integrations, "
                    "use allowed_objects='all'. Alternatively, pass an explicit list "

View on GitHub (pinned to e32fa9a52e)

Solutions

  1. Implement serialization for the offending class (subclass Serializable / add lc_attributes handling) and re-dump
  2. Remove or replace the unsupported component in the object graph before dumping
  3. Pre-process the payload to drop not_implemented entries if your loader can tolerate missing fields

Example fix

# before
json_str = dumps(chain, stop_unserializable=True)
chain2 = loads(json_str)  # NotImplementedError
# after
json_str = dumps(chain_with_only_serializable_parts)
chain2 = loads(json_str)
Defensive patterns

Strategy: try-catch

Validate before calling

import json
def has_not_implemented(node) -> bool:
    if isinstance(node, dict):
        if node.get('lc') == 1 and node.get('type') == 'not_implemented':
            return True
        return any(has_not_implemented(v) for v in node.values())
    if isinstance(node, list):
        return any(has_not_implemented(v) for v in node)
    return False
if has_not_implemented(json.loads(text)):
    raise ValueError('payload contains not_implemented placeholders')

Try / catch

try:
    obj = loads(text)
except NotImplementedError:
    obj = loads(text)  # or: strip not_implemented nodes then retry / rebuild from scratch

Prevention

When it happens

Trigger: dumps(obj, stop_unserializable=True) on an object graph containing non-Serializable nodes, then loads() on that output without flags; loading JSON where a field was replaced by {"lc": 1, "type": "not_implemented", "id": [...]} .

Common situations: Round-tripping chains that embed custom tools/retrievers without serialization support; consuming payloads produced by another service that skipped unserializable fields; partial migrations where some components never implemented to_json.

Related errors


AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14). Data as JSON: /api/errors/ec6db24a3d55bcda. Report an issue: GitHub.