Expose non-consuming input activity waits to hosts (#58411)

## Why

Host-owned tools need to wait for agent messages or steering input with the same behavior as native `wait_agent`, including when native multi-agent support is disabled.

## What changed

- Add `CodexThread::wait_for_input_activity` and export `InputWaitOutcome` through core and core-api, sharing the wait implementation with `wait_agent`.
- Distinguish notifying agent messages from steering input, with steering taking precedence when both are pending. Passive response items do not wake waits.
- Observe input without consuming it. Waits remain active after the original turn ends, support independent observers, and can be cancelled by dropping the future.

## Testing

Add coverage for pending and incoming input, agent-message classification, cancellation, independent observers, timeouts, and input arriving after the original turn completes or is interrupted.

GitOrigin-RevId: d0c0bd776c3b6fd4ba3021603d87eaaf1d93976f
This commit is contained in:
rhan-oai
2026-10-30 18:34:10 +00:00
committed by copyberry
parent 0e31c29e25
commit 6df44f08dd
7 changed files with 425 additions and 64 deletions
+14
View File
@@ -460,6 +460,20 @@ impl CodexThread {
.await
}
/// Waits for input activity without consuming input, following native `wait_agent` behavior.
///
/// The named turn supplies any already-buffered steering input. Subsequent activity is
/// thread-wide: ending or replacing that turn does not end this wait. Mailbox input
/// already pending is also observed. Callers own cancellation; dropping this future
/// does not consume input or affect execution. Each call observes independently.
pub async fn wait_for_input_activity(
&self,
turn_id: &str,
timeout: std::time::Duration,
) -> crate::InputWaitOutcome {
crate::thread_input::wait_for_input_activity(&self.session, turn_id, timeout).await
}
/// Submits turn input without requiring the caller to inspect thread state.
///
/// The result describes whether Core started a turn, steered an active