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 better. The issue is about
GLOB_TIMEOUTindeepagents/middleware/filesystem.py. The problem is thatsync_globusesThreadPoolExecutorwithfuture.result(timeout=GLOB_TIMEOUT), but when the timeout expires, thewithblock triggersshutdown(wait=True), which waits for the worker thread to finish. This means the tool blocks until the glob finishes, defeating the purpose of the timeout.Let me explore the repository structure first.
Assistant
Let me look at the relevant file:
libs/deepagents/middleware/filesystem.py(or maybedeepagents/middleware/filesystem.py).Assistant
Let's open and read the file.
Assistant
The open command seems to be different. Let me try using the special open command.
Assistant
The file was truncated. Let me read more of it to find the
sync_globandasync_globfunctionsAssistant
Now let me look at the sync_glob function in detail.
Assistant
Let me also see the async variant for reference
Assistant
Let me first create a script to reproduce the issue:
Assistant
Good, I've confirmed the issue. Now let me verify the fix:
Assistant
Now let me apply the fix. First, let me open the file:
Assistant
Now let me apply the fix. I need to replace lines 1271-1282:
Assistant
Good. Now let me verify the fix works with the original repro scenario. But first, let me check if there are existing tests I should
Assistant
Let me run the existing tests to make sure nothing is broken
Assistant
Let me check for dependencies and install
Assistant
Let me try installing the deepagents package.
Assistant
Now let me run the tests again.
Assistant
Good, tests pass. Let me also run the integration tests and backend tests:
Assistant
The integration test fails because it needs API credentials (Anthropic). That's unrelated to my change. Let me run the backend tests:
Assistant
Let me see the full test
Assistant
58 passed, 5 skipped. All good. Let me also run the async backend tests:
Assistant
Let me check what the async test failure is:
Assistant
The async test failure is pre-existing (missing
pytest-asyncioplugin) and unrelated to my change.Now let me create a proper reproduction script using the actual code to verify the fix:
Assistant
The fix works. Now let me also test that the non-timeout (successful glob) path still works correctly:
Assistant
The successful path error is from the StateBackend config requirements (not related to our fix). Let me verify the file looks correct:
Assistant
Let me run all the unit tests one final time:
Assistant
The only failure is a pre-existing async test infrastructure issue (missing
pytest-asyncio). All other 84 tests pass. Let me see the exact diff of my changes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.