{"record":{"id":"26b354bf2405ad04","repo":"langchain-ai/deepagents","slug":"managed-snapshot-is-a-different-generation-than-th","errorCode":null,"errorMessage":"managed_snapshot is a different generation than the one in force; pass refresh_managed=True to install it","messagePattern":"managed_snapshot is a different generation than the one in force; pass refresh_managed=True to install it","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/configuration/resolver.py","lineNumber":607,"sourceCode":"\n            reset_source_diagnostics()\n            return resolver\n        resolver = entry[1]\n        if not refresh_managed:\n            # A caller that hands over a snapshot and does not ask for a\n            # refresh is telling the resolver to keep serving what it has, so\n            # the two must already agree. They do today -- the preview path\n            # takes its snapshot with `refresh=False`, which returns the\n            # cached one -- but nothing in the signature says so, and the\n            # alternative is discarding a validated generation in silence.\n            if managed_snapshot is not None:\n                installed = resolver.toml_snapshot(MANAGED_RANK)\n                if installed is not None and installed != managed_snapshot:\n                    msg = (\n                        \"managed_snapshot is a different generation than the \"\n                        \"one in force; pass refresh_managed=True to install it\"\n                    )\n                    raise ValueError(msg)\n            return resolver\n        resolver.reload_with_replacements(\n            {\n                MANAGED_RANK: _managed_replacement_provider(\n                    resolver,\n                    managed,\n                )\n            }\n        )\n        return resolver\n\n\ndef _serves_usable_policy(provider: ConfigProvider) -> bool:\n    \"\"\"Whether a replacement is serving a snapshot resolution can trust.\n\n    A replacement bypasses `reload`, so it needs a usable generation behind it.\n    Its latest status may still be unusable while it safely retains the\n    previous snapshot; rejecting that state would erase the failed-refresh","sourceCodeStart":589,"sourceCodeEnd":625,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/configuration/resolver.py#L589-L625","documentation":"When get_config_resolver is called with a `managed_snapshot` but without `refresh_managed`, the resolver is documented to keep serving the generation it already has. If the passed snapshot differs from the installed MANAGED_RANK snapshot, that new generation would be silently discarded, so the resolver raises ValueError telling the caller to pass `refresh_managed=True` to install it.","triggerScenarios":"Calling `get_config_resolver(managed_snapshot=snap)` on a cache hit where `resolver.toml_snapshot(MANAGED_RANK)` exists and `snap != installed` — i.e. the managed file changed (or a newer enforceable generation published) between when the caller fetched its snapshot and when it requested the resolver, without asking for a refresh.","commonSituations":"Long-lived processes where the managed policy file is rewritten (remote policy push, another dcode instance installing new managed config) while a caller holds a stale preview snapshot; preview paths mixing `refresh=False` snapshots with later resolver lookups; tests fabricating snapshots that don't match the real managed file.","solutions":["Pass `refresh_managed=True` to install the newer managed generation.","Re-fetch the snapshot in the same generation the resolver serves (e.g. take the snapshot with `refresh=False` so you get the cached one).","If staleness is intentional, compare snapshots first and only call get_config_resolver when they match, or handle the ValueError by re-validating the new generation."],"exampleFix":"// before: stale snapshot on a cache hit\nresolver = get_config_resolver(managed_snapshot=stale_snap)\n// ValueError: managed_snapshot is a different generation...\n// after\nresolver = get_config_resolver(managed_snapshot=new_snap, refresh_managed=True)","handlingStrategy":"validation","validationCode":"resolver = get_config_resolver()  # no snapshot argument\ninstalled = resolver.toml_snapshot(MANAGED_RANK)\nif managed_snapshot is not None and installed is not None and installed != managed_snapshot:\n    resolver = get_config_resolver(managed_snapshot=managed_snapshot, refresh_managed=True)\nelse:\n    resolver = get_config_resolver(managed_snapshot=managed_snapshot)","typeGuard":null,"tryCatchPattern":"try:\n    resolver = get_config_resolver(managed_snapshot=snap)\nexcept ValueError as exc:\n    if \"different generation\" in str(exc):\n        resolver = get_config_resolver(managed_snapshot=snap, refresh_managed=True)\n    else:\n        raise","preventionTips":["Take managed snapshots with `refresh=False` so they match the cached generation the resolver serves.","Pass `refresh_managed=True` whenever the snapshot may legitimately have advanced since fetch.","In long-lived processes, re-fetch rather than hoarding snapshots across policy updates.","In tests, derive snapshots from the real managed service instead of fabricating them."],"tags":["configuration","resolver","snapshot","generation-mismatch","caching"],"backgroundTag":"stale-cache-generation","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}