Skip to content

bug(workspace): awaitPersistedReply can poll for an hour when the in-flight marker is orphaned #2133

Closed

Description

@trinity-ability

Found while validating #2120.

Context — the unbounded wait is deliberate, and correct

#2120's review fixed a real double-billing chain: awaitPersistedReply used to budget a fixed ~10.5s from stream end, so any turn persisting later (notably the cold --resume retry, which re-runs the WHOLE turn) was rendered "not delivered" with a Retry that ran and billed it a second time.

The fix makes the wait bounded by the server's answer instead of a stopwatch, which is the right shape:

// components/portal/PortalConversation.vue
for (;;) {
  ...
  if (data.inFlightExecutionId) { idlePolls = 0 }
  else if (++idlePolls >= REPLY_IDLE_GIVE_UP) return null
  await new Promise((r) => setTimeout(r, REPLY_POLL_MS))   // 700ms
}

The residual

The loop has no absolute ceiling. It exits only when the server stops reporting an in-flight execution. That marker is cleared in a finally on every exit path of start_portal_turn._run, so the normal case is fine — but except Exception does not catch CancelledError, and a hard backend kill skips the finally entirely. The marker then survives until its TTL:

def mark_turn_inflight(session_id, execution_id, ttl_seconds: int = 3600) -> None:

One hour. At REPLY_POLL_MS = 700 that is ~5,100 GET /history requests from a single tab, each hitting the DB, for a turn that is already dead. Multiple tabs multiply it. Nothing in the UI tells the user the turn is not coming.

Suggested fix

A generous absolute ceiling that cannot be hit by a legitimate turn — the agent's own execution timeout plus the cold-retry allowance (so roughly 2 × execution_timeout + buffer) — after which the UI reports that it lost track of the turn and points at history, without offering a Retry (the original billing hazard).

Worth pairing with a wider poll interval once elapsed time is large, so a long legitimate turn costs far fewer requests.

Acceptance criteria

Related: #2120, abilityai/trinity-enterprise#358, abilityai/trinity-enterprise#286

Activity

  1. added
    priority-p3
    type-bug
    theme-reliability
    complexity-low
    on Aug 12, 2026
  2. added
    status-in-progress
    on Aug 13, 2026
  3. self-assigned this
    on Aug 13, 2026
  4. added
    status-in-dev
    and removed
    status-in-progress
    on Aug 13, 2026
  5. removed
    status-in-dev
    on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

complexity-lowpriority-p3theme-reliabilitytype-bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions