# upgrade_install_command

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/update_check/upgrade_install_command)

Return the uv command that upgrades dcode while clearing stale pins.

Built specifically to avoid the `uv tool upgrade` receipt-pin trap: when
the tool was originally installed via `uv tool install deepagents-code==X.Y.Z`
— or when a prior `dependency_refresh_command` rewrote the receipt with a
version-pinned requirement — `uv tool upgrade deepagents-code` will only
re-resolve *within* that pin and silently keep the user on the same
version. Re-running `uv tool install -U deepagents-code[<extras>]` (no
version pin) rewrites the receipt's requirement to unpinned so the next
upgrade can actually move forward. Callers can still pass `version` when
the resolver must allow pre-release dependencies for a stable app target;
that prevents the root `deepagents-code` package from floating to a newer
app pre-release. Installed extras and `--with` packages are preserved to
mirror `dependency_refresh_command`.

## Signature

```python
upgrade_install_command(
    *,
    include_prereleases: bool | None = None,
    distribution_name: str = 'deepagents-code',
    version: str | None = None,
    constraints_path: Path | None = None,
    prerelease_strategy: UvPrereleaseStrategy | None = None,
) -> str
```

## Description

Propagates `ExtrasIntrospectionError` if installed extras cannot be
determined safely from distribution metadata, or a metadata-sourced extra name
fails PEP 508 validation. Also propagates `ToolRequirementIntrospectionError`
if the uv tool `--with` packages or interpreter cannot be determined safely
from the tool receipt. Callers choose whether to treat those errors as
failures or fall back to a simpler unpinned upgrade command with a
user-facing warning.

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `include_prereleases` | `bool \| None` | No | Whether to include alpha/beta/rc releases. When `None`, follows the installed version's channel. (default: `None`) |
| `distribution_name` | `str` | No | Name of the installed distribution to inspect for already-installed extras. (default: `'deepagents-code'`) |
| `version` | `str \| None` | No | Optional exact target version. Use only when pre-release dependency resolution must not also select a root app pre-release. (default: `None`) |
| `constraints_path` | `Path \| None` | No | Optional uv constraints file pinning the exact pre-release dependency, forwarded as `--constraints <path>`. (default: `None`) |
| `prerelease_strategy` | `UvPrereleaseStrategy \| None` | No | Optional uv `--prerelease` strategy (e.g. `if-necessary-or-explicit`) that admits only the constrained pre-release instead of a global `allow`. (default: `None`) |

## Returns

`str`

Shell command string suitable for execution via the shell.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/7794b61a6e76230e8c7a49bdce808b3728305914/libs/code/deepagents_code/update_check.py#L2708)