Skip to content

fix(code): always restart after a successful startup auto-update - #5317

Merged
Mason Daugherty (mdrxy) merged 8 commits into
mainfrom
open-swe/auto-update-restart-after-upgrade
Aug 6, 2026
Merged

fix(code): always restart after a successful startup auto-update#5317
Mason Daugherty (mdrxy) merged 8 commits into
mainfrom
open-swe/auto-update-restart-after-upgrade

Conversation

@mdrxy

@mdrxy Mason Daugherty (mdrxy) commented Aug 4, 2026

Copy link
Copy Markdown
Member

After a startup auto-update installs, dcode now always restarts into the new version instead of continuing with a mix of old and new code — which could crash startup with an ImportError or show the old version on the splash screen. If the restart cannot happen, it prints the new version and asks you to relaunch rather than starting a broken session.


The install rewrites the site-packages the running process imports from, so modules already loaded stay on the old release while the TUI loads from the new one; a constant added in 0.1.52 made that combination crash.

  • The shadow detector compares resolved targets, so it accepts an alias that leads into the upgraded uv installation while still detecting genuine PATH shadows.
  • On Windows, uv shim selection now resolves PATHEXT candidates only inside uv’s bin directory. This recognizes .cmd aliases to uv’s .exe shim and prevents a project-local executable from becoming the auto-update restart target.
  • Failed os.execv prints a relaunch hint and exits 0; other post-install errors name the error, point at the debug log, and exit 1. Both record the update cooldown so a persistently failing re-exec cannot loop forever.
  • Failed installs remain fail-soft and launch the existing version.

The startup auto-update rewrites the site-packages the running process
imports from, so continuing in-process after a successful install leaves a
mixed-version interpreter: the TUI is loaded from the new code while
already-imported modules stay on the old release. The splash reads
`__version__` from `_version`, which `__init__.py` imports eagerly, so it
reported the pre-upgrade version — and a renamed constant made 0.1.51 to
0.1.52 fail outright with an `ImportError` at TUI startup.

Two paths led there. `detect_shadowed_dcode` reported a `dcode` symlink
that points *into* the upgraded tool venv as a conflict, and the caller
skipped the restart on that signal even though `_restart_current_process`
re-execs `sys.executable` and never consults PATH. And a failed re-exec
launched anyway instead of asking the user to relaunch.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
@github-actions github-actions Bot added dcode Related to `deepagents-code` fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization open-swe size: M 200-499 LOC labels Aug 4, 2026
@mdrxy
Mason Daugherty (mdrxy) marked this pull request as ready for review August 5, 2026 23:14

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Open SWE Review: No issues found

Open SWE reviewed this PR and found no potential bugs to report.

Open in WebView Open SWE trace

Record the auto-update cooldown on both paths that exit after a
successful install. Neither reaches a next generation, so the
`restarted_for` sentinel guard cannot cover them: a successful-but-no-op
upgrade paired with a persistently failing `os.execv` would otherwise
re-upgrade and re-exit on every launch, leaving the TUI unreachable. The
write is best-effort — the reason for exiting is often the same
unwritable state dir `mark_startup_auto_update_failed` trips over, and it
runs inside an `except`, so an unguarded raise would escape uncaught.

`_exit_after_unrestartable_update` now distinguishes its two callers. A
failed re-exec keeps the existing wording and exits 0. An error after the
install says so, names the error, points at the debug log, and exits 1 —
claiming a restart "could not run" sent users chasing an exec problem
that never happened, and the traceback only reached the in-memory buffer
that dies with the process, so exiting 0 left the failure invisible to
the user, the terminal, the log and the exit status at once.

Retarget the PATH-shadow warning at the next manual launch. It read "will
keep running the old version on relaunch" while being printed
immediately before a restart that loads the new version.

Raise the unresolvable-entry-point log to `warning`, matching the sibling
guard in `detect_shadowed_dcode`: the consequence is a user-visible
warning about a PATH conflict that may not exist.

Cover the sentinel assignment, the cooldown writes, the print ordering,
the late-window post-install failure and the unresolvable-target
fallback. Each new guard is mutation-verified.
@github-actions github-actions Bot added size: L 500-999 LOC and removed size: M 200-499 LOC labels Aug 5, 2026

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open SWE Review found 1 potential issue.

Open in WebView Open SWE trace

Comment thread libs/code/deepagents_code/update_check.py Outdated
@mdrxy
Mason Daugherty (mdrxy) merged commit 8cdee15 into main Aug 6, 2026
70 of 71 checks passed
@mdrxy
Mason Daugherty (mdrxy) deleted the open-swe/auto-update-restart-after-upgrade branch August 6, 2026 00:59
Mason Daugherty (mdrxy) pushed a commit that referenced this pull request Aug 6, 2026
> [!CAUTION]
> Merging this PR will automatically publish to **PyPI** and create a
**GitHub release**.

For the full release process, see
[`.github/RELEASING.md`](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md).

---

_Release notes preview: keep this section in sync with the package
`CHANGELOG.md`. Publish reads the merged CHANGELOG via `release.yml`,
not this PR description — keep them aligned anyway so the PR stays an
accurate historical record for reviewers and anyone returning later._

---


##
[0.1.53](deepagents-code==0.1.52...deepagents-code==0.1.53)
(2026-08-06)

### Features

- Added pricing coverage with Baseten built-in overrides and local
fallback overrides when `genai-prices` is missing data
([#5312](#5312),
[#5304](#5304)).
- Suggest compacting large resumed threads
([#5318](#5318)).
- Added terminal program trace metadata
([#5329](#5329)).

### Bug Fixes

- Preserved runtime offload archive routing
([#5328](#5328)).
- Always restart after a successful startup auto-update
([#5317](#5317)).
- Fixed leaked turn coroutines and SQLite handles
([#5218](#5218)).
- Keep MCP shutdown-race tracebacks from appearing in the terminal
([#5325](#5325)).
- Open the `/auto model` selector immediately while connecting
([#5341](#5341)).
- Route failures to `PostToolUseFailure`
([#5315](#5315)).
- Use dismissed copy for ask-user prompts
([#5331](#5331)).

_End release notes preview._

---

> [!NOTE]
> A **New Contributors** section is appended to the GitHub release notes
automatically at publish time (see [Release
Pipeline](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md#release-pipeline),
step 2).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: langchain-oss-automated-triage[bot] <248757908+langchain-oss-automated-triage[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dcode Related to `deepagents-code` fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization open-swe size: L 500-999 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant