Skip to content
TheChatArchiveThe Chat Archive
DeepSeekdeepseek/deepseek-v4-pro· deepseekHugging 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. DeepSeek Assistant

    Let me start by understanding the repository structure and the issue better.

    The issue is about GLOB_TIMEOUT in deepagents/middleware/filesystem.py. The problem is that when a glob times out, the code blocks until the glob finishes because ThreadPoolExecutor.__exit__ calls shutdown(wait=True), which waits for the worker thread to finish. This means the timeout doesn't actually bound wall-clock time.

    Let me first explore the repository structure and then look at the specific file.

  3. DeepSeek Assistant

    Let me look at the specific file mentioned in the issue.

  4. DeepSeek Assistant

    Let me look at the file.

  5. DeepSeek Assistant

    Let me try to open it using the open command properly.

  6. DeepSeek Assistant

    Let me find the relevant sections - GLOB_TIMEOUT and sync_glob.

  7. DeepSeek Assistant

    Let me look at the sync_glob function in detail

  8. DeepSeek Assistant

    Now I understand the issue clearly. Let me look at lines 1270-1280 more

  9. DeepSeek Assistant

    Now I have a clear understanding of the issue. Let me first create a reproduction script to confirm the behavior, then fix it

  10. DeepSeek Assistant

    I see - even with shutdown(wait=False), the __exit__ method calls shutdown(wait=True) again, which still joins threads. I need to restructure the code to avoid the with block's __exit__ from blocking. Let me verify this quickly

  11. DeepSeek Assistant

    The fix works correctly. Now let me implement it in the actual file. The fix is to replace the with block with a manual try/finally that calls `executor.shutdown(wait=False

  12. DeepSeek Assistant

    Let me use the proper edit syntax with the --file option

  13. DeepSeek Assistant

    I see there are leftover lines from the old code (lines 1286-1287). Let me check the full context around the edit

  14. DeepSeek Assistant

    I see the problem - old lines 1281-1282 (status="error", and )) were not replaced and are now duplicate remnants. Let me fix this by removing lines 1286-

  15. DeepSeek Assistant

    Let me verify the code now

  16. DeepSeek Assistant

    The code looks correct. Now let me create a reproduction script using the actual codebase to verify the fix

  17. DeepSeek Assistant

    Let me install the dependencies first

  18. DeepSeek Assistant

    Let me try installing the package in development mode.

  19. DeepSeek Assistant

    Now let me run the test script again

  20. DeepSeek Assistant

    The fix works. The glob now returns after ~0.5s (the timeout) instead of blocking for the full 3s. Let me now run the existing tests for the filesystem middleware to make sure nothing is broken

  21. DeepSeek Assistant

    Let me run the most directly relevant tests for the filesystem

  22. DeepSeek Assistant

    Let me also run the integration tests and the broader middleware tests

  23. DeepSeek Assistant

    Let me check if these tests were already failing before my change by looking at one of the errors

  24. DeepSeek Assistant

    The integration tests fail due to missing API keys (Anthropic auth), not related to my change. Let me run the unit

  25. DeepSeek Assistant

    All glob-related tests pass, including test_glob_timeout_returns_error_message. Let me run the full middleware unit

  26. DeepSeek Assistant

    All 111 middleware tests pass. Let me also run the backend unit tests and related tests

  27. DeepSeek Assistant

    Let me check if these failures are pre-existing (unrelated to my change

  28. DeepSeek Assistant

    These tests were already failing before my change. Let me restore my fix

  29. DeepSeek Assistant

    Let me look at the test_glob_timeout_returns_error_message test to understand what it expects

  30. DeepSeek Assistant

    Let me also verify the final state of my

  31. DeepSeek Assistant

    Let me run one more test to verify the fix with the exact scenario from the issue description

  32. DeepSeek Assistant

    Let me run the full middleware test suite one final time to confirm everything passes

  33. DeepSeek Assistant

    Everything looks good. Let me now go through the checklist:

    • If an error was reported in the issue description, I have successfully reproduced it. I confirmed that the with ThreadPoolExecutor block's __exit__ calls shutdown(wait=True), which blocks until the worker thread finishes even after a TimeoutError.

    • If an error was reported in the issue description, I have confirmed that my fix resolves the error. My reproduction script confirmed the fix returns after ~0.5s (the timeout) instead of the full 3s glob duration.

    • I have thought about edge cases and made sure my fix handles them as well. The try/finally with executor.shutdown(wait=False) handles: timeout case (returns immediately), success case (thread already done, shutdown returns immediately), executor.submit failure (finally still runs), and non-TimeoutError exceptions (propagate, finally still runs).

    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. All 111 middleware unit tests pass, including the 7 glob-related tests (test_glob_timeout_returns_error_message, test_glob_search_*, etc.). The integration test failures are pre-existing and due to missing API keys.

    The fix is minimal and focused: replacing the with statement context manager with a manual try/finally block that calls executor.shutdown(wait=False) to prevent the worker thread from blocking on exit after a timeout.

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