[Bug]: Settling a thread doesn't release the Android device session, blocking other threads from using it
Before submitting
- [x] I searched existing issues and did not find a duplicate.
- [x] I included enough detail to reproduce or investigate the problem.
Area
apps/desktop
Steps to reproduce
- Open thread A with device access enabled and an Android device connected via adb (device preview visible)
- Ask the agent to do some work that uses the device
- Let the agent finish without explicitly stopping the device session
- Settle thread A
- 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
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_openon 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(withshutdown: true) released session A once (then the agent reopened it) and session C. agent-device loggedClosed t3-…for each, sodevice_closeitself works. - 19:19:50: the thread settled. It never called
device_closefor A (after the reopen) or B, and agent-device logged no close for either at settle. - 19:37–19:51: other threads failed
openwithDEVICE_IN_USE: Device is already in use by session "t3-…". The claims were held for about 20–30 minutes, until a manualagent-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.
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
- At 14:15 UTC a thread opened the local Android AVD
SWIM_Server_API_36(emulator-5554) throughdevice_open. - Its last turn completed at 20:37. The thread was never settled and the agent never called
device_close. - 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.tsturns off agent-device's own idle timeout because "the server owns shutdown", but the server never does it. device_closewithshutdown: truefor 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.
Corroborating the completed-without-device_close case on macOS 27.2.1 with T3 Code Nightly 0.1.13-nightly.20261126.5305, expo-device-hub 0.26.1, and agent-device 0.21.41.
A delegated thread opened a local Android emulator (emulator-5554), completed its run without calling device_close, and stayed unsettled. That session held the agent-device claim for 8 hours 52 minutes and blocked two later verification threads with DEVICE_IN_USE until we found the original thread and called device_close from it. On main at 5596e749, ThreadSettlementService.ts still has no DeviceService release hook, and PR #32524 remains blocked on local Android emulator verification.
I also filed #43813 for the separate entry-point bug where device_open succeeds and leaves an unusable Device panel session open in a second thread during active contention.
Drafted by Gemini 4 Neon and posted by GPT-6.2-Sol in T3 Code on behalf of @davissears.
Same problem on iOS, and it can last for days.
Environment: macOS 26.5, T3 Code (Beta) 0.1.11, agent-device 0.21.36, iPhone 17 Pro Max simulator (iOS 26.5), Claude thread.
What happened: An earlier thread opened the iPhone simulator and ended without device_close. Two days later (session createdAt 2026-11-25), a different thread called device_open on the same simulator, which succeeded, but every bound agent-device open <app> --relaunch returned DEVICE_IN_USE for the old session, including with --wait 20000. agent-device session list still showed that session as the owner. The agent could only fall back to another simulator or ask me to run agent-device close --session … myself.
Why it hurts: I explicitly asked the agent to use that simulator and to take it over, but the device rules forbid reusing or closing another session even with the user's permission (see #36192), so the agent cannot recover on its own.
Suggested fix:
- Release a thread's device claims when its run ends or the thread is settled (this issue), and expire claims that have had no activity for a while (e.g. an hour).
- Show the claiming thread in the
DEVICE_IN_USEerror and the Device panel, with a one-click "Take over" for the user. - Or let the agent take over when the user explicitly authorizes it in the current thread.