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
Let me start by understanding the repository structure and the issue. The issue is about
GLOB_TIMEOUTindeepagents/middleware/filesystem.py. The problem is that when a glob times out, theThreadPoolExecutor.__exit__blocks, waiting for the worker thread to finish, defeating the purpose of the timeout.Let me explore the repository structure first, then look at the relevant file.
Assistant
I need to make one command at a time. Let me explore the repository.
Assistant
Let me look at the relevant file.
Assistant
Let me find the correct path.
Assistant
Found it. Let me look at the filesystem.py middleware file.
Assistant
The output was truncated. Let me search for the
sync_globfunction and the glob tool definitionAssistant
Now let me look at the
sync_globfunction in detailAssistant
Now I understand the issue. Let me also check if
grephas the same problem with a similar patternAssistant
Good - only
globhas this pattern. Let me first reproduce the issue with a scriptAssistant
Let me find the correct import
Assistant
Let me run the script using the project's venv
Assistant
I've confirmed the issue. Now let me apply the fix. The problem is that
ThreadPoolExecutor.__exit__callsshutdown(wait=True), which blocks until the worker thread finishes. The fix is to manually manage the executor and callshutdown(wait=False)Assistant
Working directory is
/deepagents/libs/deepagents. Let me try without the libs prefix.Assistant
Let me navigate to the relevant section around line 1272
Assistant
Now I'll apply the fix. The core issue is that the
withcontext manager callsshutdown(wait=True)on exit, which blocks. We need to instead use atry/finallywithshutdown(wait=False)Assistant
The edit looks correct. Let me now verify by running the repro script again
Assistant
The fix works. Let me also test that the normal (non-timeout) case still works
Assistant
Let me check existing tests for the glob tool to see how they test it
Assistant
Let me look at the directory structure.
Assistant
Let me find the deepagents tests
Assistant
Let me look for filesystem middleware tests
Assistant
Let me look at the integration test for reference
Assistant
Let me run existing filesystem-related tests to ensure nothing is
Assistant
Let me find how tests are run
Assistant
Let me check the venv structure
Assistant
Let me check what's available
Assistant
Let me check how to install dependencies
Assistant
Let me try using uv to
Assistant
Now let me run the filesystem middleware
Assistant
Let me run without the timeout
Assistant
That test failure is about missing Anthropic API key, not related to my change. Let me run the unit tests instead
Assistant
Let me run the backend filesystem tests
Assistant
All 80 backend tests pass. Let me also run the broader
Assistant
The 3 failures are in an unrelated test file (
test_subagent_middleware_init.py). Let me verify they're pre-existing:Assistant
These failures are pre-existing (ImportError in langchain, unrelated to my change). Let me verify the final state of my changes
Assistant
Let me run the repro one final time to confirm
Assistant
Let me verify the git diff shows only the expected change
Assistant
The fix is clean and minimal. Let me now go through the checklist:
Checklist:
-
If an error was reported in the issue description, I have successfully reproduced it. ✅ Yes, I reproduced the issue using the code from the issue description. Before the fix, the script returned after ~3.0s (full glob duration). After the fix, it returns after ~0.5s (the timeout).
-
If an error was reported in the issue description, I have confirmed that my fix resolves the error. ✅ Yes, the repro script now returns within the timeout.
-
I have thought about edge cases and made sure my fix handles them as well. ✅ I considered:
- Non-timeout (success) case: Works fine —
executor.shutdown(wait=False)is a no-op when the future already completed. - Other exceptions from
future.result(): Thefinallyblock still executes, ensuring the executor is cleaned up.
- Non-timeout (success) case: Works fine —
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.