Skip to content

feat(code): carry TERM_PROGRAM into the resume hint - #5548

Merged
Mason Daugherty (mdrxy) merged 7 commits into
mainfrom
mdrxy/code/resume-hint-launch-context
Aug 17, 2026
Merged

feat(code): carry TERM_PROGRAM into the resume hint#5548
Mason Daugherty (mdrxy) merged 7 commits into
mainfrom
mdrxy/code/resume-hint-launch-context

Conversation

@mdrxy

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

Copy link
Copy Markdown
Member

The teardown resume hint prints a pasteable command for getting back into a thread. A shell alias that exports TERM_PROGRAM cannot be recovered from argv[0], so the printed command drops it — along with anything keyed off it, such as conditional theme selection. Pasting the hint gets you the thread back, but not the environment it was launched in.

The variable now rides along as an env prefix when the launch environment supplied it (an inline TERM_PROGRAM=x dcode, a terminal's own export, or a shell alias):

Resume this thread with:
TERM_PROGRAM=WezTerm dcode -r a1b2c3

The value is snapshotted at process entry, so a TERM_PROGRAM that appears only later — from a project or global .env file — is not echoed back. The value is shell-quoted, so a terminal name containing spaces or shell metacharacters cannot change what the pasted line does. A value containing control characters is omitted rather than stripped: stripping would both write raw escape sequences into teardown output and name a terminal the environment never actually contained.

The prefix uses POSIX syntax, so it is withheld on native Windows even when the variable is set — VS Code and WezTerm set TERM_PROGRAM on every platform, and cmd.exe/PowerShell cannot parse a VAR=value command prefix. POSIX markers (SHELL, MSYSTEM, WSL_DISTRO_NAME) restore the prefix under git-bash/MSYS/WSL.

@github-actions github-actions Bot added dcode Related to `deepagents-code` feature New feature/enhancement or request for one internal User is a member of the `langchain-ai` GitHub organization size: S 50-199 LOC labels Aug 17, 2026
@mdrxy
Mason Daugherty (mdrxy) marked this pull request as ready for review August 17, 2026 19:49

@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 2 potential issues.

Open in WebView Open SWE trace

Comment thread libs/code/deepagents_code/main.py Outdated
Comment thread libs/code/deepagents_code/main.py Outdated
The teardown resume hint prints a pasteable command, but a shell alias
that exports `TERM_PROGRAM` cannot be recovered from `argv[0]`, so the
printed command dropped it along with anything keyed off it (such as
conditional theme selection).

Carry the variable as an env prefix when it is set:

    TERM_PROGRAM=WezTerm dcode -r a1b2c3

The value is shell-quoted. A value containing control characters is
omitted rather than stripped, so the hint never writes raw escape
sequences into teardown output nor names a terminal the environment did
not contain. POSIX prefix syntax is used unconditionally: native
`cmd.exe`/PowerShell leave `TERM_PROGRAM` unset, so no prefix is emitted
there.
@mdrxy
Mason Daugherty (mdrxy) force-pushed the mdrxy/code/resume-hint-launch-context branch from dd4eda5 to cfcc131 Compare August 17, 2026 20:36
@mdrxy Mason Daugherty (mdrxy) changed the title feat(code): preserve launch context in resume hints feat(code): carry TERM_PROGRAM into the resume hint Aug 17, 2026
@mdrxy Mason Daugherty (mdrxy) changed the title feat(code): carry TERM_PROGRAM into the resume hint feat(code): carry TERM_PROGRAM into the resume hint Aug 17, 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/main.py Outdated
VS Code sets TERM_PROGRAM=vscode unconditionally on every platform and
WezTerm does the same, so under win32 the variable's presence does not
imply a POSIX shell. Emitting TERM_PROGRAM=... dcode -r ... there leaves
native cmd.exe/PowerShell trying to execute the assignment as a command,
breaking the advertised resume hint.

Withhold the prefix on win32 unless a POSIX marker (SHELL, MSYSTEM,
WSL_DISTRO_NAME) indicates git-bash/MSYS/WSL, where the prefix syntax is
valid. Existing POSIX tests pin sys.platform so they stay hermetic on
Windows dev machines.
The resume hint read live TERM_PROGRAM at teardown, so a value supplied
after launch (a project or global .env file) would leak into the printed
command even though the user never launched with it.

Snapshot the variable at cli_main entry into an internal
DEEPAGENTS_CODE_LAUNCH_TERM_PROGRAM sentinel and read that instead. The
app never sets TERM_PROGRAM itself, so a set sentinel always marks a
launch-supplied value (inline prefix, terminal export, or shell alias);
the update re-exec inherits it unchanged, which matches the relaunch
running the command the user typed.
@github-actions github-actions Bot added size: M 200-499 LOC and removed size: S 50-199 LOC labels Aug 17, 2026
… duration test

- Add `_env_vars.LAUNCH_TERM_PROGRAM` to `NON_OPTION_ENV_VARS` — it is an
  internal launch-time snapshot, never user-configured.
- Fake a 4.9s elapsed instead of exactly 5s in
  `test_execute_shows_took_after_success` so wall-clock drift between the
  subtraction and `set_success` cannot round the rendered duration up to
  `5.1s`.
… teardown

`_refresh_cache_display` queried `#cache-display` unguarded. When a
usage event fires while `/reload` has the `StatusBar` mid-teardown
(surfacing at `app._shutdown()`), the query raised `NoMatches` inside
the worker and Textual re-raised it as `WorkerFailed`, flaking
`test_queues_prompt_for_entire_reload`. Guard the query + repaint with
`suppress(NoMatches)`, matching the ~50 sibling status-bar lookups and
the already-guarded `_render_tokens`.
@mdrxy
Mason Daugherty (mdrxy) merged commit 3cdc821 into main Aug 17, 2026
57 checks passed
@mdrxy
Mason Daugherty (mdrxy) deleted the mdrxy/code/resume-hint-launch-context branch August 17, 2026 22:55
Mason Daugherty (mdrxy) pushed a commit that referenced this pull request Aug 18, 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.57](deepagents-code==0.1.56...deepagents-code==0.1.57)
(2026-08-18)

### Features

- Added warnings before expensive cold-cache turns and trust
user-declared endpoints for cold-cache policies
([#5439](#5439),
[#5462](#5462)).
- Made the chat input resizable by dragging its top border
([#5524](#5524)).
- Added a `multi_select` question type to `ask_user`
([#5097](#5097)).
- Added support for ACP approval modes
([#5394](#5394)).
- Added `DeepSeek-V4-Pro-0813` to the model picker
([#5512](#5512)).
- Show conversation turns alongside message counts
([#5571](#5571)).
- Include `TERM_PROGRAM` in the resume hint
([#5548](#5548)).

### Bug Fixes

- Report total context after `/offload`
([#5488](#5488)).
- Fixed transcript and thread restoration issues, including hydration
lag, scrolling resumed threads to the bottom, and hiding empty
previous-thread hints
([#5479](#5479),
[#5543](#5543),
[#5552](#5552)).
- Fixed Auto-mode approval handling by binding “yes” to the paired
`ask_user` question and avoiding duplicate Auto denial notices
([#5038](#5038),
[#5501](#5501)).
- Improved reload behavior by keeping the chat input responsive during
`/reload`, reporting MCP server changes, and avoiding plugin reload
prompt flashes or startup hints
([#5529](#5529),
[#5504](#5504),
[#5500](#5500),
[#5502](#5502)).
- Improved dependency update UI by preserving editable fields and hiding
dependency details after updates
([#5521](#5521),
[#5519](#5519)).
- Fixed chat UI polish issues, including detached spacer mount anchors,
the unfocused input cursor, and relative timestamp toggle display
([#5516](#5516),
[#5258](#5258),
[#5503](#5503)).
- Refresh the splash version after updates
([#5520](#5520)).

_End release notes preview._

---

> [!NOTE]
> A **community contributors** list and a **Special thanks** section
(crediting the users who filed the issues this release's PRs closed) are
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 3).

---------

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>
Mason Daugherty (mdrxy) added a commit that referenced this pull request Aug 18, 2026
Related #5548

`TERM_PROGRAM` is now omitted from resume hints by default, with an
explicit config opt-in that defaults on in experimental or debug mode.

---

Ambient terminal exports cannot be distinguished from launch-specific
values, so `features.resume_term_program` /
`DEEPAGENTS_CODE_RESUME_TERM_PROGRAM` controls propagation. An explicit
true or false value overrides the mode-dependent default; existing
quoting, launch snapshotting, and native-Windows safeguards remain
intact.

<details><summary>Test plan</summary>

- `make -C libs/code format`
- `make -C libs/code lint`
- Focused resume/config tests: 38 passed
- Full-file attempts also exposed an unrelated cold-import timeout and
an existing Rich line-wrap assertion outside this change.

</details>

Made by [Open
SWE](https://openswe.vercel.app/agents/cb92eab5-7bc0-14b4-a9d2-78b0ee980b70)

---------

Co-authored-by: open-swe[bot] <open-swe@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` feature New feature/enhancement or request for one internal User is a member of the `langchain-ai` GitHub organization size: M 200-499 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant