Skip to content

turn/completed can precede command completion and wedge later turns between active-writer and no-session errors #2327

Description

@pixexid

Summary

A Codex-backed thread emitted turn/completed while a command-execution item from that same turn was still running. The command later emitted output and item/completed after the terminal turn event. Every subsequent new-turn request then failed in one of two contradictory states:

  • thread <provider-thread> already has an active writer
  • No active codex session for thread <bb-thread>

Stopping the broken runtime and retrying the exact input did not recover the thread. Provider retry refused because the input had not been accepted, and edit-message could not apply because the rejected request was agent-origin rather than an editable user turn.

Native ordering evidence

For one exact turn/provider-thread:

  1. item/started for a long-running commandExecution.
  2. turn/completed with status=completed.
  3. item/commandExecution/outputDelta for the still-running command.
  4. item/completed for that command, reporting success and a multi-minute duration.
  5. A later client/turn/requested was rejected as already has an active writer.
  6. A recovery new-turn request was rejected as No active codex session.
  7. A further exact redelivery again rejected as already has an active writer.

This is a native event/state contradiction: the turn was publicly terminal before all of its writer-owned items terminalized, leaving BB and the provider bridge disagreeing about whether a session/writer existed.

Expected behavior

  • Do not emit turn/completed until every command/tool/item belonging to that turn is terminal and no turn writer remains.
  • If a provider sends premature completion, BB should delay/fail the terminal event or reconcile outstanding items deterministically.
  • A terminal thread must not simultaneously report both active-writer and no-active-session states.
  • Stop/restart should clear any orphaned writer ownership without deleting event history or replaying rejected input.
  • Rejected agent-origin requests need a supported exact-redelivery recovery path; edit-message is not applicable.

Acceptance

  1. A fixture delays command completion beyond provider turn completion; BB does not publish terminal completion first.
  2. After true terminalization, one new-turn request is accepted exactly once.
  3. Stop/restart clears stale writer ownership while preserving interruption/history.
  4. Tests cover the contradictory already has an active writer / No active codex session sequence and prove it cannot persist.

No repository or canonical-state mutation is needed to reproduce; this report is based on bounded native event reads.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

confirmed-reproBug reproduced again from a clean trusted checkout; see linked reportprovider-codexBuilt-in plugin: provider-codexprovidersCross-provider bridges, models, loginthreadsTurns, timeline, messaging, forks

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions