Applied AI
A cached LangGraph task may fail on valid mapping keys
Diagnose a TypeError in a cached task before its body runs when mapping keys cannot be ordered.
November 10, 2026
A task can fail before its own code runs. In LangGraph issue 9566, a cached @task receives a keyword-argument mapping with Enum keys. The default cache-key path sorts mapping keys; hashable keys are not necessarily comparable, so TypeError occurs before the task body. The report also reproduces mixed key types.
Identify the failing boundary
Capture the exception, task signature, cache policy and a sanitized input shape. Reduce it to a mapping with two keys of the same problematic type. Run once with caching and once without; if the uncached call succeeds, investigate key generation rather than the downstream tool.
LangGraph's Functional API explains tasks and entrypoints. The issue provides a direct default_cache_key reproduction and notes that positional and keyword argument paths differ in its example. Keep the reproduction tied to the package version in use.
Choose a stable key contract
For a local workaround, convert domain keys to stable strings before the cache boundary or supply a reviewed key function where supported. Do not use a representation that changes with process order, locale or Python object identity. Test that semantically identical inputs share a key and distinct inputs do not collide.
If cached results persist across deployments, plan how a key-function change affects old entries. Make the exception visible and retest when an upstream fix is released.
Adovo’s view
Caching is part of the agent's correctness model. A cache key must represent the business input deterministically, not merely be easy to compute. Prove that contract before using cache hits as evidence of reliable behavior.
