codex icon indicating copy to clipboard operation
codex copied to clipboard

[TUI] Clarify fan-out/fan-in intent across wait_threads/read_thread and native multi-agent semantics

Open starSumi opened this issue 1 week ago • 1 comments

What variant of Codex are you using?

CLI / TUI (codex-cli 0.170.0, Windows 11), using the codex_tui MCP task tools.

What feature would you like to see?

In my TUI workflow, Codex often misses the fan-out / fan-in orchestration intent behind the codex_tui task tools (create_thread to fan out parallel tasks, wait_threads to fan in on state changes, and read_thread to harvest results). Instead, Codex has treated wait_threads as though another task's reply would arrive like a native subagent message—skipping read_thread when it needs information from a particular thread and continuing to wait, requiring me to explain the workflow manually.

Could the tool descriptions and shared guidance make this fan-out/fan-in design intent and result-collection flow explicit across these two workflows, and align their behavior where appropriate?

The main gaps are:

  1. Fan-in synchronization and result reading have distinct roles. Native v2 wait_agent waits for mailbox activity where agent messages are delivered separately. By contrast, codex_tui is designed around a pull-based fan-out / fan-in loop: wait_threads synchronizes across dispatched threads and can include the latest assistant message, but that message is omitted when changed is false, and an included message is not necessarily a final answer. A missing message does not establish that a worker failed or stalled, and a single wake does not mean every fanned-out target is done. When the next step needs a specific thread's content, Codex needs to recognize when to use read_thread rather than wait again.
  2. The default wait is not stated in the tool schema. Omitting timeoutMs uses a 120,000 ms timeout, with an earlier return when a wake condition occurs. The description highlights timeoutMs: 0 for a snapshot but does not explain this default. Making both modes explicit could help avoid repeated zero-timeout calls when the intent is to await a result.
  3. Sending a message changes execution. send_message_to_thread goes through turn/start and the start-or-steer path: it can steer an active turn or start a new turn when the thread is idle. This differs from native v2 send_message, which does not trigger a new turn. The model should understand this distinction before sending a corrective prompt in response to an empty wait result.
  4. Shared guidance is missing from the TUI MCP metadata. DynamicToolMcpHandler::get_info() does not set server instructions, and list_tools() retains function descriptions while dropping DynamicToolNamespaceSpec.description. The MCP client already maps server instructions to a namespace description, so this is an existing place to convey the fan-out/fan-in workflow.

I would like each tool's description to explain its role in the fan-out/fan-in lifecycle and the relevant next step:

  • create_thread / fork_thread: fan-out task dispatch with inherited working directory and no automatic file isolation; forking completed history without starting a turn.
  • wait_threads: fan-in convergence across targets, including the 120-second default, snapshot mode (timeoutMs: 0), conditional message fields, tracking remaining unresolved targets, and afterCursor for change tracking.
  • read_thread: post-wake targeted, bounded history and output retrieval—including pagination, turnLimit, includeOutputs, and output limits—to collect and verify deliverables.
  • send_message_to_thread: steering an active turn or starting an idle one.

The native v2 guidance could make the mailbox push distinction equally explicit. A concise shared fan-out/fan-in summary in MCP instructions and the namespace description could complement the individual descriptions, accounting for truncation and the tools actually exposed.

The goal is for Codex to recognize the intended fan-out/fan-in workflow—knowing when to wait, when to read a particular task, and when a message would intervene in its execution—without requiring local skills, instruction files, or hooks to explain basic tool behavior.

Additional information

Relevant source locations:

starSumi avatar Nov 20 '26 09:11 starSumi

One acceptance case for the wait/read boundary: fan out to A and B, then let A post progress, B finish, and A finish later. The first wake must leave both targets pending; the second should make only B eligible for a targeted read. Integration should start only once both required outputs have actually been read, even if a terminal state's message was omitted or truncated. A terminal failure should resolve the wait without counting as a usable output.

That gives the tool guidance a concrete distinction to teach: a wake changes what to inspect; a targeted read establishes what can be integrated. An empty wake isn't a reason to send a new turn.

Disclosure: this is an AI-assisted design suggestion from the TeamSwarm maintainer account, not a test result or an official Codex response.

DrPei12 avatar Nov 21 '26 01:11 DrPei12