{"record":{"id":"e08a7653eb1eaeb0","repo":"langchain-ai/langgraph","slug":"cache-is-only-available-server-side-within-the-lan","errorCode":null,"errorMessage":"Cache is only available server-side within the LangGraph Agent Server (https://docs.langchain.com/langgraph/deployments).","messagePattern":"Cache is only available server-side within the LangGraph Agent Server \\(https://docs\\.langchain\\.com/langgraph/deployments\\)\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"libs/sdk-py/langgraph_sdk/cache.py","lineNumber":67,"sourceCode":"\n\n__all__ = [\n    \"SWRResult\",\n    \"cache_get\",\n    \"cache_set\",\n    \"swr\",\n]\n\n\nasync def cache_get(key: str) -> Any | None:\n    \"\"\"Get a value from the cache.\n\n    Returns the deserialized value, or ``None`` if the key is missing or expired.\n\n    Requires Agent Server runtime version 0.7.29 or later.\n    \"\"\"\n    if _cache_get is None:\n        raise RuntimeError(\n            \"Cache is only available server-side within the LangGraph Agent Server \"\n            \"(https://docs.langchain.com/langsmith/deployments).\"\n        )\n    return await _cache_get(key)\n\n\nasync def cache_set(key: str, value: Any, *, ttl: timedelta | None = None) -> None:\n    \"\"\"Set a value in the cache.\n\n    Args:\n        key: The cache key.\n        value: The value to cache (must be JSON-serializable).\n        ttl: Optional time-to-live. Capped at 1 day; ``None`` or zero\n            defaults to 1 day.\n\n    Requires Agent Server runtime version 0.7.29 or later.\n    \"\"\"\n    if _cache_set is None:","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/sdk-py/langgraph_sdk/cache.py#L49-L85","documentation":"Environment guard in the cache helpers: cache_get/cache_set work by calling runtime hooks that the LangGraph Agent Server injects at startup. When the code runs outside Agent Server (plain Python, tests, local scripts) the hook is None and this RuntimeError fires to say the server-side cache is unavailable.","triggerScenarios":"Thrown at libs/sdk-py/langgraph_sdk/cache.py:67 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Move the caching code so it executes inside a LangGraph Agent Server deployment (requires runtime >= 0.7.29)","Guard the call, e.g. only use cache_get/cache_set when the code runs server-side, and provide a local no-op or dict-based fallback","Skip the cache path in local development and tests"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"38031739e551638e373fb553453256c23feeb41f","analyzedAt":"2026-08-26T18:02:49.312Z","contentChangedAt":"2026-08-26T18:02:49.312Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}