Skip to content

test(code): sandbox creation must not run on the blockbuster-guarded loop - #6017

Open
Jack Michaud (jack-michaud) wants to merge 2 commits into
langchain-ai:mainfrom
jack-michaud:test/sandbox-blockbuster-guard
Open

test(code): sandbox creation must not run on the blockbuster-guarded loop#6017
Jack Michaud (jack-michaud) wants to merge 2 commits into
langchain-ai:mainfrom
jack-michaud:test/sandbox-blockbuster-guard

Conversation

@jack-michaud

@jack-michaud Jack Michaud (jack-michaud) commented Sep 1, 2026

Copy link
Copy Markdown

Summary

Failing regression test for a server-startup bug: sandbox creation runs synchronously on the LangGraph dev event loop and is killed by the blockbuster blocking-I/O guard.

Failure: dcode --sandbox <provider> (reproduced on langsmith, agentcore, and previously reported for daytona in #5278) aborts before the readiness check passes:

Error: Server failed to start: RuntimeError: Server graph 'agent' failed readiness
check (status: 500): Sandbox creation failed for 'langsmith': Failed to list
snapshots: Blocking call to socket.socket.connect

Root cause: langgraph dev arms blockbuster (langgraph_runtime_inmem/queue.py -> _enable_blockbuster()), which raises BlockingError for patched blocking calls (socket connect, time.sleep, ...) on the asyncio loop. _make_graphs is async and calls the sync create_sandbox(...) / __enter__() directly on that loop (server_graph.py), which invokes the provider's sync get_or_create(...) — real blocking I/O. Every other blockbuster-hostile step in _make_graphs is already offloaded via asyncio.to_thread (with comments citing #5043); sandbox creation is the one that was missed. Note SandboxProvider.aget_or_create exists but has zero call sites.

What this test does

Mimics the server's guard with BlockBuster().activate() around a real _make_graphs run (modules stubbed per the existing test_interpreter_settings_apply_before_agent_construction pattern). The fake provider's sync get_or_create does a time.sleep — deterministic, and safe under pytest-socket's --disable-socket, unlike a real socket connect. On main, blockbuster raises BlockingError, _make_graphs hits its startup-error path, and the test fails with SystemExit(1). Once sandbox creation is offloaded off the event loop (e.g. asyncio.to_thread, matching the existing pattern in this file), the provider runs in a worker thread and the test passes. Verified locally: fails on main, passes with the to_thread fix applied.

Implementation notes

  • Uses explicit BlockBuster().activate()/deactivate() rather than blockbuster_ctx: blockbuster <1.5.27 lacks the try/finally in that helper, so the guard leaks into later tests when the body raises. The repo's uv.lock currently pins 1.5.26. The explicit form is version-stable and always restores.
  • Test lives in test_server_graph.py (the server-side seam where the fix belongs), reusing the existing _import_fresh_server_graph / _backend_with_offload helpers.

Out of scope

Deliberately a test-only PR (per the bug template guidance). The fix itself is straightforward — offload sandbox creation off the event loop — and will be tracked by the follow-up issue referencing this PR.

Fixes #6018

…loop

Reproduces the `dcode --sandbox <provider>` startup failure: the langgraph
dev server arms the blockbuster blocking-I/O guard on the event loop, and
_make_graphs calls the sync provider get_or_create directly on it, so the
readiness check dies with "Blocking call to socket.socket.connect".

Fails on main; passes once sandbox creation is offloaded off the event loop
(e.g. asyncio.to_thread).
@github-actions github-actions Bot added dcode Related to `deepagents-code` size: S 50-199 LOC tests Adding tests or correcting existing labels Sep 1, 2026
@langchain-oss-automated-triage langchain-oss-automated-triage Bot added new-contributor First-time contributor to this repo external User is not a member of the `langchain-ai` GitHub organization labels Sep 1, 2026
@github-actions github-actions Bot added the missing-issue-link PR missing a linked issue label Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

This PR has been automatically closed because you are not assigned to the linked issue.

Opening a PR is not an indication that it will be accepted. This process exists so maintainers can confirm a change is aligned with the project direction before you invest time implementing it. Please:

  1. Comment on the linked issue explaining the approach you would like to take and why — include enough detail for a maintainer to evaluate the design. Do not post a drive-by "please assign me" comment with no substance; those will be ignored.
  2. Wait for a maintainer to assign you. Once assigned, your PR will be reopened automatically.

Maintainers: reopen this PR or remove the missing-issue-link label to bypass this check.

@github-actions github-actions Bot closed this Sep 1, 2026
Matches the existing test_interpreter_settings_apply_before_agent_construction
pattern: with no_mcp=True and the stubbed tools module, _build_tools does no
blocking I/O, so it can run on the loop under the blockbuster guard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-issue-check Bypass linked-issue requirement on PR dcode Related to `deepagents-code` external User is not a member of the `langchain-ai` GitHub organization new-contributor First-time contributor to this repo size: S 50-199 LOC tests Adding tests or correcting existing

Projects

None yet

1 participant