elicitations: Move to shared ElicitationService (#30627)

## Why

Code-mode tool results could return to the model while an MCP
elicitation was still waiting for user input. This differed from
parallel tool calling and could let the model continue before the user
resolved the request.

We need one session-level view of outstanding elicitations so tool
runtimes can consistently hold results until every pending elicitation
is resolved.

  ## What changed

- Added a counted, session-owned ElicitationService with RAII
registrations.
- Registered both core-originated and server-originated MCP elicitations
with the service.
- Migrated out-of-band elicitation tracking and unified exec timeout
pausing to the shared service.
- Made code-mode functions.exec and functions.wait capture their runtime
result normally, then hold it before returning while an elicitation is
outstanding.
  - Kept terminate: true immediate; only its result is held.
  - Preserved model-visible wall time across the elicitation hold.
- Kept the behavior session-scoped, with concurrent elicitations holding
the pause until all registrations are released.
This commit is contained in:
Channing Conger authored and GitHub committed 2026-07-06 11:20:32 -07:00
1 parent 8268cbfb0e
commit 84fe70c30e
22 files changed
+302 -49

No files matched your search

+3 -4
View File
@@ -160,7 +160,7 @@ async fn exec_command_with_tty(
&output_closed,
&output_closed_notify,
&cancellation_token,
Some(session.subscribe_out_of_band_elicitation_pause_state()),
Some(session.subscribe_elicitation_pause_state()),
deadline,
)
.await;
@@ -515,12 +515,11 @@ async fn unified_exec_pause_blocks_yield_timeout() -> anyhow::Result<()> {
skip_if_sandbox!(Ok(()));
let (session, turn) = test_session_and_turn().await;
session.set_out_of_band_elicitation_pause_state(/*paused*/ true);
let elicitation = session.services.elicitations.register();
let paused_session = Arc::clone(&session);
tokio::spawn(async move {
tokio::time::sleep(Duration::from_secs(2)).await;
paused_session.set_out_of_band_elicitation_pause_state(/*paused*/ false);
drop(elicitation);
});
let started = tokio::time::Instant::now();
@@ -493,11 +493,7 @@ impl UnifiedExecProcessManager {
&output_closed,
&output_closed_notify,
&cancellation_token,
Some(
context
.session
.subscribe_out_of_band_elicitation_pause_state(),
),
Some(context.session.subscribe_elicitation_pause_state()),
deadline,
)
.await;
@@ -839,7 +835,7 @@ impl UnifiedExecProcessManager {
let pause_state = entry
.session
.upgrade()
.map(|session| session.subscribe_out_of_band_elicitation_pause_state());
.map(|session| session.subscribe_elicitation_pause_state());
let session = entry.session.upgrade();
Ok(PreparedProcessHandles {