mirror of
https://github.com/openai/codex.git
synced 2026-10-19 17:28:46 +00:00
## What changed Add an optional `preempt` signal to `CodeModeSession::execute` and `CodeModeSession::wait` so callers can end an observation early while the cell continues running and remains available for later waits. Support the signal in the in-process runtime and across both remote transports: `operation/yield` with the negotiated `yield-observation` capability for stdio, and `YieldObservation` for gRPC. Preserve signals received before gRPC observation registration, and retain normal timeout behavior for older hosts that lack support. ## Testing Add runtime and transport tests covering early execute and wait yields followed by successful cell completion, yields before observation registration, and suppression of yield frames for older stdio hosts. GitOrigin-RevId: 3f8049d8f0582be6b8f0832cc03f2d974a0b8f18
49 lines
1.5 KiB
Rust
49 lines
1.5 KiB
Rust
use codex_code_mode_protocol::NoopCodeModeSessionDelegate;
|
|
use codex_code_mode_runtime::ExecuteRequest;
|
|
use codex_code_mode_runtime::InProcessCodeModeSession;
|
|
use codex_code_mode_runtime::RuntimeResponse;
|
|
use codex_code_mode_runtime::V8JitMode;
|
|
use codex_code_mode_runtime::initialize_v8;
|
|
use pretty_assertions::assert_eq;
|
|
use std::sync::Arc;
|
|
|
|
#[tokio::test]
|
|
async fn code_mode_runs_with_jit_disabled() {
|
|
initialize_v8(V8JitMode::Disabled).expect("initialize V8 without JIT");
|
|
|
|
let service = InProcessCodeModeSession::new();
|
|
let started = service
|
|
.execute(
|
|
ExecuteRequest {
|
|
tool_call_id: "call_1".to_string(),
|
|
enabled_tools: Vec::new(),
|
|
source: "21 * 2;".to_string(),
|
|
yield_time_ms: None,
|
|
max_output_tokens: None,
|
|
},
|
|
Arc::new(NoopCodeModeSessionDelegate),
|
|
/*preempt*/ None,
|
|
)
|
|
.await
|
|
.expect("start code-mode cell");
|
|
let cell_id = started.cell_id.clone();
|
|
let response = started
|
|
.initial_response()
|
|
.await
|
|
.expect("execute code-mode cell");
|
|
|
|
assert_eq!(
|
|
response,
|
|
RuntimeResponse::Result {
|
|
code_mode_host_duration: None,
|
|
cell_id,
|
|
content_items: Vec::new(),
|
|
error_text: None,
|
|
}
|
|
);
|
|
assert_eq!(
|
|
initialize_v8(V8JitMode::Enabled),
|
|
Err("V8 was already initialized with JIT disabled".to_string())
|
|
);
|
|
}
|