Skip to content

Retried turn starts can make stored timelines unreadable #1839

Closed

Description

@brsbl

Summary

The host-to-server event channel is at-least-once, but daemon ingestion is not idempotent for turn/started. A committed batch whose acknowledgement is lost can be retried with the same provider turn ID, persist a duplicate start, and make timeline projection throw; the public timeline route returns 500 even though the thread data remains stored.

Implementation: PR #1560

Versions and environment

  • Reproduced on parent commit a83c12946790724383c84b665ac899b9d3bef601
  • Boundary: host daemon event delivery → server ingestion → timeline projection
  • Reproduction uses in-memory SQLite and synthetic persisted events

Steps to reproduce

  1. Insert two turn/started events for the same (threadId, turnId), simulating a daemon retry after an ambiguous 502/504 response.
  2. Request that thread's public timeline.
  3. Observe the unfixed route return 500 because projection sees two starts for one provider turn.

The exact red fixture and command are documented in PR #1560.

Expected vs actual

Expected: re-delivery is idempotent and previously persisted duplicate histories remain readable.

Actual: a duplicate receives a fresh event ID and sequence; projection throws. The regression fails on the parent with AssertionError: expected 500 to be 200.

Evidence

  • Ingestion now resolves stored turn identities and skips duplicate starts in events.ts.
  • Legacy projection compatibility and route-level regressions are included in PR #1560.

What you ruled out

  • Not distinct provider turns: the incident repeated stable turn and item IDs at later server sequences.
  • Not general exactly-once delivery: the required boundary is semantic idempotency for turn/started.
  • Not Codex thread shows idle (no spinner) while actively running commands #1646: that issue is missing/late starts during continuation, not duplicate starts from delivery replay.
  • No exact open or closed issue matched the invariant, PR URL, originating thread, or failure output.

Suggested priority and effort

High priority, medium effort: affected threads become unreadable; the fix must protect new ingestion and tolerate persisted duplicates.

Originating implementation thread: thr_tq4bctwps7

AGENT GENERATED: by GPT-5.6-Sol

Activity

  1. added
    bug
    threads
    host
    confirmed-repro
    on Aug 18, 2026
  2. added theissue type on Aug 18, 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

    bugconfirmed-reprohostthreads

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions