langchain-ai/deepagents · error · ValueError

managed_snapshot is a different generation than the one in f

Error message

managed_snapshot is a different generation than the one in force; pass refresh_managed=True to install it

What it means

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.

Source

Thrown at libs/code/deepagents_code/configuration/resolver.py:607

            reset_source_diagnostics()
            return resolver
        resolver = entry[1]
        if not refresh_managed:
            # A caller that hands over a snapshot and does not ask for a
            # refresh is telling the resolver to keep serving what it has, so
            # the two must already agree. They do today -- the preview path
            # takes its snapshot with `refresh=False`, which returns the
            # cached one -- but nothing in the signature says so, and the
            # alternative is discarding a validated generation in silence.
            if managed_snapshot is not None:
                installed = resolver.toml_snapshot(MANAGED_RANK)
                if installed is not None and installed != managed_snapshot:
                    msg = (
                        "managed_snapshot is a different generation than the "
                        "one in force; pass refresh_managed=True to install it"
                    )
                    raise ValueError(msg)
            return resolver
        resolver.reload_with_replacements(
            {
                MANAGED_RANK: _managed_replacement_provider(
                    resolver,
                    managed,
                )
            }
        )
        return resolver


def _serves_usable_policy(provider: ConfigProvider) -> bool:
    """Whether a replacement is serving a snapshot resolution can trust.

    A replacement bypasses `reload`, so it needs a usable generation behind it.
    Its latest status may still be unusable while it safely retains the
    previous snapshot; rejecting that state would erase the failed-refresh

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Pass `refresh_managed=True` to install the newer managed generation.
  2. 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).
  3. 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.

Example fix

// before: stale snapshot on a cache hit
resolver = get_config_resolver(managed_snapshot=stale_snap)
// ValueError: managed_snapshot is a different generation...
// after
resolver = get_config_resolver(managed_snapshot=new_snap, refresh_managed=True)
Defensive patterns

Strategy: validation

Validate before calling

resolver = get_config_resolver()  # no snapshot argument
installed = resolver.toml_snapshot(MANAGED_RANK)
if managed_snapshot is not None and installed is not None and installed != managed_snapshot:
    resolver = get_config_resolver(managed_snapshot=managed_snapshot, refresh_managed=True)
else:
    resolver = get_config_resolver(managed_snapshot=managed_snapshot)

Try / catch

try:
    resolver = get_config_resolver(managed_snapshot=snap)
except ValueError as exc:
    if "different generation" in str(exc):
        resolver = get_config_resolver(managed_snapshot=snap, refresh_managed=True)
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29). Data as JSON: /api/errors/26b354bf2405ad04. Report an issue: GitHub.