[PR #1154] feat(sdk): add per-command timeout override to execute() #1175

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

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagents/pull/1154
Author: @mdrxy
Created: 2/6/2026
Status: 🔄 Open

Base: mainHead: mdrxy/execute-timeout


📝 Commits (3)

  • e98607b feat(sdk): add per-command timeout override to execute()
  • 5b6cc15 Merge remote-tracking branch 'origin/main' into mdrxy/execute-timeout
  • 41c7d28 add 1hr max timeout

📊 Changes

21 files changed (+521 additions, -55 deletions)

View changed files

📝 libs/cli/deepagents_cli/backends.py (+15 -3)
📝 libs/cli/deepagents_cli/integrations/daytona.py (+10 -1)
📝 libs/cli/deepagents_cli/integrations/langsmith.py (+6 -2)
📝 libs/cli/deepagents_cli/integrations/modal.py (+10 -1)
📝 libs/cli/deepagents_cli/integrations/runloop.py (+7 -1)
📝 libs/cli/tests/unit_tests/test_backend_timeout.py (+1 -1)
📝 libs/deepagents/deepagents/backends/__init__.py (+2 -1)
📝 libs/deepagents/deepagents/backends/composite.py (+21 -12)
📝 libs/deepagents/deepagents/backends/local_shell.py (+44 -7)
📝 libs/deepagents/deepagents/backends/protocol.py (+13 -1)
📝 libs/deepagents/deepagents/backends/sandbox.py (+5 -0)
📝 libs/deepagents/deepagents/middleware/filesystem.py (+39 -2)
📝 libs/deepagents/tests/integration_tests/test_filesystem_middleware.py (+3 -3)
📝 libs/deepagents/tests/unit_tests/backends/test_composite_backend_async.py (+2 -2)
📝 libs/deepagents/tests/unit_tests/backends/test_sandbox_backend.py (+1 -1)
📝 libs/deepagents/tests/unit_tests/test_local_sandbox_operations.py (+7 -3)
libs/deepagents/tests/unit_tests/test_local_shell.py (+102 -0)
📝 libs/deepagents/tests/unit_tests/test_middleware.py (+199 -4)
📝 libs/deepagents/tests/unit_tests/test_middleware_async.py (+6 -6)
📝 libs/harbor/deepagents_harbor/backend.py (+13 -2)

...and 1 more files

📄 Description

Prior to #1107, the CLI used a standalone ShellMiddleware (in libs/cli/deepagents_cli/shell.py) that exposed a shell tool with a per-command timeout: int | None = None parameter. The LLM could pass timeout=300 on any individual command to override the default 120s.

#1107 replaced ShellMiddleware with the SDK's LocalShellBackend, which unified shell execution under the execute tool and made it available to subagents. However, LocalShellBackend.execute() and SandboxBackendProtocol.execute() only accept command: str -- the per-command timeout parameter was list. The timeout is fixed at init time (self._timeout) and cannot be overridden per call ...so the LLM lost the ability to extend the timeout for long-running commands.

This PR restores that capability at the SDK level:

  • Add keyword-only timeout: int | None = None parameter to execute() across SandboxBackendProtocol and all implementations
  • Update timeout error message to guide LLM agents toward using the timeout parameter
  • Catch ValueError in middleware alongside NotImplementedError to prevent unhandled exceptions from crashing the agent loop

(negligible) Breaking changes

LocalShellBackend.__init__ timeout type narrowed from float to int.


🔄 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/1154 **Author:** [@mdrxy](https://github.com/mdrxy) **Created:** 2/6/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `mdrxy/execute-timeout` --- ### 📝 Commits (3) - [`e98607b`](https://github.com/langchain-ai/deepagents/commit/e98607be605204ff5f7fc4976fb1dc9a7ab9cfd3) feat(sdk): add per-command timeout override to execute() - [`5b6cc15`](https://github.com/langchain-ai/deepagents/commit/5b6cc1576896acf82995377226ca2d62b4f6cf62) Merge remote-tracking branch 'origin/main' into mdrxy/execute-timeout - [`41c7d28`](https://github.com/langchain-ai/deepagents/commit/41c7d28f16920eaac165b33f71bc17b6f3602bbe) add 1hr max timeout ### 📊 Changes **21 files changed** (+521 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `libs/cli/deepagents_cli/backends.py` (+15 -3) 📝 `libs/cli/deepagents_cli/integrations/daytona.py` (+10 -1) 📝 `libs/cli/deepagents_cli/integrations/langsmith.py` (+6 -2) 📝 `libs/cli/deepagents_cli/integrations/modal.py` (+10 -1) 📝 `libs/cli/deepagents_cli/integrations/runloop.py` (+7 -1) 📝 `libs/cli/tests/unit_tests/test_backend_timeout.py` (+1 -1) 📝 `libs/deepagents/deepagents/backends/__init__.py` (+2 -1) 📝 `libs/deepagents/deepagents/backends/composite.py` (+21 -12) 📝 `libs/deepagents/deepagents/backends/local_shell.py` (+44 -7) 📝 `libs/deepagents/deepagents/backends/protocol.py` (+13 -1) 📝 `libs/deepagents/deepagents/backends/sandbox.py` (+5 -0) 📝 `libs/deepagents/deepagents/middleware/filesystem.py` (+39 -2) 📝 `libs/deepagents/tests/integration_tests/test_filesystem_middleware.py` (+3 -3) 📝 `libs/deepagents/tests/unit_tests/backends/test_composite_backend_async.py` (+2 -2) 📝 `libs/deepagents/tests/unit_tests/backends/test_sandbox_backend.py` (+1 -1) 📝 `libs/deepagents/tests/unit_tests/test_local_sandbox_operations.py` (+7 -3) ➕ `libs/deepagents/tests/unit_tests/test_local_shell.py` (+102 -0) 📝 `libs/deepagents/tests/unit_tests/test_middleware.py` (+199 -4) 📝 `libs/deepagents/tests/unit_tests/test_middleware_async.py` (+6 -6) 📝 `libs/harbor/deepagents_harbor/backend.py` (+13 -2) _...and 1 more files_ </details> ### 📄 Description Prior to #1107, the CLI used a standalone `ShellMiddleware` (in `libs/cli/deepagents_cli/shell.py`) that exposed a `shell` tool with a per-command `timeout: int | None = None` parameter. The LLM could pass `timeout=300` on any individual command to override the default 120s. #1107 replaced `ShellMiddleware` with the SDK's `LocalShellBackend`, which unified shell execution under the `execute` tool and made it available to subagents. However, `LocalShellBackend.execute()` and `SandboxBackendProtocol.execute()` only accept `command: str` -- the per-command timeout parameter was list. The timeout is fixed at init time (`self._timeout`) and cannot be overridden per call ...so the LLM lost the ability to extend the timeout for long-running commands. This PR restores that capability at the SDK level: - Add keyword-only `timeout: int | None = None` parameter to `execute()` across `SandboxBackendProtocol` and all implementations - Update timeout error message to guide LLM agents toward using the timeout parameter - Catch `ValueError` in middleware alongside `NotImplementedError` to prevent unhandled exceptions from crashing the agent loop ## (negligible) Breaking changes `LocalShellBackend.__init__` timeout type narrowed from `float` to `int`. --- <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:20 -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#1175