ISSUE DESCRIPTION GLOBTIMEOUT does not bound wall-clock time — tool blocks until the…
- User
ISSUE DESCRIPTION
GLOB_TIMEOUTdoes not bound wall-clock time — tool blocks until the runaway glob finishesSubmission checklist
- This is a bug, not a usage question.
- I added a clear and descriptive title.
- I searched existing issues and didn't find this.
- I can reproduce this with the latest released version.
- I included a minimal reproducible example and steps to reproduce.
Area (Required)
- deepagents (SDK)
- cli
- code
- talon
- acp
- evals
- harbor
- daytona
- modal
- quickjs
- runloop
- langsmith-sandbox
- Other / not sure / general
Related Issues / PRs
No response
Reproduction Steps / Example Code (Python)
import time from unittest.mock import patch from deepagents.backends import StateBackend from deepagents.middleware import filesystem as fs_mw from deepagents.middleware.filesystem import FilesystemMiddleware class FakeRuntime: tool_call_id = "demo" state = {"files": {}} store = None context = None stream_writer = None config = {} backend = StateBackend() real_glob = backend.glob middleware = FilesystemMiddleware(backend=backend) glob_tool = next(t for t in middleware.tools if t.name == "glob") def slow_glob(*args, **kwargs): time.sleep(3) # a glob that takes 3s (stand-in for a huge tree / slow mount) return real_glob("*.none") with ( patch.object(fs_mw, "GLOB_TIMEOUT", 0.5), # 20s in production; shortened for the repro patch.object(backend, "glob", side_effect=slow_glob), ): start = time.monotonic() msg = glob_tool.invoke({"pattern": "**/*", "runtime": FakeRuntime()}) print(f"returned after {time.monotonic() - start:.2f}s: {msg.content!r}") # Expected: returns after ~0.5s (the timeout) # Actual: returns after ~3.0s -- the full duration of the "timed out" glob - Assistant
I’ll first inspect the repository structure and the filesystem middleware implementation, then locate relevant tests and reproduce the reported blocking behavior before choosing an executor-lifecycle fix.
- Assistant
The implementation is in the expected package and existing timeout tests already exist. I’ll inspect the tool construction, middleware lifecycle, and those tests to determine whether a module-shared executor or instance-owned executor best matches project conventions and avoids per-call thread creation without introducing process-exit hangs.
- Assistant
The bug is confirmed structurally: returning from the
exceptstill enters the context manager’s blocking shutdown. The existing sync test checks only the message, not elapsed time, so it takes the full two seconds. I’ll now inspect package Python constraints and middleware initialization, then run a focused timing reproduction to establish the baseline. - Assistant
A reusable module-level pool is the appropriate fix: it removes the blocking context-manager shutdown and addresses per-call executor overhead. On timeout, I’ll also cancel the future so a task that was still queued (because other slow globs occupied workers) does not execute later; already-running Python threads cannot be force-cancelled, but the caller will return at the deadline. The pool’s default worker count avoids one timed-out glob serializing all later calls.
- Assistant
The previous command changed the persistent working directory into
libs/deepagents, so the edit path was incorrect and no files were changed. I’ll apply the same targeted edit using paths relative to the current directory. - Assistant
The source now returns immediately on timeout and retains context-variable propagation. Before testing, I’ll inspect the exact diff and run Ruff; then I’ll install/sync the project’s declared test dependencies (the environment currently lacks LangChain) so the reproduction and relevant unit tests can execute.
- Assistant
The diff is minimal and correct. The initial Ruff invocation suppressed setup diagnostics, so I’ll explicitly sync the test dependency group and then run the focused sync timeout test plus the issue’s elapsed-time reproduction.
- Assistant
The focused test now completes in 0.51s rather than waiting for its 2s worker, demonstrating the behavioral change. I’ll run a standalone reproduction matching the report and wait briefly afterward to ensure the background completion causes no exception, then execute all filesystem middleware sync/async unit tests and static type checking for the modified package.
- Assistant
The exact reproduction returns after 0.50s, all 139 sync/async middleware tests pass, and type checking passes. I’ll now inspect repository status and the final diff for unintended lock/environment changes, then consider concurrency edge cases (queued cancellation, simultaneous calls, and successful calls) with a small temporary in-memory stress script before final submission.
- Assistant
The concurrency check confirmed four simultaneous callers each returned near the 80ms timeout (0.087s total). Its final “success” probe used
StateBackendoutside LangGraph after restoring the mock, which correctly raises an unrelated runtime-context error; the executor itself accepted and executed the task, so this does not indicate a fix issue. I’ll use a backend from the test helpers or a simple protocol-compatible mock for a clean recovery probe, run formatting, and run the complete deepagents unit-test suite for broader regression coverage.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.