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 start by exploring the repository structure and locating the glob timeout implementation described in the issue.
- Assistant
Let me look at the filesystem middleware and the sync_glob function.
- Assistant
Let me read the relevant section of the file around sync_glob.
- Assistant
Let me check for similar timeout patterns and imports in this file.
- Assistant
Let me check if there's already a shared executor somewhere in the codebase, and look at git history / any related cleanups.
- Assistant
Let me look at related tests and the class structure around the glob tool.
- Assistant
There's already a test for timeout - let me read it.
- Assistant
I understand the bug: the executor context manager calls
shutdown(wait=True)and blocks until the worker finishes. I'll fix it with a shared executor that doesn't wait on timeout. - Assistant
I'll implement the shared executor and update
sync_globso timeouts return without waiting on the worker. - Assistant
Let me try navigating to those lines first, then apply the edit.
- Assistant
Now let me try the replace again.
- Assistant
Next I'll add the module-level shared executor near
GLOB_TIMEOUT. - Assistant
I'll add the shared executor and update
sync_glob. - Assistant
Now I'll update
sync_globto use the shared executor. - Assistant
Now I'll replace the with-block with shared executor usage.
- Assistant
Next I'll run the reproduction script from the issue to verify the timeout behaves correctly.
- Assistant
I need to use the project's virtualenv.
- Assistant
The fix works. Next I'll run the related unit tests.
- Assistant
Need to install test deps or find how to run tests.
- Assistant
I'll use uv run to run the tests.
- Assistant
I should fix the import order—
asyncioshould come beforeatexitalphabetically. - Assistant
Need to goto line 1 first.
- Assistant
Let me fix import order - asyncio before atexit.
- Assistant
I'll also verify successive timeouts and that normal globs still work quickly afterward.
- Assistant
Let me also check if ruff is happy and maybe run a broader lint.
- Assistant
I'll add a done-callback so abandoned timed-out futures don't log unretrieved exceptions.
- Assistant
I'll add the done callback. It's a small improvement. The lambda f: f.exception() might trigger ruff B023 or similar - let me keep it clean.
- Assistant
I'll re-run the timeout tests and reproduction.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.