Skip to content

Android leases over HTTP give no adb serial: udid is the AVD name #817

Closed

Description

@V3RON

What happened

A lease granted over the HTTP API gives no way to reach an Android emulator with adb. The lease object's udid is the device's driver id (device.driverDeviceId, src/http/tracker.ts:71). For an Android emulator that is the AVD name (simlock_<uuid>), not the adb serial (emulator-5554) that adb -s needs. No HTTP response carries the serial: the lease object has no address field, although the contract's device record has one (src/contract/schemas.ts:211,272) and the CLI's lease line includes device.address.

So a remote agent that leases an Android device over HTTP cannot run adb -s <serial> … through POST /v1/leases/{id}/exec without first running adb devices and then adb -s <serial> emu avd name on each serial to find its own. iOS is not affected, because a simulator's driver id and its address are both the UDID.

What you expected

The HTTP lease object names the address to point tools at (the adb serial on Android, the UDID on iOS), the same value the CLI prints as device.address.

How to reproduce

  1. On a worker with Android set up and HTTP on, create an agent token: simlock token create --role agent.
  2. curl -X POST http://127.0.0.1:4701/v1/lease-requests -H "Authorization: Bearer <secret>" -H 'Content-Type: application/json' -d '{"platform":"android","model":"Pixel 8"}', then wait until the request is granted.
  3. Look at the lease object: udid is simlock_…, and no field holds emulator-5554.
  4. Compare simlock lease --platform android --device "Pixel 8" --detach, whose device.address is the serial.

Environment

main at 4cc44f8. Found while writing the website's "Remote agents over HTTP" page (PR #816), which documents the adb devices workaround.

Logs and evidence

  • src/http/tracker.ts:71: udid: device.driverDeviceId
  • src/drivers/android/index.ts:948: a running emulator's address is running.serial; :918: its deviceId is the AVD name.

Written by an agent.

Activity

  1. added
    bug:new
    and removed
    bug:new
    on Oct 21, 2026
  2. self-assigned this
    on Oct 23, 2026
  3. V3RON commented on Oct 23, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    Confirmed as reported. A gap: the expected address field beside udid is a proposal.

    src/http/app.test.ts › lease routes › "names an Android emulator's adb serial as address, beside its AVD name as udid, on the lease object the POST, the request poll and GET /v1/leases/:id answer", on bug/817-repro.

    pnpm exec vitest run --project unit src/http/app.test.ts -t "adb serial as address"
    
      {
        "get":  { -  "address": "emulator-5554",  "udid": "simlock_3f9a2c1e" },
        "poll": { -  "address": "emulator-5554",  "udid": "simlock_3f9a2c1e" },
        "post": { -  "address": "emulator-5554",  "udid": "simlock_3f9a2c1e" },
      }
     ❯ src/http/app.test.ts:1526  }).toMatchObject({ get: named, poll: named, post: named });
    

    Root cause

    Gap. The address reaches the HTTP layer on every path: the grant's device.address (src/contract/schemas.ts:272), the worker registry's DeviceRecord.address, and a gateway's grantedDevices() (grant shape). buildLeasePayload (src/http/tracker.ts:60) copies only driverDeviceId, into udid (:71); HttpLeaseDevice (:376) has no address, so it is dropped. The OpenAPI leasePayloadSchema (src/http/lease-declarations.ts:16) lacks it too.

    Simplest fix

    Add address?: string to HttpLeaseDevice and LeasePayload, spread it in buildLeasePayload when defined, declare it optional in leasePayloadSchema, and replace the adb devices workaround in remote-agents.mdx:153 with adb -s <address>. The tracker change alone turns the test green, with the rest of app.test.ts still green.

    Shape pinned: a field named address, as the CLI's device.address; udid unchanged.

    Alternatives rejected

    • Serial in udid on Android: changes a documented field's meaning.
    • Exec adds -s <serial> for virtual adb: fixes exec only, not other clients.
    • ANDROID_SERIAL in the virtual lease environment: the HTTP lease object does not carry the environment.

    Risk

    • Gateway GET /v1/leases/:id reads grantedDevices(): check the worker refresh keeps address. The test covers the worker only.
    • A device never made ready, or shut down, has no address: the field stays optional and the docs say so.
    • check-openapi.mjs must pass with the new field.

    Written by an agent.

  4. removed their assignment
    on Oct 23, 2026
  5. added
    bug:ready
    and removed on Oct 23, 2026
  6. self-assigned this
    on Oct 23, 2026
  7. added a commit that references this issue on Oct 23, 2026
    3de46d1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions