Skip to content

[Bug]: Settling a thread doesn't release the Android device session, blocking other threads from using it #32511

Open

Description

@Casual76

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/desktop

Steps to reproduce

  1. Open thread A with device access enabled and an Android device connected via adb (device preview visible)
  2. Ask the agent to do some work that uses the device
  3. Let the agent finish without explicitly stopping the device session
  4. Settle thread A
  5. Open thread B and try to use the same device

Expected behavior

Settling a thread releases its device session, so other threads can use the device right away

Actual behavior

The device stays held by the settled thread. Thread B can't use it until I find thread A, reopen it, and ask the agent to stop using the device. Since agents often finish without stopping the session, this happens a lot whenever I work across multiple threads

Impact

Major degradation or frequent failure

Version or commit

0.1.8-nightly.20261107.4314

Environment

Windows 11, codex gpt 6.1 sol

Logs or stack traces

Screenshots, recordings, or supporting files

No response

Workaround

Find the settled thread that holds the device and ask its agent to stop using the device

Activity

  1. added
    bug
    needs-triage
    on Nov 7, 2026
  2. diflores commented on Nov 17, 2026

    @diflores

    Reproduced on macOS with iOS Simulators, which may unblock #32524 (its pipeline stopped because it could only try Android over adb).

    Version: T3 Code Desktop 0.1.10-nightly.20261116.4787, local device host, agent-device daemon 0.21.36, macOS 26.6 arm64. Settle cleanup on main still has no device release (ThreadSettlementService.ts), so this is current.

    Timeline (UTC, 2026-11-17), one Claude thread:

    • 19:08–19:16: device_open on three simulators: iPhone 17 iOS 26.3 (session A), iPhone 17 iOS 26.2 (session B), and a third one (session C).
    • 19:10:41 and 19:17:54: device_close (with shutdown: true) released session A once (then the agent reopened it) and session C. agent-device logged Closed t3-… for each, so device_close itself works.
    • 19:19:50: the thread settled. It never called device_close for A (after the reopen) or B, and agent-device logged no close for either at settle.
    • 19:37–19:51: other threads failed open with DEVICE_IN_USE: Device is already in use by session "t3-…". The claims were held for about 20–30 minutes, until a manual agent-device close --session t3-… from another thread.

    Side note: one manual close failed with INVALID_ARGS because it reused the other simulator's --udid (Session "t3-…" is already bound to apple device …, but close selected --udid=…). The agent-device CLI then printed only its hint, so the close looked like it had succeeded. That's caller error, but the output is easy to misread.

    Evidence: agent-device session events.ndjson and request logs, plus the thread's provider event log. Excerpts are available on request.


    Investigated by Claude Opus 5.5 (claude-opus-5-5) via Claude Code, running inside T3 Code triage.

  3. semyonfox commented on Nov 24, 2026

    @semyonfox
    Contributor

    Same problem here on Linux, with a cost the original report doesn't mention: the emulator stays booted after the thread is done and nothing ever shuts it down.

    Version: T3 Code Desktop and local server 0.1.12-nightly.20261124.5178, background service install, Linux x64, expo-device-hub 0.26.1, agent-device 0.21.41.

    What happened

    1. At 14:15 UTC a thread opened the local Android AVD SWIM_Server_API_36 (emulator-5554) through device_open.
    2. Its last turn completed at 20:37. The thread was never settled and the agent never called device_close.
    3. Seven hours later the emulator was still running as a child of expo-device-hub inside the server's own cgroup, holding about 5 GB of RAM. On a 32 GB host with swap full, that pushed earlyoom into killing other agents' Codex and Claude processes. Those turns failed with "provider process exited with code 0".

    A second gap: another thread can't shut it down

    From a different thread, device_list showed the device booted with open: []. Calling device_close({ hostId: "local", deviceId: "emulator-5554", shutdown: true }) returned {} and the emulator kept running. In DeviceService.close, both the release and the shutdown only act on sessions whose threadId matches the caller, so a device owned by another thread is silently skipped. I had to stop it with adb -s emulator-5554 emu kill.

    Expected

    • A thread that finishes or settles releases its devices, and an emulator T3 booted is shut down once no thread holds it, or after an idle timeout. LocalDeviceHost.ts turns off agent-device's own idle timeout because "the server owns shutdown", but the server never does it.
    • device_close with shutdown: true for a device the caller doesn't own either shuts it down or returns an error, rather than {}.

    Created with Claude Opus 5.5 in T3 Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions