Skip to content

enhancement(codex): distinguish a live but not-yet-persisted Codex thread from a missing target #166

Closed

Description

@abruption

Summary

send --to codex:<uuid> (including --dry-run and an explicit --codex-home) reports thread_not_saved_in_known_homes for a live Codex session whose thread has not been persisted yet (before its first turn completes). The message cannot be distinguished from a wrong UUID or wrong home, and list --agent codex --all does not show the session either. Diagnosing it required tracing the process cwd and writer lock with lsof.

This is a diagnostics enhancement, not a delivery bug: refusing to queue to an unsaved thread is correct because Codex queueing requires a saved thread/rollout.

Environment

  • session-peer 1.0.0rc2, macOS (mac-mini), Orca-managed Codex home
  • Observed 2026-09-23

Observed

  1. A new Codex session was started, but no message had been sent to it yet.
  2. The process held <home>/thread-writer-locks/<uuid>.lock, but state_5.sqlite had no row for that thread.
  3. list --agent codex --all (auto-discovery and explicit --codex-home) did not list the session.
  4. send --to codex:<uuid> --codex-home <home> --dry-run returned No saved Codex thread <uuid> in known homes; nothing queued. (reason: thread_not_saved_in_known_homes).
  5. After the first turn completed, the same dry-run resolved as explicit_live_writer, and a real send was queued normally.

Reproduction

  1. Start a new Codex session and do not send it a message.
  2. Run session-peer send --to codex:<uuid> --codex-home <home> --dry-run --message test.
  3. Observe thread_not_saved_in_known_homes.
  4. Send one message in that session, wait for the turn to finish, and repeat step 2. It now resolves.

Code location

session_peer_core/codex.py (standalone session_peer.py equivalent): when no candidate home has a saved thread, resolve raises NoTargetError(thread_not_saved_in_known_homes) without consulting thread-writer-locks/<uuid>.lock, although inspect_codex_writer already knows how to probe that lock.

Proposal

  1. send / dry-run: if no home has a saved thread but exactly one home has a stably held writer lock for the same UUID, report a distinct reason (e.g. thread_not_yet_persisted) with actionable guidance such as "the Codex session has not finished its first turn; retry after it does." Still queue nothing.
  2. doctor: report "live writer lock without a saved thread" as an unsaved session.
  3. list (optional): consider exposing such sessions in --all with a field like persisted: false. This is an additive JSON schema change, so it needs a separate decision.
  4. Keep fail-closed: do not add any workaround that queues to an unsaved thread; only improve diagnostics.

Acceptance

  • Unit tests cover: no saved thread plus a held lock → thread_not_yet_persisted; no saved thread and no lock → unchanged thread_not_saved_in_known_homes; a stale lock (dead owner) is not treated as live.
  • No behavior change for saved threads or for home-selection rules.

Activity

  1. added this to the v1.0.0-rc.3 milestone on Sep 23, 2026
  2. abruption commented on Sep 23, 2026

    @abruption
    OwnerAuthor

    Milestone: v1.0.0-rc.3 as a non-blocking item. RC3's purpose is the #161 Relay stability validation (#163/#164); this diagnostics-only change must not delay it.

    • Scope stays diagnostics-only and fail-closed: no queueing to unsaved threads.
    • Merge only before the RC3 five-host four-hour campaign starts, so a late change cannot confound its results. If it is not ready by then, move it to v1.0.0 or 1.0.1 instead of holding RC3.
  3. modified the milestones: v1.0.0-rc.3, v1.0.0 on Sep 23, 2026
  4. abruption commented on Sep 23, 2026

    @abruption
    OwnerAuthor

    Deferred out of v1.0.0-rc.3 by maintainer decision (2026-09-23): RC3 is scoped to the #161/#163 Relay stability validation. Moved to the v1.0.0 milestone; it remains non-blocking and may move to a later patch release.

  5. modified the milestones: v1.0.0, v1.0.1 on Sep 24, 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

    No labels
    No labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions