Skip to content

fix(sdk): prevent local shell commands from stealing TUI input - #5873

Merged
Mason Daugherty (mdrxy) merged 2 commits into
mainfrom
mdrxy/sdk/detach-local-shell-session
Aug 27, 2026
Merged

fix(sdk): prevent local shell commands from stealing TUI input#5873
Mason Daugherty (mdrxy) merged 2 commits into
mainfrom
mdrxy/sdk/detach-local-shell-session

Conversation

@mdrxy

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

Copy link
Copy Markdown
Member

Fixes #4329
Related: #5907

Local shell commands can no longer access the parent process's controlling terminal on POSIX systems, preventing credential prompts from stealing keyboard input from the dcode TUI.


The dcode agent routes execute through LocalShellBackend. Although that backend gives subprocesses stdin=subprocess.DEVNULL, programs such as Git and SSH can bypass standard input by opening /dev/tty directly. When they prompt for credentials, they then compete with Textual for the same terminal input, disrupting or effectively breaking the chat input until the process exits.

Start each local shell command in a new POSIX session so it no longer has access to dcode's controlling terminal. Interactive commands now fail cleanly through captured output rather than intercepting keystrokes. This also aligns the agent execute path with dcode's existing local ! shell behavior.

Windows behavior is unchanged because start_new_session is enabled only on non-Windows platforms. Focused coverage runs the backend beneath a real controlling pseudo-terminal, proves the parent can open /dev/tty, and verifies the detached command cannot.

Made by Open SWE

Co-authored-by: Sumit Kumar 187615421+sumit1kr@users.noreply.github.com

@github-actions github-actions Bot added p0 Critical priority / immediate response deepagents Related to the `deepagents` SDK / agent harness fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization size: XS < 50 LOC labels Aug 27, 2026
@mdrxy
Mason Daugherty (mdrxy) marked this pull request as ready for review August 27, 2026 04:24

@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

@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/deepagents/deepagents/backends/local_shell.py Outdated
@mdrxy
Mason Daugherty (mdrxy) force-pushed the mdrxy/sdk/detach-local-shell-session branch from 19b4e7a to 3581692 Compare August 27, 2026 15:01
@github-actions github-actions Bot added size: L 500-999 LOC and removed size: M 200-499 LOC labels Aug 27, 2026
@mdrxy
Mason Daugherty (mdrxy) force-pushed the mdrxy/sdk/detach-local-shell-session branch from 9e315b9 to b542259 Compare August 27, 2026 17:19
@mdrxy
Mason Daugherty (mdrxy) force-pushed the mdrxy/sdk/detach-local-shell-session branch from 9f953e0 to 35cb8ea Compare August 27, 2026 18:33
@github-actions github-actions Bot added size: S 50-199 LOC and removed size: L 500-999 LOC labels Aug 27, 2026
Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
@mdrxy
Mason Daugherty (mdrxy) force-pushed the mdrxy/sdk/detach-local-shell-session branch from 35cb8ea to d6aa48d Compare August 27, 2026 20:36
@mdrxy
Mason Daugherty (mdrxy) merged commit c94a090 into main Aug 27, 2026
87 checks passed
@mdrxy
Mason Daugherty (mdrxy) deleted the mdrxy/sdk/detach-local-shell-session branch August 27, 2026 20:55
Mason Daugherty (mdrxy) added a commit that referenced this pull request Aug 27, 2026
Related: #4329

Git commands run through dcode's `execute` tool now fail with an
explicit terminal-prompts-disabled message when credentials are
unavailable.

---

Stacked on #5873.

Starting local shell subprocesses in a new session prevents them from
stealing the Textual TUI's keyboard input, but Git can then surface a
cryptic `/dev/tty` error when it tries to prompt for credentials. Set
`GIT_TERMINAL_PROMPT=0` in dcode's curated local shell environment as
defense in depth so Git skips the prompt attempt and reports the cause
directly.

This is intentionally scoped to dcode's agent `execute` environment. It
does not alter the general SDK backend, remote sandboxes, or the user's
parent environment, and dcode overrides an inherited value to keep
non-interactive execution reliable.

Made by [Open
SWE](https://openswe.vercel.app/agents/000f0c29-ded9-5a80-abaa-daa77e57f972)

---------

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
Mason Daugherty (mdrxy) pushed a commit that referenced this pull request Aug 28, 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.7.10](deepagents==0.7.9...deepagents==0.7.10)
(2026-08-28)

### Bug Fixes

- Prevent local shell commands from stealing TUI input
([#5873](#5873))
- Surface sandbox glob failures instead of reporting no matches
([#5566](#5566))

_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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepagents Related to the `deepagents` SDK / agent harness fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization p0 Critical priority / immediate response size: S 50-199 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dcode execute subprocesses can steal TUI input via /dev/tty prompts

1 participant