Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging 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)

    Interface

    No new interfaces are introduced.

    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. Claude Assistant

    Now let's add a module-level lazily created shared executor and update sync_glob to not block on shutdown.

  3. Claude Assistant

    That looks fine. Let me try using edit command with line numbers instead.

  4. Claude Assistant

    Now let's edit line 233 to insert the executor code after GLOB_TIMEOUT.

  5. Claude Assistant

    Need to fix the missing blank line before LINE_NUMBER_WIDTH, and add import threading at top.

  6. Claude Assistant

    Now add import threading to the top imports.

  7. Claude Assistant

    Duplicate import concurrent.futures. Fix line 6.

  8. Claude Assistant

    Now let's remove the unused __import__("threading") reference I no longer need (already replaced with threading.Lock()). Now update the sync_glob function to use the shared executor instead of with ThreadPoolExecutor....

  9. Claude Assistant

    Duplicate line at 1295-1296 and stray ) at 1314. Let me fix both.

  10. Claude Assistant

    Now that looks correct. Let's check for syntax errors by compiling the file and running the reproduction script.

  11. Claude Assistant

    Now let's remove the leftover unused _GLOB_EXECUTOR_LOCK note - actually it's used. Let's double check the whole new block for correctness.

  12. Claude Assistant

    Good. Now let's write and run the reproduction script.

  13. Claude Assistant

    The fix works — the tool now returns after ~0.5s instead of blocking for 3s. Let's run the existing test suite for filesystem middleware to make sure nothing broke.

  14. Claude Assistant

    There's an existing test for glob timeout. Let's run it along with the whole test_middleware.py.

  15. Claude Assistant

    This test doesn't check timing, so it should pass fine, but let's run it to confirm and run the whole test suite for regressions.

  16. Claude Assistant

    All glob tests pass. Now run the full test suite for test_middleware.py and other filesystem-related tests.

  17. Claude Assistant

    Same 183 failures on the baseline (pre-existing, likely missing pytest-asyncio config) — confirms these are unrelated to my change. Let's restore my fix.

  18. Claude Assistant

    Good, my changes are restored. The 183 pre-existing failures are unrelated (missing async test plugin config), same count with and without my fix. Now let's verify sync-only tests pass and double check no regressions specific to filesystem middleware.

  19. Claude Assistant

    Confirmed these 4 failures are pre-existing and unrelated to my change. Now let's run ruff/lint check on the modified file.

  20. Claude Assistant

    There's a convention to add # noqa: PLW0603 for this pattern. Let's add it.

  21. Claude Assistant

    Now let's re-run the reproduction script and the glob tests once more to be sure everything still works after the noqa edit.

  22. Claude Assistant

    Everything works. Let's also test that consecutive glob calls reuse the same executor (verify overhead concern addressed) and cleanup temp file.

  23. Claude Assistant

    Let's view the final diff for review.

  24. Claude Assistant

    The diff looks clean and correctly addresses both issues from the report (blocking on timeout, and per-call executor overhead). Let's do a final full test run of the sync-only middleware and permissions tests to be extra sure.

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