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 authored and copyberry committed 2026-09-02 02:09:35 +00:00
1 parent b21f2e3081
commit 2c79ee6dac
80 files changed
+1110 -146

No files matched your search

+9 -3
View File
@@ -23,8 +23,8 @@ use crate::tools::handlers::PlanHandler;
use crate::tools::handlers::ReadMcpResourceHandler;
use crate::tools::handlers::RequestPermissionsHandler;
use crate::tools::handlers::RequestPluginInstallHandler;
use crate::tools::handlers::RequestUserInputAsyncHandler;
use crate::tools::handlers::RequestUserInputHandler;
use crate::tools::handlers::SendUserMessageAsyncHandler;
use crate::tools::handlers::SleepHandler;
use crate::tools::handlers::TestSyncHandler;
use crate::tools::handlers::ToolSearchHandlerCache;
@@ -1163,10 +1163,16 @@ fn add_core_utility_tools(context: &CoreToolPlanContext<'_>, registry: &mut Tool
.model_info
.experimental_supported_tools
.iter()
.any(|tool| tool == "send_user_message_async")
// Existing model catalogs still advertise the previous name.
.any(|tool| {
matches!(
tool.as_str(),
"request_user_input_async" | "send_user_message_async"
)
})
{
registry.add_with_exposure(
SendUserMessageAsyncHandler {
RequestUserInputAsyncHandler {
description: context
.model_messages
.and_then(|messages| messages.tools.as_ref())