#1648

fix(runtime): report expected PTY support while deferred startup is pending

OpenLaihu08wants to merge intofrom

Fixes #1623

What

With create_or_reuse(..., defer=True), DeferredSandboxSession.supports_pty() returned False until bring-up finished. The Agents SDK checks that method synchronously, in Shell.tools() and at the start of ExecCommandTool.run(). A session that was still pending therefore:

  • built its shell tools without write_stdin, and
  • ran the first exec_command in one-shot mode, so yield_time_ms acted as a hard timeout and no session ID came back.

This takes approach 1 from the issue: say up front what PTY support to expect.

  • register_backend(..., supports_pty=False) gains a flag next to supports_bind_mounts, plus a backend_supports_pty() helper. The built-in docker backend is declared PTY-capable (DockerSandboxSession.supports_pty() returns True).
  • DeferredSandboxSession takes supports_pty and reports it while pending. Once resolved it still delegates to the real session.
  • create_or_reuse passes backend_supports_pty(backend_name) into the deferred session.

Custom backends default to False, so they behave as before unless they opt in. That avoids assuming every backend supports PTYs. The defer=False path is unchanged.

Tests

New tests in tests/test_deferred_session.py:

  • a pending session on a PTY backend reports supports_pty() and Shell.tools() includes write_stdin
  • a pending session on a backend without the flag stays on exec_command only
  • the issue's reproduction as a test: the SDK's real UnixLocalSandboxClient behind a gated deferred bring-up. The first ExecCommandTool.run() returns Process running with session ID and no timeout.

Before the change, the first and third tests fail. After the change, uv run pytest tests/test_deferred_session.py passes (13 tests). The full suite shows the same 19 failures as main (they come from existing _start_child_runner(skills=...) and settings fakes), and the three new tests are the only difference. ruff format --check ., ruff check ., mypy strix/ and bandit -r strix/ -c pyproject.toml are clean.

AI assistance: this change was prepared with Claude (AI coding assistants) and tested as described above.

Activity

2
greptile-apps[bot]3d ago

Confidence Score: 5/5

[Low impact] The PR appears safe to merge; no actionable issues were found.

Summary

Pending sandbox sessions now report the selected backend’s declared PTY support.

  • Pending sandboxes now report whether their backend supports PTY.

No actionable issues were found. Tests were not run during this review.

Reviews (1) · Last reviewed commit: "fix(runtime): report expected PTY suppor..." · Reviewed by Greptile