[PR #1267] fix(cli): esc should terminate active execution #1263

Open
opened 2026-02-16 09:18:34 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagents/pull/1267
Author: @OiPunk
Created: 2/11/2026
Status: 🔄 Open

Base: mainHead: codex/deepagents-1157-escape-execute


📝 Commits (3)

  • 441275b fix(cli): let escape stop active execute command
  • 81ccfcc fix(cli): interrupt bash command process groups on escape
  • 57f2825 style(cli): sort imports in app test module

📊 Changes

2 files changed (+221 additions, -25 deletions)

View changed files

📝 libs/cli/deepagents_cli/app.py (+84 -23)
📝 libs/cli/tests/unit_tests/test_app.py (+137 -2)

📄 Description

Summary

Fixes #1157.

When a user runs a direct shell command in CLI mode (for example !sleep 60), pressing Esc previously did not stop the active command because the process handle was not tracked.

This change makes Esc and Ctrl+C terminate an active shell execution immediately.

Changes

  • Replace blocking subprocess.run(...) shell execution in _handle_bash_command with an async subprocess (asyncio.create_subprocess_shell) so the running process can be interrupted.
  • Track the active shell process in app state (_bash_process) and add _interrupt_bash_process().
  • Call _interrupt_bash_process() from both action_interrupt (Esc) and action_quit_or_interrupt (Ctrl+C).
  • Keep existing timeout behavior (60s) and explicitly kill timed-out commands.
  • Add regression tests for:
    • Esc interrupting an active bash command
    • Ctrl+C interrupting an active bash command
    • Timeout path killing process and showing timeout error

Testing

  • uv run --all-groups ruff check deepagents_cli/app.py tests/unit_tests/test_app.py
  • uv run --all-groups ty check deepagents_cli/app.py tests/unit_tests/test_app.py
  • uv run --group test pytest -q tests/unit_tests/test_app.py

AI disclosure

AI assistance was used to draft and refine the patch and tests; all changes were manually reviewed and validated locally before opening this PR.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/deepagents/pull/1267 **Author:** [@OiPunk](https://github.com/OiPunk) **Created:** 2/11/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `codex/deepagents-1157-escape-execute` --- ### 📝 Commits (3) - [`441275b`](https://github.com/langchain-ai/deepagents/commit/441275bfa7a1769318abfc77e945397839775186) fix(cli): let escape stop active execute command - [`81ccfcc`](https://github.com/langchain-ai/deepagents/commit/81ccfcc93d0f4c1d1599f9a5c85bba48d036b93b) fix(cli): interrupt bash command process groups on escape - [`57f2825`](https://github.com/langchain-ai/deepagents/commit/57f2825ad9d431800d187fd18704bc5abac0ee54) style(cli): sort imports in app test module ### 📊 Changes **2 files changed** (+221 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `libs/cli/deepagents_cli/app.py` (+84 -23) 📝 `libs/cli/tests/unit_tests/test_app.py` (+137 -2) </details> ### 📄 Description ## Summary Fixes #1157. When a user runs a direct shell command in CLI mode (for example `!sleep 60`), pressing `Esc` previously did not stop the active command because the process handle was not tracked. This change makes `Esc` and `Ctrl+C` terminate an active shell execution immediately. ## Changes - Replace blocking `subprocess.run(...)` shell execution in `_handle_bash_command` with an async subprocess (`asyncio.create_subprocess_shell`) so the running process can be interrupted. - Track the active shell process in app state (`_bash_process`) and add `_interrupt_bash_process()`. - Call `_interrupt_bash_process()` from both `action_interrupt` (`Esc`) and `action_quit_or_interrupt` (`Ctrl+C`). - Keep existing timeout behavior (60s) and explicitly kill timed-out commands. - Add regression tests for: - `Esc` interrupting an active bash command - `Ctrl+C` interrupting an active bash command - Timeout path killing process and showing timeout error ## Testing - `uv run --all-groups ruff check deepagents_cli/app.py tests/unit_tests/test_app.py` - `uv run --all-groups ty check deepagents_cli/app.py tests/unit_tests/test_app.py` - `uv run --group test pytest -q tests/unit_tests/test_app.py` ## AI disclosure AI assistance was used to draft and refine the patch and tests; all changes were manually reviewed and validated locally before opening this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 09:18:34 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagents#1263