langchain-ai/deepagents · error · ValueError
a different CLI provider is already installed for this proce
Error message
a different CLI provider is already installed for this process
What it means
get_config_resolver keeps one CLI-tier provider per process in the shared resolver cache. Passing a `cli_provider` that differs from the one already installed raises ValueError: one argv must map to one CLI tier, and silently keeping either provider would misreport the flags the other carries.
Source
Thrown at libs/code/deepagents_code/configuration/resolver.py:561
provider would misreport every flag the other one carries.
"""
from deepagents_code.configuration.providers import TomlFileProvider
from deepagents_code.configuration.service import get_managed_snapshot
from deepagents_code.model_config import DEFAULT_CONFIG_PATH
if managed_snapshot is not None:
managed = managed_snapshot
elif refresh_managed:
managed = _reload_enforceable_managed_snapshot()
else:
managed = get_managed_snapshot()
key = _ResolverKey(DEFAULT_CONFIG_PATH, managed.status.path)
with _resolver_cache_lock:
installed_cli = _resolver_cache.cli_provider
if cli_provider is not None:
if installed_cli is not None and installed_cli != cli_provider:
msg = "a different CLI provider is already installed for this process"
raise ValueError(msg)
_resolver_cache.cli_provider = cli_provider
installed_cli = cli_provider
entry = _resolver_cache.entry
if (
entry is None
or entry[0] != key
or (
cli_provider is not None
and CLI_RANK not in entry[1].provider_statuses()
)
):
user_provider = TomlFileProvider(
name="config.toml", path=DEFAULT_CONFIG_PATH
)
user = user_provider.load()
resolver = resolver_from_snapshots(
managed=managed,
user=user,View on GitHub (pinned to a1af029e6e)
Solutions
- Reuse the same CLI provider instance for all get_config_resolver calls in the process.
- Reset the resolver cache (the module's `_resolver_cache`) between logically distinct phases, e.g. in test setup/teardown.
- If flags genuinely changed, restart the process or build a fresh resolver instead of the shared cached one.
Example fix
// before (test) get_config_resolver(cli_provider=provider_a) get_config_resolver(cli_provider=provider_b) # ValueError // after: reset the shared cache between phases reset_resolver_cache() # or fixture that clears _resolver_cache get_config_resolver(cli_provider=provider_b)
Defensive patterns
Strategy: validation
Validate before calling
def cli_provider_matches_cached(cached_cli, new_cli) -> bool:
return cached_cli is None or cached_cli == new_cli
assert cli_provider_matches_cached(_resolver_cache.cli_provider, cli_provider), (
"Process already installed a different CLI provider; reset the cache or reuse it."
) Try / catch
try:
resolver = get_config_resolver(cli_provider=new_cli)
except ValueError as exc:
if "different CLI provider" in str(exc):
reset_resolver_cache() # e.g. between test phases / re-parse
resolver = get_config_resolver(cli_provider=new_cli)
else:
raise Prevention
- Parse CLI arguments once per process and reuse the resulting provider for all resolver lookups.
- Reset the module-level `_resolver_cache` in test setup/teardown when swapping CLI providers.
- Never rebuild an argparse-derived CLI provider mid-process with different flags.
When it happens
Trigger: Calling `get_config_resolver(cli_provider=A)` after a previous call in the same process installed `cli_provider=B` (A != B) — e.g. re-parsing arguments mid-process and rebuilding a different argparse provider, or test code swapping CLI providers without resetting the `_resolver_cache`.
Common situations: Re-running argument parsing twice with different flags in one process (scripts embedding dcode internals); unit tests leaking a cached CLI provider between cases because they didn't reset the module-level cache; programmatic overrides layered on top of real argv.
Related errors
- managed_snapshot is a different generation than the one in f
- enable_interpreter=True is not supported with a remote sandb
- a provider already serves rank {provider.rank}
- shared config resolver has no managed TOML provider
- thread display options are missing from the configuration ma
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/516c2027500d3f35.
Report an issue: GitHub.