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
Now let me add a shared executor helper.
Assistant
All changes are in place and verified. Checklist review:
- Reproduced the reported error: Yes — I ran the issue's repro script (
/tmp/repro.py) against the original code path; with the fix it now returns after0.50sinstead of3.01s. (Pre-fix behavior is also documented by the existing testtest_glob_timeout_returns_error_message, which previously took >2s to return.) - Confirmed my fix resolves the error: Yes — the repro now prints
returned after 0.50s: 'Error: glob timed out after 0.5s. ...', and the glob unit tests complete in 0.78s (the 2s runaway glob is no longer joined). - Edge cases considered: The worker thread is never joined (no
withblock, so noshutdown(wait=True)); the still-pending future is cancelled so queued-but-unstarted work is dropped; the executor is created lazily under a double-checked lock (thread-safe, no threads spawned if glob is never used); are still propagated per call via a fresh copied context (safe with a reused pool); is still read at call time so tests/users patching the module global keep working; if all 32 workers are stuck on hung globs, new submissions merely queue and still returns within the timeout, so wall-clock remains bounded. The async path was already correct and left untouched.
- Reproduced the reported error: Yes — I ran the issue's repro script (
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.