mirror of
https://github.com/langchain-ai/deepagents.git
synced 2026-08-27 20:50:04 -04:00
f69804bfce
Update logs from self-updates (`uv tool install` / `pip install` output)
are ephemeral diagnostics, not application state. This moves
`UPDATE_LOG_DIR` from `~/.deepagents/.state/update_logs/` to
`<cache>/deepagents-code/update_logs/`, where `<cache>` is the
platform-native cache directory (`~/Library/Caches` on macOS,
`%LOCALAPPDATA%` on Windows, `$XDG_CACHE_HOME` or `~/.cache` elsewhere).
---
Before this change, every self-update wrote a timestamped log under
`~/.deepagents/.state/update_logs/`. That directory also holds OAuth
tokens, the sessions database, and input history — things users expect
to persist — while the update logs are transient `uv`/`pip` output that
the retention policy (`UPDATE_LOG_RETENTION_DAYS = 14`,
`UPDATE_LOG_MAX_FILES = 10`) already treats as disposable. A cache
directory is the more correct home.
- New `default_cache_dir()` resolver lives next to `DEFAULT_STATE_DIR`
in `model_config.py`: `~/Library/Caches` on macOS, `LOCALAPPDATA` on
Windows (falling back to `~/AppData/Local`), and `XDG_CACHE_HOME`
elsewhere when it is an absolute path (falling back to `~/.cache`).
Relative `XDG_CACHE_HOME` values are invalid per the XDG spec and are
ignored rather than resolved against the launch directory.
- Resulting `UPDATE_LOG_DIR` values:
- macOS: `~/Library/Caches/deepagents-code/update_logs/`
- Windows: `%LOCALAPPDATA%/deepagents-code/update_logs/`
- Linux with `XDG_CACHE_HOME` set:
`$XDG_CACHE_HOME/deepagents-code/update_logs/`
- Linux without it: `~/.cache/deepagents-code/update_logs/`
- The install script writes its own `install.log` under
`${XDG_CACHE_HOME:-~/.cache}` on every platform, so on macOS the two
logs intentionally land under different roots. Each side follows the
convention appropriate to it — a portable one-shot POSIX bootstrap (like
the rustup and uv installers) versus a long-lived app (like
`platformdirs`, and `uv`'s own cache at `~/Library/Caches/uv`). Both
docstrings now state this explicitly so the divergence isn't later
"fixed" by mistake.
- `create_update_log_path` / `cleanup_update_logs` signatures and the
`OSError`-tolerant debug-log-and-continue behavior in `perform_upgrade`
are unchanged — a non-writable cache dir must not break updates. The
timestamped `<stamp>-update.log` naming and retention policy are
untouched. Existing logs under the old
`~/.deepagents/.state/update_logs/` path are simply orphaned; nothing
reads them back.
- Nothing in the codebase reads update logs back (verified: write-only
across the package), so no reader migration is needed. No docs/help text
referenced the old path.
<details>
<summary>Test plan</summary>
- New `TestDefaultCacheDir` in `test_model_config.py`: XDG
set/unset/empty/relative, macOS with and without `XDG_CACHE_HOME`,
Windows with and without `LOCALAPPDATA`.
- `test_update_check.py` (388 tests, including the existing
`UPDATE_LOG_DIR` patch-based fixture) passes unchanged.
- `make -C libs/code lint` (ruff + ty + format) passes.
</details>