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_commandin one-shot mode, soyield_time_msacted 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 tosupports_bind_mounts, plus abackend_supports_pty()helper. The built-indockerbackend is declared PTY-capable (DockerSandboxSession.supports_pty()returnsTrue).DeferredSandboxSessiontakessupports_ptyand reports it while pending. Once resolved it still delegates to the real session.create_or_reusepassesbackend_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()andShell.tools()includeswrite_stdin - a pending session on a backend without the flag stays on
exec_commandonly - the issue's reproduction as a test: the SDK's real
UnixLocalSandboxClientbehind a gated deferred bring-up. The firstExecCommandTool.run()returnsProcess running with session IDand 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.
[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.
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