Skip to content

iOS prompt sends stall silently in the background upload session #1002

Closed

Description

@ivanfenenko

Problem

An iOS user reported that the app stopped sending prompts to opencode while session sync kept working and other clients worked. In their diagnostic log, /agent and /model answered in milliseconds before each send, but most /prompt requests never logged a response or failure. Each stall ended around the app going to the background. The server is ruled out: catalog calls that wait on the same plugin activation as /prompt answered in 100–450 ms during the waits, and v2.2.6 admits the same request in ~4 ms.

Prompts are the only request iOS sends through the background URLSession (DurableJSONUploader, OPE-221). The upload runs in the system daemon, which can defer or hold it with no signal to the app. Reproduced on a simulator through a faulting proxy:

  • A held connection is retried by the daemon after ~65 s on its own timer, with no error reaching the app.
  • Send stays disabled in that chat until the user leaves it.
  • Stuck uploads survive app relaunches and land minutes later, out of order.
  • A connection cap at a proxy holds the prompt until another connection closes; backgrounding releases it.

The log cannot say which of these hit the user: it has no upload progress, connection timing, power or data mode, or leftover task count, and it hides the server's echo of the prompt.

Scope (iOS)

Diagnostics:

  • Per send: transport, app state, Low Power Mode, network path (status, constrained, expensive, interface type).
  • While pending: a line every 10 s with task state and bytes sent/received.
  • On completion: URLSessionTaskMetrics per transaction (fetch, connect, TLS, request, response timings, reused connection, protocol, proxy, constrained/expensive/cellular). No remote addresses.
  • At launch: leftover background tasks, their age and state.
  • Log the server's echo of user messages (message.updated role=user with its id) instead of hiding it.

Hardening:

  • While the app is active, send prompts over an in-process session first. Hand off to the background session when the app is about to be suspended with the send unanswered, or when the direct attempt cannot reach the server. Every attempt reuses the same body and message id.
  • Stall watchdog: after 20 s with no answer in the foreground, show "Still sending…" with Retry. Retry starts a fresh connection with the same id.
  • At launch, cancel background prompt uploads the app no longer tracks that are older than 2 minutes, so an abandoned prompt does not land much later.

Platform notes

  • Android sends prompts in-process with a 60 s socket timeout, so a stuck send already ends in a visible error with the draft restored. No change there.
  • v2 servers ignore a repeated prompt id (SessionInbox.reconcile), so retries and handoffs cannot duplicate a v2 prompt.

Acceptance

  • With /prompt held at a proxy, the app shows "Still sending…" with Retry within ~20 s; Retry delivers the prompt once.
  • A send started in the foreground still completes when the app is backgrounded mid-send.
  • The diagnostic log shows the new per-send lines.

Activity

  1. added
    bug
    ios
    on Nov 9, 2026
  2. added a commit that references this issue on Nov 9, 2026
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

    bugios

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions