openai / openai/codex

Feature request: return explicit state for every wait_threads target

Open
#41,972 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

app app-server enhancement
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What version of the Codex App are you using?

Current Codex Desktop task tools exposing wait_threads with per-target threadId, optional hostId, and optional afterCursor.

What subscription do you have?

Not subscription-specific.

What platform is your computer?

Not platform-specific.

What issue are you seeing?

wait_threads wakes when the first requested target completes or needs attention, but it does not provide a stable contract that returns the explicit current state of every requested target.

For multi-target coordination, the caller needs to know which targets are queued, running, waiting for input, completed, failed, or unavailable after every wait. An omitted target or a compact progress entry is not enough to distinguish unchanged state from unknown state, and it encourages extra reads or accidental duplicate dispatch.

The wait response should contain a complete per-target state vector on every return, including when one target wins the wake and when the call times out.

A backward-compatible shape could be:

{
  "wake": {
    "reason": "turnCompleted",
    "threadId": "thread-a",
    "turnId": "turn-a-3"
  },
  "targets": [
    {
      "threadId": "thread-a",
      "hostId": "host-1",
      "state": "completed",
      "cursor": "cursor-a-3",
      "triggeredWake": true,
      "turnId": "turn-a-3"
    },
    {
      "threadId": "thread-b",
      "hostId": "host-1",
      "state": "running",
      "cursor": "cursor-b-8",
      "triggeredWake": false
    }
  ]
}

The exact state names are flexible, but they should form a documented closed set such as queued, running, needs_attention, completed, failed, and unavailable. Each requested target should appear exactly once, in request order, with its current cursor or revision and whether it caused the wake.

Expected behavior
  • Every requested target appears exactly once in every successful wait_threads response.
  • Each target has an explicit current state, even when another target caused the wake.
  • Timeout responses still carry the complete state vector.
  • Each target carries its latest cursor or revision so the next wait can advance without reconstructing state.
  • Per-target failures are represented on that target as typed state/error data rather than only in a detached aggregate error list.
  • Terminal final text can remain cursor-suppressed after delivery; state must not disappear with it.
  • Existing top-level wake behavior can remain unchanged.
Why this is useful

A complete state vector makes one bounded multi-target wait sufficient for orchestration. The parent can resume only running targets, surface only attention-required targets, and retain terminal knowledge without polling every task separately.

It also prevents a missing or compacted target entry from being interpreted as idle, failed, or never dispatched.

Related issues
  • #40397 requests exact turn correlation between send_message_to_thread and wait_threads. This request is complementary: it asks for complete current state for every target in a multi-target wait, whether or not exact turn targeting is also added.
  • #26822 reports missing terminal child state in the separate collaboration-agent wait surface. This request is specifically for the first-party wait_threads task API and its per-target response contract.
  • #24951 concerns timeout enforcement in multi-agent waiting. This request concerns the data returned when a bounded wait does return.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the wait_threads task API and trace its response schema, wake behavior, and timeout path. Review related issues #40397, #26822, and #24951 for surrounding constraints. Done means every requested target has one explicit state entry, including on timeout, with cursor or revision and per-target failure information.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.