Files
codex/codex-rs/codex-mcp/src/user_verification_elicitation.rs
T
Rennie 40584fad87 Keep MCP user interaction on the root thread (#46066)
## Why

MCP requests that need human input, including browser sign-in, must be handled by the root thread. Subagents need guidance to hand these blockers to their parent without prompting the user or automatically accepting requests that require input.

## What changed

- Reject interactive MCP elicitations and tool approval prompts in subagents with guidance to ask the parent and wait before retrying.
- Recognize browser authentication and `codex_requires_user_input` metadata even when the form schema is empty, while preserving automatic permission approvals and review decisions.
- Carry user-interaction eligibility through MCP runtime creation and connection reuse, and guard prompt registration.
- Preserve connector authentication diagnostics alongside handoff guidance, subject to normal tool-output limits.

## Testing

Add unit and integration coverage for blocked subagent prompts, root browser authentication, automatic approval and review, connection reuse, and authentication diagnostic preservation and truncation. Add a request-history snapshot for browser-auth handoff guidance.

GitOrigin-RevId: 83e146b6e5c1a2a22a34681ad45615f504b3c96c
2026-09-17 01:18:37 +00:00

37 lines
1.1 KiB
Rust

//! Routes device verification directly to the app, outside automated approval policy.
use super::*;
pub(super) async fn route(
router: ElicitationRequestRouter,
events: Option<Sender<Event>>,
authority: Option<ElicitationAuthority>,
server_name: String,
request: ElicitationRequest,
) -> Result<ElicitationResponse> {
let plugin_service = authority.as_ref().is_some_and(|authority| {
authority
.config
.mcp_server_catalog
.server(&server_name)
.is_some_and(|server| {
server
.source()
.is_host_owned_apps(&server_name, server.config())
})
});
let Some((events, authority)) = events
.zip(authority)
.filter(|_| plugin_service && !router.auto_deny())
else {
return Ok(ElicitationResponse {
action: ElicitationAction::Cancel,
content: None,
meta: None,
});
};
router
.request_user_interaction(Some(events), &authority, server_name, request)
.await
}