Skip to content
TheChatArchiveThe Chat Archive
QwenQwen/Qwen3.6-27B· alibabaHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION GLOBTIMEOUT does not bound wall-clock time — tool blocks until the…

  1. User

    ISSUE DESCRIPTION

    GLOB_TIMEOUT does not bound wall-clock time — tool blocks until the runaway glob finishes

    Submission 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
    

    Error Message and Stack Trace (if applicable)

    returned after 3.01s: 'Error: glob timed out after 0.5s. Try a more specific pattern or a narrower path.'
    

    Description

    • The synchronous glob tool created by FilesystemMiddleware enforces GLOB_TIMEOUT (20s) by running the backend glob on a worker thread: future.result(timeout=GLOB_TIMEOUT) inside a with concurrent.futures.ThreadPoolExecutor(max_workers=1) block (deepagents/middleware/filesystem.py, sync_glob).
    • I expect a glob that exceeds the timeout to make the tool return the "timed out" error after ~GLOB_TIMEOUT seconds.
    • Instead, the return inside the with block triggers ThreadPoolExecutor.__exit__ -> shutdown(wait=True), which joins the worker thread still running the glob (threads can't be cancelled). The tool builds the "timed out after 20s" message but then blocks until the glob actually finishes — however long that takes. The timeout changes the message the model sees, not the latency, so a glob over a huge tree or slow network mount hangs the agent loop unboundedly.
    • Secondary issue with the same code: constructing a fresh ThreadPoolExecutor (and spawning a thread) per glob call adds ~5x dispatch overhead per call vs. reusing a shared executor.
    • The async variant (async_glob) is not affected — asyncio.wait_for cancels and returns immediately.

    Environment / System Info

    OS: macOS 14 (Darwin 23.6.0, arm64) Python: 3.13.5 deepagents: 0.6.8 (also reproducible on main @ 676abecf)

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /deepagents, current file: none) bash-$

  2. Qwen Assistant

    Let me analyze the issue:

    1. The bug is in deepagents/middleware/filesystem.py in the sync_glob function
    2. The problem is that after a timeout occurs with future.result(timeout=GLOB_TIMEOUT), the with concurrent.futures.ThreadPoolExecutor(...) block triggers __exit__ which calls shutdown(wait=True), blocking until the worker thread finishes
    3. The fix should prevent the shutdown from waiting for the timed-out task

    Let me start by exploring the repository structure and finding the relevant file.

  3. Qwen Assistant

    Let me find the specific file mentioned in the issue.

  4. Qwen Assistant

    The user is pointing out that my tool call format is incorrect. I need to use the proper bash_terminal format. Let me look at the filesystem.py file using cat instead.

  5. Qwen Assistant

    Let me search for the sync_glob function specifically:

  6. Qwen Assistant

    Now let me see the full sync_glob function to understand the issue:

  7. Qwen Assistant

    Now I understand the issue clearly. The problem is in the sync_glob function:

    1. When a TimeoutError is raised, the code returns inside the with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor: context manager block.
    2. The return statement triggers ThreadPoolExecutor.__exit__() which calls shutdown(wait=True) by default.
    3. This causes the thread to block until the worker thread (still running the slow glob) actually finishes.

    The fix is to call executor.shutdown(wait=False) before returning in the timeout case, or to restructure the code so the shutdown doesn't wait. Let me also check if there are existing tests I need to be aware of:

  8. Qwen Assistant

    Now let me first create a script to reproduce the issue:

  9. Qwen Assistant

    I need to install the dependencies first. Let me check how the project is set up:

  10. Qwen Assistant

    I need to see how the project is set up and install its dependencies

  11. Qwen Assistant

    Let me check the project setup and install dependencies properly.

  12. Qwen Assistant

    Let me check if the dependencies are already installed or if I need to install them.

  13. Qwen Assistant

    Now let me run the reproduction script to confirm the bug:

  14. Qwen Assistant

    I've confirmed the bug. The tool returns the timeout message but blocks for the full 3 seconds instead of returning after 0.5 seconds, because ThreadPoolExecutor.__exit__() calls shutdown(wait=True) which blocks until the worker thread finishes.

    Now let me look at the exact lines to edit and apply the fix:

  15. Qwen Assistant

    Now I understand the issue. The problem is that when TimeoutError is caught inside the with block and we return, the context manager's __exit__ method calls shutdown(wait=True) which blocks until the worker thread finishes.

    The fix is to restructure the code so that on timeout, we call executor.shutdown(wait=False) before returning. Let me apply the fix:

  16. Qwen Assistant

    The fix is to replace the with statement with a try/finally block and call executor.shutdown(wait=False) in the finally block. This way, when we return from inside the try block on timeout, the finally block runs shutdown(wait=False) which doesn't block, allowing the function to return immediately.

  17. Qwen Assistant

    The user seems to have encountered an error with my tool call. Let me check what happened and continue with the fix. I need to use the edit command to fix the sync_glob function.

    The issue is that when a timeout occurs in the with block, returning triggers ThreadPoolExecutor.__exit__() which calls shutdown(wait=True), blocking until the worker thread finishes.

    The fix is to replace the with statement with a try/finally block and call executor.shutdown(wait=False) in the finally block, so the function returns immediately on timeout without waiting for the worker thread to finish.

    Let me apply the fix using the edit command.

  18. Qwen Assistant

    I need to use the bash_terminal to invoke the edit command properly. Let me try a different approach using sed to make the replacement.

  19. Qwen Assistant

    Let me create a Python script to do the replacement since the edit command seems to have issues:

  20. Qwen Assistant

    Now let me verify the fix was applied correctly:

  21. Qwen Assistant

    The fix looks correct. Now let me run the reproduction script to verify the fix works:

  22. Qwen Assistant

    Excellent! The fix works! The tool now returns after ~0.5s (the timeout) instead of waiting until the full 3s glob operation completes.

    Now let me run the existing tests to make sure I haven't broken anything:

  23. Qwen Assistant

    Let me run the relevant tests related to the filesystem middleware to make sure the fix doesn't break anything.

  24. Qwen Assistant

    The 3 test failures are unrelated to my change - they're all failing because langchain-openai package is missing (which is a test dependency issue). The 337 passing tests include filesystem-related tests. Let me specifically run the tests most relevant to the glob timeout fix to confirm nothing is broken:

  25. Qwen Assistant

    All relevant filesystem middleware tests pass. Now let me run the reproduction script one more time to confirm the fix, and also test edge cases:

  26. Qwen Assistant

    Now let me also test an edge case - make sure the normal (non-timeout) path still works correctly:

  27. Qwen Assistant

    <arg_key>command</arg_key> <arg_value>cat > /tmp/test_normal.py << 'PYEOF' import sys sys.path.insert(0, "/deepagents/libs/deepagents")

    from deepagents.backends.protocol import GlobResult from deepagents.middleware.filesystem import FilesystemMiddleware from unittest.mock import MagicMock

    class FakeRuntime: tool_call_id = "demo" state = {"files": {}} store = None context = None stream_writer = None config = {}

    Test normal (non-timeout) glob operation with a mock backend

    backend = MagicMock() backend.glob.return_value = GlobResult( matches=[ {"path": "/test.py", "size": 100}, {"path": "/test2.py", "size": 200}, ], error=None )

    middleware = FilesystemMiddleware(backend=backend) glob_tool = next(t for t in middleware.tools if t.name == "glob")

    Test normal glob

    msg = glob_tool.invoke({"pattern": "*.py", "runtime": FakeRuntime()}) print(f"Normal glob result: {msg.content!r}") print(f"Status: {msg.status}")

    Verify it found the files

    assert "test.py" in msg.content or "test2.py" in msg.content, f"Expected to find .py files, got: {msg.content}" assert msg.status == "success", f"Expected success status, got: {msg.status}"

    print("Normal glob test PASSED!")

    Test that the executor is properly shut down (wait=False should be fine)

    by calling glob multiple times

    for i in range(5): msg = glob_tool.invoke({"pattern": "*.py", "runtime": FakeRuntime()}) assert msg.status == "success", f"Call {i+1} failed: {msg.content}"

    print("Multiple glob calls test PASSED!") PYEOF python3 /tmp/test_normal.py </tool_call>

  28. Qwen Assistant

    I need to use the proper bash_terminal function call format.

  29. Qwen Assistant

    Let me fix the mock setup:

  30. Qwen Assistant

    The normal glob path works correctly. Let me run one final comprehensive test to confirm everything:

  31. Qwen Assistant

    All tests pass. Let me verify the exact changes I made to the file:

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.