Skip to content

feat(sdk): add per-command timeout override to execute()#1154

Merged
Mason Daugherty (mdrxy) merged 9 commits intomainfrom
mdrxy/execute-timeout
Feb 19, 2026
Merged

feat(sdk): add per-command timeout override to execute()#1154
Mason Daugherty (mdrxy) merged 9 commits intomainfrom
mdrxy/execute-timeout

Conversation

@mdrxy
Copy link
Copy Markdown
Member

@mdrxy Mason Daugherty (mdrxy) commented Feb 6, 2026

Restore per-command timeout control that was lost when #1107 replaced the CLI's ShellMiddleware with LocalShellBackend.

The SDK's execute() previously only accepted command: str with the timeout fixed at init time, so the LLM couldn't extend it for long-running commands. This adds timeout as a keyword-only parameter across the entire SandboxBackendProtocol hierarchy and removes the CLI's CLIShellBackend wrapper that is no longer needed.

Changes

  • Add keyword-only timeout: int | None = None to SandboxBackendProtocol.execute() / aexecute() and propagate through BaseSandbox, LocalShellBackend, CompositeBackend, and all partner implementations
  • Expose DEFAULT_EXECUTE_TIMEOUT = 120 as a named constant
  • Add max_timeout parameter to FilesystemMiddleware.__init__ (default 3600s) that caps per-command overrides from the LLM

(negligible) Breaking changes

LocalShellBackend.__init__ timeout type narrowed from float to int.

@github-actions github-actions Bot added internal User is a member of the `langchain-ai` GitHub organization cli Related to `deepagents-cli` and removed internal User is a member of the `langchain-ai` GitHub organization labels Feb 6, 2026
@github-actions github-actions Bot added harbor Benchmarks deepagents Related to the `deepagents` SDK / agent harness labels Feb 6, 2026
@github-actions github-actions Bot added the feature New feature/enhancement or request for one label Feb 6, 2026
@github-actions github-actions Bot added feature New feature/enhancement or request for one and removed feature New feature/enhancement or request for one labels Feb 6, 2026
Mason Daugherty (mdrxy) added a commit that referenced this pull request Feb 6, 2026
This functionality was lost in #1107

> [!WARNING]
> This is a temporary CLI-side implementation until #1154 lands the
feature natively in the SDK. Once merged, these subclasses and the
monkey-patch can be removed in favor of the SDK's built-in support.

---

Adds per-command timeout support to the CLI's execute tool so the LLM
can override the default 120s timeout for long-running commands.
self,
command: str,
*,
timeout: int | None = None,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it entirely LLM controlled... which a DOS attack? If we're introducing this, is there a way to introduce a max timeout?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add a max_timeout init parameter (defaulting to e.g. 3600) that caps the per-command value. If the LLM exceeds it, the middleware returns an explicit error (same pattern as the <= 0 validation already in this PR):

if timeout is not None and timeout > self._max_timeout:
    return f"Error: timeout {timeout}s exceeds maximum allowed
({self._max_timeout}s)."

@github-actions github-actions Bot added the acp Agent Client Protocol label Feb 15, 2026
# Conflicts:
#	libs/cli/deepagents_cli/ui.py
#	libs/deepagents/deepagents/backends/__init__.py
Comment thread libs/deepagents/deepagents/middleware/filesystem.py Outdated
@eyurtsev
Copy link
Copy Markdown
Collaborator

We're good to merge this one

Would need to merge against main, run make update-snapshots and potentially improve any prompts that need improving

Can help get this over the finish line on Friday

@mdrxy
Copy link
Copy Markdown
Member Author

run make update-snapshots

had no effect Eugene Yurtsev (@eyurtsev)

@github-actions github-actions Bot added feature New feature/enhancement or request for one and removed feature New feature/enhancement or request for one labels Feb 19, 2026
@mdrxy Mason Daugherty (mdrxy) merged commit 49277d4 into main Feb 19, 2026
37 checks passed
@mdrxy Mason Daugherty (mdrxy) deleted the mdrxy/execute-timeout branch February 19, 2026 06:24
Mason Daugherty (mdrxy) added a commit that referenced this pull request Feb 20, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.0.24](deepagents-cli==0.0.23...deepagents-cli==0.0.24)
(2026-02-20)


### Features

* **cli:** add single-click link opening for rich-style hyperlinks
([#1433](#1433))
([ef1fd31](ef1fd31))
* **cli:** display model name and context window size using `/tokens`
([#1441](#1441))
([ff7ef0f](ff7ef0f))
* **cli:** refresh local context after summarization events
([#1384](#1384))
([dcb9583](dcb9583))
* **cli:** windowed thread hydration and configurable thread limit
([#1435](#1435))
([9da8d0b](9da8d0b))
* **sdk:** add per-command `timeout` override to `execute()`
([#1154](#1154))
([49277d4](49277d4))


### Bug Fixes

* **cli:** escape `Rich` markup in shell command display
([#1413](#1413))
([c330290](c330290))
* **cli:** load root-level `AGENTS.md` into agent system prompt
([#1445](#1445))
([047fa2c](047fa2c))
* **cli:** prevent crash when quitting with queued messages
([#1421](#1421))
([a3c9ae6](a3c9ae6))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Mason Daugherty <github@mdrxy.com>
Mason Daugherty (mdrxy) added a commit that referenced this pull request Feb 20, 2026
Backwards-compatible guard for the per-command `timeout` parameter added
in #1154. Partner backend packages (`langchain-daytona`,
`langchain-modal`, `langchain-runloop`) previously had no version
constraint on the SDK, so upgrading the SDK without upgrading a partner
package would `TypeError` on every `execute()` call, as the SDK
unconditionally passed `timeout=` to backends whose signatures didn't
accept it.
Harrison Chase (hwchase17) pushed a commit that referenced this pull request Feb 24, 2026
Restore per-command timeout control that was lost when #1107 replaced
the CLI's `ShellMiddleware` with `LocalShellBackend`.

The SDK's `execute()` previously only accepted `command: str` with the
timeout fixed at init time, so the LLM couldn't extend it for
long-running commands. This adds `timeout` as a keyword-only parameter
across the entire `SandboxBackendProtocol` hierarchy and removes the
CLI's `CLIShellBackend` wrapper that is no longer needed.

## Changes

- Add keyword-only `timeout: int | None = None` to
`SandboxBackendProtocol.execute()` / `aexecute()` and propagate through
`BaseSandbox`, `LocalShellBackend`, `CompositeBackend`, and all partner
implementations
- Expose `DEFAULT_EXECUTE_TIMEOUT = 120` as a named constant
- Add `max_timeout` parameter to `FilesystemMiddleware.__init__`
(default 3600s) that caps per-command overrides from the LLM

## (negligible) Breaking changes

`LocalShellBackend.__init__` timeout type narrowed from `float` to
`int`.
Harrison Chase (hwchase17) pushed a commit that referenced this pull request Feb 24, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.0.24](deepagents-cli==0.0.23...deepagents-cli==0.0.24)
(2026-02-20)


### Features

* **cli:** add single-click link opening for rich-style hyperlinks
([#1433](#1433))
([ef1fd31](ef1fd31))
* **cli:** display model name and context window size using `/tokens`
([#1441](#1441))
([ff7ef0f](ff7ef0f))
* **cli:** refresh local context after summarization events
([#1384](#1384))
([dcb9583](dcb9583))
* **cli:** windowed thread hydration and configurable thread limit
([#1435](#1435))
([9da8d0b](9da8d0b))
* **sdk:** add per-command `timeout` override to `execute()`
([#1154](#1154))
([49277d4](49277d4))


### Bug Fixes

* **cli:** escape `Rich` markup in shell command display
([#1413](#1413))
([c330290](c330290))
* **cli:** load root-level `AGENTS.md` into agent system prompt
([#1445](#1445))
([047fa2c](047fa2c))
* **cli:** prevent crash when quitting with queued messages
([#1421](#1421))
([a3c9ae6](a3c9ae6))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Mason Daugherty <github@mdrxy.com>
Harrison Chase (hwchase17) pushed a commit that referenced this pull request Feb 24, 2026
Backwards-compatible guard for the per-command `timeout` parameter added
in #1154. Partner backend packages (`langchain-daytona`,
`langchain-modal`, `langchain-runloop`) previously had no version
constraint on the SDK, so upgrading the SDK without upgrading a partner
package would `TypeError` on every `execute()` call, as the SDK
unconditionally passed `timeout=` to backends whose signatures didn't
accept it.
james8814 pushed a commit to james8814/deepagents that referenced this pull request Mar 1, 2026
…in-ai#1154)

Restore per-command timeout control that was lost when langchain-ai#1107 replaced
the CLI's `ShellMiddleware` with `LocalShellBackend`.

The SDK's `execute()` previously only accepted `command: str` with the
timeout fixed at init time, so the LLM couldn't extend it for
long-running commands. This adds `timeout` as a keyword-only parameter
across the entire `SandboxBackendProtocol` hierarchy and removes the
CLI's `CLIShellBackend` wrapper that is no longer needed.

## Changes

- Add keyword-only `timeout: int | None = None` to
`SandboxBackendProtocol.execute()` / `aexecute()` and propagate through
`BaseSandbox`, `LocalShellBackend`, `CompositeBackend`, and all partner
implementations
- Expose `DEFAULT_EXECUTE_TIMEOUT = 120` as a named constant
- Add `max_timeout` parameter to `FilesystemMiddleware.__init__`
(default 3600s) that caps per-command overrides from the LLM

## (negligible) Breaking changes

`LocalShellBackend.__init__` timeout type narrowed from `float` to
`int`.
james8814 pushed a commit to james8814/deepagents that referenced this pull request Mar 1, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.0.24](langchain-ai/deepagents@deepagents-cli==0.0.23...deepagents-cli==0.0.24)
(2026-02-20)


### Features

* **cli:** add single-click link opening for rich-style hyperlinks
([langchain-ai#1433](langchain-ai#1433))
([ef1fd31](langchain-ai@ef1fd31))
* **cli:** display model name and context window size using `/tokens`
([langchain-ai#1441](langchain-ai#1441))
([ff7ef0f](langchain-ai@ff7ef0f))
* **cli:** refresh local context after summarization events
([langchain-ai#1384](langchain-ai#1384))
([dcb9583](langchain-ai@dcb9583))
* **cli:** windowed thread hydration and configurable thread limit
([langchain-ai#1435](langchain-ai#1435))
([9da8d0b](langchain-ai@9da8d0b))
* **sdk:** add per-command `timeout` override to `execute()`
([langchain-ai#1154](langchain-ai#1154))
([49277d4](langchain-ai@49277d4))


### Bug Fixes

* **cli:** escape `Rich` markup in shell command display
([langchain-ai#1413](langchain-ai#1413))
([c330290](langchain-ai@c330290))
* **cli:** load root-level `AGENTS.md` into agent system prompt
([langchain-ai#1445](langchain-ai#1445))
([047fa2c](langchain-ai@047fa2c))
* **cli:** prevent crash when quitting with queued messages
([langchain-ai#1421](langchain-ai#1421))
([a3c9ae6](langchain-ai@a3c9ae6))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Mason Daugherty <github@mdrxy.com>
james8814 pushed a commit to james8814/deepagents that referenced this pull request Mar 1, 2026
…ain-ai#1461)

Backwards-compatible guard for the per-command `timeout` parameter added
in langchain-ai#1154. Partner backend packages (`langchain-daytona`,
`langchain-modal`, `langchain-runloop`) previously had no version
constraint on the SDK, so upgrading the SDK without upgrading a partner
package would `TypeError` on every `execute()` call, as the SDK
unconditionally passed `timeout=` to backends whose signatures didn't
accept it.
Eugene Yurtsev (eyurtsev) added a commit that referenced this pull request Mar 6, 2026
…oop 0.0.3) (#1689)

Patch releases for all partner sandbox packages to pick up changes since
PR #1154 (per-command timeout override) and #1461 (timeout guard +
deepagents>=0.4.3 floor).

- langchain-daytona: 0.0.2 -> 0.0.3
- langchain-modal: 0.0.1 -> 0.0.2
- langchain-runloop: 0.0.2 -> 0.0.3

Created with [Deep Agents
CLI](https://docs.langchain.com/oss/python/deepagents/cli/overview).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

acp Agent Client Protocol cli Related to `deepagents-cli` deepagents Related to the `deepagents` SDK / agent harness feature New feature/enhancement or request for one harbor Benchmarks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants