Add structured asynchronous user input requests (#42178)

## What changed

- Replace `send_user_message_async` with `request_user_input_async`, accepting one or more questions with optional suggested answers while allowing the turn to continue.
- Attach structured question metadata to asynchronous agent messages while retaining readable fallback text, and preserve it through app-server events, thread history, and generated schemas.
- Continue enabling the new tool for model catalogs that advertise either the old or new tool name.

## Testing

- Cover tool registration, question validation, emitted items, continued turn execution, history preservation, and backwards-compatible deserialization.

GitOrigin-RevId: ffc49aebde2e854c3c50a122aa52805fec3fc6b3
This commit is contained in:
rka-oai
2026-09-02 02:09:35 +00:00
committed by copyberry
parent b21f2e3081
commit 2c79ee6dac
80 changed files with 1110 additions and 146 deletions
+4
View File
@@ -34,6 +34,7 @@ use crate::dynamic_tools::DynamicToolResponse;
use crate::dynamic_tools::DynamicToolSpec;
use crate::error::Result as CodexResult;
use crate::items::AgentMessageDelivery;
use crate::items::AsyncUserInputQuestion;
use crate::items::TurnItem;
use crate::mcp::CallToolResult;
use crate::mcp::RequestId;
@@ -2496,6 +2497,9 @@ pub struct AgentMessageEvent {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub delivery: Option<AgentMessageDelivery>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub questions: Option<Vec<AsyncUserInputQuestion>>,
}
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, JsonSchema, TS)]