Prewarm code-mode host connections at session startup (#40678)

## What changed

- Add the opt-in `code_mode_prewarm` feature to establish the code-mode host session during startup, before the first turn.
- Make in-progress host initialization cancellable so a stalled prewarm does not block shutdown.
- Share a failed connection attempt with concurrent callers instead of immediately starting another attempt.

## Testing

- Verify app-server contacts the configured host before the first turn and can shut down while that connection is stalled.
- Exercise shared remote-host behavior with prewarming enabled.

GitOrigin-RevId: 3cfde5509be7b4aba80112c36c5616b9a9b632c6
This commit is contained in:
Vivian Fang authored and copyberry committed 2026-08-25 19:16:45 +00:00
1 parent 17c4c47dfa
commit 4b24638e1c
6 files changed
+105 -14

No files matched your search

+8
View File
@@ -111,6 +111,8 @@ pub enum Feature {
CodeModeBufferedExec,
/// Run JavaScript code mode in the standalone host process.
CodeModeHost,
/// Establish the code-mode host connection during session startup.
CodeModePrewarm,
/// Terminate active code mode cells when their turn is interrupted.
CodeModeInterrupt,
/// Restrict model-visible tools to code mode entrypoints (`exec`, `wait`).
@@ -949,6 +951,12 @@ pub const FEATURES: &[FeatureSpec] = &[
stage: Stage::Stable,
default_enabled: true,
},
FeatureSpec {
id: Feature::CodeModePrewarm,
key: "code_mode_prewarm",
stage: Stage::UnderDevelopment,
default_enabled: false,
},
FeatureSpec {
id: Feature::CodeModeInterrupt,
key: "code_mode_interrupt",